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