001
014
015 package com.liferay.portal.tools;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.util.FileImpl;
019
020 import java.io.File;
021
022 import java.text.DateFormat;
023
024 import java.util.Date;
025 import java.util.Properties;
026
027
030 public class ReleaseInfoBuilder {
031
032 public static void main(String[] args) {
033 new ReleaseInfoBuilder();
034 }
035
036 public ReleaseInfoBuilder() {
037 try {
038
039
040
041 Properties releaseProps =
042 _fileUtil.toProperties("../release.properties");
043
044 String version = releaseProps.getProperty("lp.version");
045
046 File file = new File(
047 "../portal-service/src/com/liferay/portal/kernel/util/" +
048 "ReleaseInfo.java");
049
050 String content = _fileUtil.read(file);
051
052 int x = content.indexOf("String version = \"");
053 x = content.indexOf("\"", x) + 1;
054 int y = content.indexOf("\"", x);
055
056 content =
057 content.substring(0, x) + version +
058 content.substring(y, content.length());
059
060
061
062 x = content.indexOf("String build = \"");
063 x = content.indexOf("\"", x) + 1;
064 y = content.indexOf("\"", x);
065
066 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
067
068 content =
069 content.substring(0, x) + build +
070 content.substring(y, content.length());
071
072
073
074 DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
075
076 String date = df.format(new Date());
077
078 x = content.indexOf("String date = \"");
079 x = content.indexOf("\"", x) + 1;
080 y = content.indexOf("\"", x);
081
082 content =
083 content.substring(0, x) + date +
084 content.substring(y, content.length());
085
086
087
088 _fileUtil.write(file, content);
089
090
091
092 file = new File("../sql/portal-data-release.sql");
093
094 content = _fileUtil.read(file);
095
096 x = content.indexOf("insert into Release_");
097 y = content.indexOf(", FALSE);", x);
098 x = content.lastIndexOf(" ", y - 1) + 1;
099
100 content =
101 content.substring(0, x) + build +
102 content.substring(y, content.length());
103
104 _fileUtil.write(file, content);
105 }
106 catch (Exception e) {
107 e.printStackTrace();
108 }
109 }
110
111 private static FileImpl _fileUtil = FileImpl.getInstance();
112
113 }