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 = content.substring(0, x) + version + content.substring(y);
059
060
061
062 x = content.indexOf("String _BUILD = \"");
063 x = content.indexOf("\"", x) + 1;
064
065 y = content.indexOf("\"", x);
066
067 int build = GetterUtil.getInteger(content.substring(x, y)) + 1;
068
069 content = content.substring(0, x) + build + content.substring(y);
070
071
072
073 DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
074
075 String date = dateFormat.format(new Date());
076
077 x = content.indexOf("String _DATE = \"");
078 x = content.indexOf("\"", x) + 1;
079
080 y = content.indexOf("\"", x);
081
082 content = content.substring(0, x) + date + content.substring(y);
083
084
085
086 _fileUtil.write(file, content);
087
088
089
090 file = new File("../sql/portal-data-release.sql");
091
092 content = _fileUtil.read(file);
093
094 x = content.indexOf("insert into Release_");
095 y = content.indexOf(", FALSE);", x);
096 x = content.lastIndexOf(" ", y - 1) + 1;
097
098 content = content.substring(0, x) + build + content.substring(y);
099
100 _fileUtil.write(file, content);
101 }
102 catch (Exception e) {
103 e.printStackTrace();
104 }
105 }
106
107 private static FileImpl _fileUtil = FileImpl.getInstance();
108
109 }