001
014
015 package com.liferay.portal.tools;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.util.FileImpl;
019
020 import java.io.File;
021
022 import java.text.DateFormat;
023
024 import java.util.Date;
025 import java.util.Properties;
026
027
030 public class ReleaseInfoBuilder {
031
032 public static void main(String[] args) {
033 new ReleaseInfoBuilder();
034 }
035
036 public ReleaseInfoBuilder() {
037 try {
038
039
040
041 Properties releaseProps = _fileUtil.toProperties(
042 "../release.properties");
043
044 String version = releaseProps.getProperty("lp.version");
045
046 File file = new File(
047 "../portal-service/src/com/liferay/portal/kernel/util/" +
048 "ReleaseInfo.java");
049
050 String content = _fileUtil.read(file);
051
052 int x = content.indexOf("String _VERSION = \"");
053
054 x = content.indexOf("\"", x) + 1;
055
056 int y = content.indexOf("\"", x);
057
058 content =
059 content.substring(0, x) + version +
060 content.substring(y, content.length());
061
062
063
064 x = content.indexOf("String _BUILD = \"");
065 x = content.indexOf("\"", x) + 1;
066
067 y = content.indexOf("\"", x);
068
069 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
070
071 content =
072 content.substring(0, x) + build +
073 content.substring(y, content.length());
074
075
076
077 DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
078
079 String date = dateFormat.format(new Date());
080
081 x = content.indexOf("String _DATE = \"");
082 x = content.indexOf("\"", x) + 1;
083
084 y = content.indexOf("\"", x);
085
086 content =
087 content.substring(0, x) + date +
088 content.substring(y, content.length());
089
090
091
092 _fileUtil.write(file, content);
093
094
095
096 file = new File("../sql/portal-data-release.sql");
097
098 content = _fileUtil.read(file);
099
100 x = content.indexOf("insert into Release_");
101 y = content.indexOf(", FALSE);", x);
102 x = content.lastIndexOf(" ", y - 1) + 1;
103
104 content =
105 content.substring(0, x) + build +
106 content.substring(y, content.length());
107
108 _fileUtil.write(file, content);
109 }
110 catch (Exception e) {
111 e.printStackTrace();
112 }
113 }
114
115 private static FileImpl _fileUtil = FileImpl.getInstance();
116
117 }