提交 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
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论