提交 0a3590f0 authored 作者: Thomas Mueller's avatar Thomas Mueller

Require Java 1.5 compiler

上级 a8fec820
...@@ -16,9 +16,10 @@ PATH=$JAVA16/bin:$PATH ...@@ -16,9 +16,10 @@ PATH=$JAVA16/bin:$PATH
./build.sh -quiet spellcheck javadocImpl jarClient ./build.sh -quiet spellcheck javadocImpl jarClient
echo $(date "+%H:%M:%S") JDK 1.4 echo $(date "+%H:%M:%S") JDK 1.4
JAVA_HOME=$JAVA14 export BCP=/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes
PATH=$JAVA14/bin:$PATH JAVA_HOME=$JAVA15
./build.sh -quiet clean compile PATH=$JAVA15/bin:$PATH
./build.sh -quiet clean -Dversion=1.4 switchSource -Dbcp=$BCP/classes.jar:$BCP/jsse.jar compile
./build.sh -quiet installer mavenDeployCentral ./build.sh -quiet installer mavenDeployCentral
# ./build.sh -quiet compile benchmark # ./build.sh -quiet compile benchmark
......
...@@ -61,14 +61,15 @@ public class Build extends BuildBase { ...@@ -61,14 +61,15 @@ public class Build extends BuildBase {
"ext/derbynet-10.4.2.0.jar" + File.pathSeparator + "ext/derbynet-10.4.2.0.jar" + File.pathSeparator +
"ext/postgresql-8.3-603.jdbc3.jar" + File.pathSeparator + "ext/postgresql-8.3-603.jdbc3.jar" + File.pathSeparator +
"ext/mysql-connector-java-5.1.6.jar"; "ext/mysql-connector-java-5.1.6.jar";
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-init", "-db", "1"}); StringList args = new StringList(new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance"});
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "2"}); exec("java", args.plus(new String[]{"-init", "-db", "1"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "3", "-out", "pe.html"}); exec("java", args.plus(new String[]{"-db", "2"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-init", "-db", "4"}); exec("java", args.plus(new String[]{"-db", "3", "-out", "pe.html"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "5", "-exit"}); exec("java", args.plus(new String[]{"-init", "-db", "4"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "6"}); exec("java", args.plus(new String[]{"-db", "5", "-exit"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "7"}); exec("java", args.plus(new String[]{"-db", "6"}));
exec("java", new String[]{"-Xmx128m", "-cp", cp, "org.h2.test.bench.TestPerformance", "-db", "8", "-out", "ps.html"}); exec("java", args.plus(new String[]{"-db", "7"}));
exec("java", args.plus(new String[]{"-db", "8", "-out", "ps.html"}));
} }
/** /**
...@@ -103,12 +104,12 @@ public class Build extends BuildBase { ...@@ -103,12 +104,12 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/lucene-core-2.2.0.jar" + File.pathSeparator + "ext/lucene-core-2.2.0.jar" +
File.pathSeparator + "ext/org.osgi.core-1.2.0.jar" + File.pathSeparator + "ext/org.osgi.core-1.2.0.jar" +
File.pathSeparator + "ext/slf4j-api-1.5.0.jar"; File.pathSeparator + "ext/slf4j-api-1.5.0.jar";
exec("java", new String[] { "-Xmx128m", "-cp", cp, "emma", "run", exec("java", new StringList(new String[] { "-Xmx128m", "-cp", cp, "emma", "run",
"-cp", "temp", "-cp", "temp",
"-sp", "src/main", "-sp", "src/main",
"-r", "html,txt", "-r", "html,txt",
"-ix", "-org.h2.test.*,-org.h2.dev.*,-org.h2.jaqu.*,-org.h2.index.Page*,-org.h2.mode.*", "-ix", "-org.h2.test.*,-org.h2.dev.*,-org.h2.jaqu.*,-org.h2.index.Page*,-org.h2.mode.*",
"org.h2.test.TestAll" }); "org.h2.test.TestAll" }));
} }
/** /**
...@@ -116,7 +117,12 @@ public class Build extends BuildBase { ...@@ -116,7 +117,12 @@ public class Build extends BuildBase {
*/ */
public void switchSource() { public void switchSource() {
try { try {
String version = System.getProperty("version");
if (version == null) {
SwitchSource.main(new String[] { "-dir", "src", "-auto" }); SwitchSource.main(new String[] { "-dir", "src", "-auto" });
} else {
SwitchSource.main(new String[] { "-dir", "src", "-version", version });
}
} catch (IOException e) { } catch (IOException e) {
throw new Error(e); throw new Error(e);
} }
...@@ -141,11 +147,18 @@ public class Build extends BuildBase { ...@@ -141,11 +147,18 @@ public class Build extends BuildBase {
} else { } else {
files = getFiles("src/main"); files = getFiles("src/main");
} }
StringList args = new StringList();
if (System.getProperty("version") != null) {
String bcp = System.getProperty("bcp");
// /System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes/classes.jar
args = args.plus(new String[] { "-source", "1.5", "-target", "jsr14", "-bootclasspath", bcp});
}
if (debugInfo) { if (debugInfo) {
javac(new String[] { "-d", "temp", "-sourcepath", "src/main", "-classpath", classpath }, files); args = args.plus(new String[] { "-d", "temp", "-sourcepath", "src/main", "-classpath", classpath});
} else { } else {
javac(new String[] { "-g:none", "-d", "temp", "-sourcepath", "src/main", "-classpath", classpath }, files); args = args.plus(new String[] { "-g:none", "-d", "temp", "-sourcepath", "src/main", "-classpath", classpath });
} }
javac(args, files);
files = getFiles("src/main/META-INF/services"); files = getFiles("src/main/META-INF/services");
copy("temp", files, "src/main"); copy("temp", files, "src/main");
...@@ -153,8 +166,9 @@ public class Build extends BuildBase { ...@@ -153,8 +166,9 @@ public class Build extends BuildBase {
if (!clientOnly) { if (!clientOnly) {
files = getFiles("src/test"); files = getFiles("src/test");
files.addAll(getFiles("src/tools")); files.addAll(getFiles("src/tools"));
javac(new String[] { "-d", "temp", "-sourcepath", "src/test" + File.pathSeparator + "src/tools", args = new StringList(new String[] { "-d", "temp", "-sourcepath", "src/test" + File.pathSeparator + "src/tools",
"-classpath", classpath }, files); "-classpath", classpath });
javac(args, files);
files = getFiles("src/test"). files = getFiles("src/test").
exclude("*.java"). exclude("*.java").
exclude("*/package.html"); exclude("*/package.html");
...@@ -229,7 +243,7 @@ public class Build extends BuildBase { ...@@ -229,7 +243,7 @@ public class Build extends BuildBase {
delete(getFiles("bin").keep("*.jar")); delete(getFiles("bin").keep("*.jar"));
jar(); jar();
docs(); docs();
exec("soffice", new String[]{"-invisible", "macro:///Standard.Module1.H2Pdf"}); exec("soffice", new StringList(new String[]{"-invisible", "macro:///Standard.Module1.H2Pdf"}));
copy("docs", getFiles("../h2web/h2.pdf"), "../h2web"); copy("docs", getFiles("../h2web/h2.pdf"), "../h2web");
delete("docs/html/onePage.html"); delete("docs/html/onePage.html");
FileList files = getFiles("../h2").keep("../h2/build.*"); FileList files = getFiles("../h2").keep("../h2/build.*");
...@@ -240,7 +254,7 @@ public class Build extends BuildBase { ...@@ -240,7 +254,7 @@ public class Build extends BuildBase {
zip("../h2web/h2.zip", files, "../", false, false); zip("../h2web/h2.zip", files, "../", false, false);
boolean installer = false; boolean installer = false;
try { try {
exec("makensis", new String[]{"/v2", "src/installer/h2.nsi"}); exec("makensis", new StringList(new String[]{"/v2", "src/installer/h2.nsi"}));
installer = true; installer = true;
} catch (Error e) { } catch (Error e) {
print("NSIS is not available: " + e); print("NSIS is not available: " + e);
...@@ -339,11 +353,11 @@ public class Build extends BuildBase { ...@@ -339,11 +353,11 @@ public class Build extends BuildBase {
public void javadoc() { public void javadoc() {
delete("docs"); delete("docs");
mkdir("docs/javadoc"); mkdir("docs/javadoc");
javadoc(new String[] { "-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx", javadoc(new StringList(new String[] { "-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx",
"org.h2.tools", "org.h2.api", "org.h2.constant", "org.h2.fulltext", "org.h2.tools", "org.h2.api", "org.h2.constant", "org.h2.fulltext",
"-doclet", "org.h2.build.doclet.Doclet", "-doclet", "org.h2.build.doclet.Doclet",
"-classpath", "-classpath",
"ext/lucene-core-2.2.0.jar"}); "ext/lucene-core-2.2.0.jar"}));
copy("docs/javadoc", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc"); copy("docs/javadoc", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc");
} }
...@@ -352,7 +366,7 @@ public class Build extends BuildBase { ...@@ -352,7 +366,7 @@ public class Build extends BuildBase {
*/ */
public void javadocImpl() { public void javadocImpl() {
mkdir("docs/javadocImpl2"); mkdir("docs/javadocImpl2");
javadoc(new String[] { javadoc(new StringList(new String[] {
"-sourcepath", "src/main" + File.pathSeparator + "-sourcepath", "src/main" + File.pathSeparator +
"src/test" + File.pathSeparator + "src/tools" , "src/test" + File.pathSeparator + "src/tools" ,
"-noindex", "-noindex",
...@@ -365,11 +379,11 @@ public class Build extends BuildBase { ...@@ -365,11 +379,11 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/lucene-core-2.2.0.jar" + File.pathSeparator + "ext/lucene-core-2.2.0.jar" +
File.pathSeparator + "ext/org.osgi.core-1.2.0.jar", File.pathSeparator + "ext/org.osgi.core-1.2.0.jar",
"-subpackages", "org.h2", "-subpackages", "org.h2",
"-exclude", "org.h2.test.jaqu:org.h2.jaqu" }); "-exclude", "org.h2.test.jaqu:org.h2.jaqu" }));
System.setProperty("h2.interfacesOnly", "false"); System.setProperty("h2.interfacesOnly", "false");
System.setProperty("h2.destDir", "docs/javadocImpl"); System.setProperty("h2.destDir", "docs/javadocImpl");
javadoc(new String[] { javadoc(new StringList(new String[] {
"-sourcepath", "src/main" + File.pathSeparator + "src/test" + File.pathSeparator + "src/tools", "-sourcepath", "src/main" + File.pathSeparator + "src/test" + File.pathSeparator + "src/tools",
"-classpath", System.getProperty("java.home") + "/../lib/tools.jar" + "-classpath", System.getProperty("java.home") + "/../lib/tools.jar" +
File.pathSeparator + "ext/slf4j-api-1.5.0.jar" + File.pathSeparator + "ext/slf4j-api-1.5.0.jar" +
...@@ -379,7 +393,7 @@ public class Build extends BuildBase { ...@@ -379,7 +393,7 @@ public class Build extends BuildBase {
"-subpackages", "org.h2", "-subpackages", "org.h2",
"-exclude", "org.h2.test.jaqu:org.h2.jaqu", "-exclude", "org.h2.test.jaqu:org.h2.jaqu",
"-package", "-package",
"-doclet", "org.h2.build.doclet.Doclet" }); "-doclet", "org.h2.build.doclet.Doclet" }));
copy("docs/javadocImpl", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc"); copy("docs/javadocImpl", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc");
} }
...@@ -406,7 +420,7 @@ public class Build extends BuildBase { ...@@ -406,7 +420,7 @@ public class Build extends BuildBase {
String pom = new String(readFile(new File("src/installer/pom.xml"))); String pom = new String(readFile(new File("src/installer/pom.xml")));
pom = replaceAll(pom, "@version@", getVersion()); pom = replaceAll(pom, "@version@", getVersion());
writeFile(new File("bin/pom.xml"), pom.getBytes()); writeFile(new File("bin/pom.xml"), pom.getBytes());
execScript("mvn", new String[] { execScript("mvn", new StringList(new String[] {
"deploy:deploy-file", "deploy:deploy-file",
"-Dfile=bin/h2" + getJarSuffix(), "-Dfile=bin/h2" + getJarSuffix(),
"-Durl=file:///data/h2database/m2-repo", "-Durl=file:///data/h2database/m2-repo",
...@@ -414,7 +428,7 @@ public class Build extends BuildBase { ...@@ -414,7 +428,7 @@ public class Build extends BuildBase {
"-Dversion=" + getVersion(), "-Dversion=" + getVersion(),
"-DpomFile=bin/pom.xml", "-DpomFile=bin/pom.xml",
"-DartifactId=h2", "-DartifactId=h2",
"-DgroupId=com.h2database" }); "-DgroupId=com.h2database" }));
} }
/** /**
...@@ -426,20 +440,20 @@ public class Build extends BuildBase { ...@@ -426,20 +440,20 @@ public class Build extends BuildBase {
String pom = new String(readFile(new File("src/installer/pom.xml"))); String pom = new String(readFile(new File("src/installer/pom.xml")));
pom = replaceAll(pom, "@version@", "1.0-SNAPSHOT"); pom = replaceAll(pom, "@version@", "1.0-SNAPSHOT");
writeFile(new File("bin/pom.xml"), pom.getBytes()); writeFile(new File("bin/pom.xml"), pom.getBytes());
execScript("mvn", new String[] { execScript("mvn", new StringList(new String[] {
"install:install-file", "install:install-file",
"-Dversion=1.0-SNAPSHOT", "-Dversion=1.0-SNAPSHOT",
"-Dfile=bin/h2" + getJarSuffix(), "-Dfile=bin/h2" + getJarSuffix(),
"-Dpackaging=jar", "-Dpackaging=jar",
"-DpomFile=bin/pom.xml", "-DpomFile=bin/pom.xml",
"-DartifactId=h2", "-DartifactId=h2",
"-DgroupId=com.h2database" }); "-DgroupId=com.h2database" }));
} }
private void resources(boolean clientOnly, boolean basicOnly) { private void resources(boolean clientOnly, boolean basicOnly) {
if (!clientOnly) { if (!clientOnly) {
javadoc(new String[] { "-sourcepath", "src/main", "org.h2.tools", javadoc(new StringList(new String[] { "-sourcepath", "src/main", "org.h2.tools",
"-doclet", "org.h2.build.doclet.ResourceDoclet"}); "-doclet", "org.h2.build.doclet.ResourceDoclet"}));
} }
FileList files = getFiles("src/main"). FileList files = getFiles("src/main").
exclude("*.MF"). exclude("*.MF").
...@@ -555,9 +569,9 @@ public class Build extends BuildBase { ...@@ -555,9 +569,9 @@ public class Build extends BuildBase {
throw new Error("h2.ftpPassword not set"); throw new Error("h2.ftpPassword not set");
} }
String cp = "bin" + File.pathSeparator + "temp"; String cp = "bin" + File.pathSeparator + "temp";
exec("java", new String[] { "-Xmx128m", "-cp", cp, exec("java", new StringList(new String[] { "-Xmx128m", "-cp", cp,
"-Dh2.ftpPassword=" + password, "-Dh2.ftpPassword=" + password,
"org.h2.build.doc.UploadBuild" }); "org.h2.build.doc.UploadBuild" }));
} }
/** /**
......
...@@ -43,12 +43,69 @@ import java.util.zip.ZipOutputStream; ...@@ -43,12 +43,69 @@ import java.util.zip.ZipOutputStream;
*/ */
public class BuildBase { public class BuildBase {
/**
* A list of strings.
*/
public static class StringList extends ArrayList implements List {
private static final long serialVersionUID = 1L;
StringList() {
super();
}
StringList(String[] args) {
super();
addAll(Arrays.asList(args));
}
/**
* Add a list of strings.
*
* @param args the list to add
* @return the new list
*/
public StringList plus(String[] args) {
StringList newList = new StringList();
newList.addAll(this);
newList.addAll(Arrays.asList(args));
return newList;
}
/**
* Add a string.
*
* @param s the string to add
* @return the new list
*/
public StringList plus(String s) {
StringList newList = new StringList();
newList.addAll(this);
newList.add(s);
return newList;
}
/**
* Convert this list to a string array.
*
* @return the string array
*/
public String[] toArray() {
String[] list = new String[size()];
for (int i = 0; i < size(); i++) {
list[i] = (String) get(i);
}
return list;
}
}
/** /**
* A list of files. * A list of files.
*/ */
public static class FileList extends ArrayList implements List { public static class FileList extends ArrayList implements List {
private static final long serialVersionUID = -3241001695597802578L; private static final long serialVersionUID = 1L;
/** /**
* Remove the files that match from the list. * Remove the files that match from the list.
...@@ -190,7 +247,7 @@ public class BuildBase { ...@@ -190,7 +247,7 @@ public class BuildBase {
* @param args the command line parameters * @param args the command line parameters
* @return the exit value * @return the exit value
*/ */
protected int execScript(String script, String[] args) { protected int execScript(String script, StringList args) {
if (isWindows()) { if (isWindows()) {
script = script + ".bat"; script = script + ".bat";
} }
...@@ -204,19 +261,19 @@ public class BuildBase { ...@@ -204,19 +261,19 @@ public class BuildBase {
* @param args the command line parameters * @param args the command line parameters
* @return the exit value * @return the exit value
*/ */
protected int exec(String command, String[] args) { protected int exec(String command, StringList args) {
try { try {
print(command); print(command);
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.size(); i++) {
print(" " + args[i]); print(" " + args.get(i));
} }
println(""); StringList cmd = new StringList();
String[] cmdArray = new String[1 + (args == null ? 0 : args.length)]; cmd = cmd.plus(command);
cmdArray[0] = command;
if (args != null) { if (args != null) {
System.arraycopy(args, 0, cmdArray, 1, args.length); cmd.addAll(args);
} }
Process p = Runtime.getRuntime().exec(cmdArray); println("");
Process p = Runtime.getRuntime().exec(cmd.toArray());
copyInThread(p.getInputStream(), quiet ? null : out); copyInThread(p.getInputStream(), quiet ? null : out);
copyInThread(p.getErrorStream(), quiet ? null : out); copyInThread(p.getErrorStream(), quiet ? null : out);
p.waitFor(); p.waitFor();
...@@ -345,7 +402,7 @@ public class BuildBase { ...@@ -345,7 +402,7 @@ public class BuildBase {
* *
* @param args the command line arguments to pass * @param args the command line arguments to pass
*/ */
protected void javadoc(String[] args) { protected void javadoc(StringList args) {
int result; int result;
PrintStream old = System.out; PrintStream old = System.out;
try { try {
...@@ -361,7 +418,8 @@ public class BuildBase { ...@@ -361,7 +418,8 @@ public class BuildBase {
} }
Class clazz = Class.forName("com.sun.tools.javadoc.Main"); Class clazz = Class.forName("com.sun.tools.javadoc.Main");
Method execute = clazz.getMethod("execute", new Class[] { String[].class }); Method execute = clazz.getMethod("execute", new Class[] { String[].class });
result = ((Integer) invoke(execute, null, new Object[] { args })).intValue(); String[] array = args.toArray();
result = ((Integer) invoke(execute, null, new Object[] { array })).intValue();
} catch (Exception e) { } catch (Exception e) {
result = exec("javadoc", args); result = exec("javadoc", args);
} finally { } finally {
...@@ -667,12 +725,12 @@ public class BuildBase { ...@@ -667,12 +725,12 @@ public class BuildBase {
* @param args the command line parameters * @param args the command line parameters
* @param files the file list * @param files the file list
*/ */
protected void javac(String[] args, FileList files) { protected void javac(StringList args, FileList files) {
println("Compiling " + files.size() + " classes"); println("Compiling " + files.size() + " classes");
ArrayList argList = new ArrayList(Arrays.asList(args)); StringList params = new StringList();
argList.addAll(getPaths(filterFiles(files, true, ".java"))); params.addAll(args);
args = new String[argList.size()]; params.addAll(getPaths(filterFiles(files, true, ".java")));
argList.toArray(args); String[] array = params.toArray();
int result; int result;
PrintStream old = System.err; PrintStream old = System.err;
try { try {
...@@ -684,7 +742,7 @@ public class BuildBase { ...@@ -684,7 +742,7 @@ public class BuildBase {
Class clazz = Class.forName("com.sun.tools.javac.Main"); Class clazz = Class.forName("com.sun.tools.javac.Main");
Method compile = clazz.getMethod("compile", new Class[] { String[].class }); Method compile = clazz.getMethod("compile", new Class[] { String[].class });
Object instance = clazz.newInstance(); Object instance = clazz.newInstance();
result = ((Integer) invoke(compile, instance, new Object[] { args })).intValue(); result = ((Integer) invoke(compile, instance, new Object[] { array })).intValue();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
result = exec("javac", args); result = exec("javac", args);
...@@ -702,14 +760,12 @@ public class BuildBase { ...@@ -702,14 +760,12 @@ public class BuildBase {
* @param className the class name * @param className the class name
* @param args the command line parameters to pass * @param args the command line parameters to pass
*/ */
protected void java(String className, String[] args) { protected void java(String className, StringList args) {
println("Running " + className); println("Running " + className);
if (args == null) { String[] array = args == null ? new String[0] : args.toArray();
args = new String[0];
}
try { try {
Method main = Class.forName(className).getMethod("main", new Class[] { String[].class }); Method main = Class.forName(className).getMethod("main", new Class[] { String[].class });
invoke(main, null, new Object[] { args }); invoke(main, null, new Object[] { array });
} catch (Exception e) { } catch (Exception e) {
throw new Error(e); throw new Error(e);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论