提交 0655d670 authored 作者: Thomas Mueller's avatar Thomas Mueller

The build tool now supports (minimalistic) shell mode, started using ./build.sh -

上级 15efc627
......@@ -88,10 +88,13 @@ You will get a list of targets. If you want to build the <code>jar</code> file,
<pre>
build jar
</pre>
<p>
To run the build tool in shell mode, use the command line option <code>-</code> as in <code>./build.sh -</code>.
</p>
<h3>Switching the Source Code</h3>
<p>
By default the source code uses Java 1.5 features, however Java 1.6 is supported as well.
By default the source code uses Java 1.6 features, however Java 1.5 is supported as well.
To switch the source code to the installed version of Java, run:
</p>
<pre>
......
......@@ -8,12 +8,14 @@ package org.h2.build;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
......@@ -169,6 +171,9 @@ public class BuildBase {
for (String a : args) {
if ("-quiet".equals(a)) {
quiet = true;
} else if (a.startsWith("-")) {
runShell();
return;
} else if (a.startsWith("-D")) {
String value;
String key = a.substring(2);
......@@ -181,20 +186,54 @@ public class BuildBase {
}
System.setProperty(key, value);
} else {
if (!runTarget(a)) {
break;
}
}
}
}
println("Done in " + (System.currentTimeMillis() - time) + " ms");
}
private boolean runTarget(String target) {
Method m = null;
try {
m = getClass().getMethod(a);
m = getClass().getMethod(target);
} catch (Exception e) {
sysOut.println("Unknown target: " + a);
sysOut.println("Unknown target: " + target);
projectHelp();
break;
return false;
}
println("Target: " + a);
println("Target: " + target);
invoke(m, this, new Object[0]);
return true;
}
private void runShell() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String last = "", line;
System.out.println("Shell mode. Type the target, then [Enter]. Just [Enter] repeats the last target.");
while (true) {
System.out.print("build> ");
try {
line = reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
if (line.length() == 0) {
line = last;
} else if (line.equals("exit") || line.equals("quit")) {
break;
}
long time = System.currentTimeMillis();
try {
runTarget(line);
} catch (Exception e) {
System.out.println(e);
}
println("Done in " + (System.currentTimeMillis() - time) + " ms");
last = line;
}
}
private Object invoke(Method m, Object instance, Object[] args) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论