1
22
23 package com.liferay.portal.tools;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.util.FileImpl;
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
40 public class ReleaseInfoBuilder {
41
42 public static void main(String[] args) {
43 new ReleaseInfoBuilder();
44 }
45
46 public ReleaseInfoBuilder() {
47 try {
48
49
51 Properties releaseProps =
52 _fileUtil.toProperties("../release.properties");
53
54 String version = releaseProps.getProperty("lp.version");
55
56 File file = new File(
57 "../portal-kernel/src/com/liferay/portal/kernel/util/" +
58 "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 private static FileImpl _fileUtil = FileImpl.getInstance();
122
123 }