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