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