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 public static void main(String[] args) {
45 InitUtil.initWithSpring();
46
47 new ReleaseInfoBuilder();
48 }
49
50 public ReleaseInfoBuilder() {
51 try {
52
53
55 Properties releaseProps =
56 FileUtil.toProperties("../release.properties");
57
58 String version = releaseProps.getProperty("lp.version");
59
60 File file = new File(
61 "../portal-kernel/src/com/liferay/portal/kernel/util/" +
62 "ReleaseInfo.java");
63
64 String content = FileUtil.read(file);
65
66 int x = content.indexOf("String version = \"");
67 x = content.indexOf("\"", x) + 1;
68 int y = content.indexOf("\"", x);
69
70 content =
71 content.substring(0, x) + version +
72 content.substring(y, content.length());
73
74
76 x = content.indexOf("String build = \"");
77 x = content.indexOf("\"", x) + 1;
78 y = content.indexOf("\"", x);
79
80 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
81
82 content =
83 content.substring(0, x) + build +
84 content.substring(y, content.length());
85
86
88 DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
89
90 String date = df.format(new Date());
91
92 x = content.indexOf("String date = \"");
93 x = content.indexOf("\"", x) + 1;
94 y = content.indexOf("\"", x);
95
96 content =
97 content.substring(0, x) + date +
98 content.substring(y, content.length());
99
100
102 FileUtil.write(file, content);
103
104
106 file = new File("../sql/portal-data-release.sql");
107
108 content = FileUtil.read(file);
109
110 x = content.indexOf("insert into Release_");
111 y = content.indexOf(", FALSE);", x);
112 x = content.lastIndexOf(" ", y - 1) + 1;
113
114 content =
115 content.substring(0, x) + build +
116 content.substring(y, content.length());
117
118 FileUtil.write(file, content);
119 }
120 catch (Exception e) {
121 e.printStackTrace();
122 }
123 }
124
125 }