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
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 "../portal-kernel/src/com/liferay/portal/kernel/util/" +
59 "ReleaseInfo.java");
60
61 String content = _fileUtil.read(file);
62
63 int x = content.indexOf("String version = \"");
64 x = content.indexOf("\"", x) + 1;
65 int y = content.indexOf("\"", x);
66
67 content =
68 content.substring(0, x) + version +
69 content.substring(y, content.length());
70
71
73 x = content.indexOf("String build = \"");
74 x = content.indexOf("\"", x) + 1;
75 y = content.indexOf("\"", x);
76
77 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
78
79 content =
80 content.substring(0, x) + build +
81 content.substring(y, content.length());
82
83
85 DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
86
87 String date = df.format(new Date());
88
89 x = content.indexOf("String date = \"");
90 x = content.indexOf("\"", x) + 1;
91 y = content.indexOf("\"", x);
92
93 content =
94 content.substring(0, x) + date +
95 content.substring(y, content.length());
96
97
99 _fileUtil.write(file, content);
100
101
103 file = new File("../sql/portal-data-release.sql");
104
105 content = _fileUtil.read(file);
106
107 x = content.indexOf("insert into Release_");
108 y = content.indexOf(", FALSE);", x);
109 x = content.lastIndexOf(" ", y - 1) + 1;
110
111 content =
112 content.substring(0, x) + build +
113 content.substring(y, content.length());
114
115 _fileUtil.write(file, content);
116 }
117 catch (Exception e) {
118 e.printStackTrace();
119 }
120 }
121
122 private static FileImpl _fileUtil = FileImpl.getInstance();
123
124 }