1
22
23 package com.liferay.portal.tools;
24
25 import com.liferay.portal.kernel.util.FileUtil;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.util.InitUtil;
28
29 import java.io.File;
30
31 import java.text.DateFormat;
32
33 import java.util.Date;
34 import java.util.Properties;
35
36
42 public class ReleaseInfoBuilder {
43
44 static {
45 InitUtil.init();
46 }
47
48 public static void main(String[] args) {
49 new ReleaseInfoBuilder();
50 }
51
52 public ReleaseInfoBuilder() {
53 try {
54
55
57 Properties releaseProps =
58 FileUtil.toProperties("../release.properties");
59
60 String version = releaseProps.getProperty("lp.version");
61
62 File file = new File(
63 "../portal-kernel/src/com/liferay/portal/kernel/util/" +
64 "ReleaseInfo.java");
65
66 String content = FileUtil.read(file);
67
68 int x = content.indexOf("String version = \"");
69 x = content.indexOf("\"", x) + 1;
70 int y = content.indexOf("\"", x);
71
72 content =
73 content.substring(0, x) + version +
74 content.substring(y, content.length());
75
76
78 x = content.indexOf("String build = \"");
79 x = content.indexOf("\"", x) + 1;
80 y = content.indexOf("\"", x);
81
82 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
83
84 content =
85 content.substring(0, x) + build +
86 content.substring(y, content.length());
87
88
90 DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
91
92 String date = df.format(new Date());
93
94 x = content.indexOf("String date = \"");
95 x = content.indexOf("\"", x) + 1;
96 y = content.indexOf("\"", x);
97
98 content =
99 content.substring(0, x) + date +
100 content.substring(y, content.length());
101
102
104 FileUtil.write(file, content);
105
106
108 file = new File("../sql/portal-data-release.sql");
109
110 content = FileUtil.read(file);
111
112 x = content.indexOf("insert into Release_");
113 y = content.indexOf(", FALSE);", x);
114 x = content.lastIndexOf(" ", y - 1) + 1;
115
116 content =
117 content.substring(0, x) + build +
118 content.substring(y, content.length());
119
120 FileUtil.write(file, content);
121 }
122 catch (Exception e) {
123 e.printStackTrace();
124 }
125 }
126
127 }