提交 c23dcee7 authored 作者: Thomas Mueller's avatar Thomas Mueller

automate release process

上级 22f467ed
......@@ -270,6 +270,13 @@ java org.h2.test.TestAll timer
/*
H2 databases need to have a file name prefix.
Probably the database should throw a meaningful exception
if the last element in the URL path is a slash (or backslash).
I will try to implement that for the next release.
Improved compatibility with DB2: support for FETCH .. ROWS
drop table test;
create table test(a int);
insert into test values(1);
......
......@@ -6,8 +6,8 @@
*/
package org.h2.test.jaqu;
//## Java 1.5 begin ##
import java.math.BigDecimal;
//## Java 1.5 begin ##
import java.util.List;
import org.h2.jaqu.Db;
......@@ -179,13 +179,13 @@ public class SamplesTest extends TestBase {
/**
* A result set class containing the product name and price.
*/
//## Java 1.5 begin ##
public static class ProductPrice {
public String productName;
public String category;
public Double price;
}
//## Java 1.5 begin ##
private void testAnonymousTypes3() throws Exception {
// var productInfos =
......@@ -220,13 +220,13 @@ public class SamplesTest extends TestBase {
/**
* A result set class containing customer data and the order total.
*/
//## Java 1.5 begin ##
public static class CustOrder {
public String customerId;
public Integer orderId;
public BigDecimal total;
}
//## Java 1.5 begin ##
private void testSelectManyCompoundFrom2() throws Exception {
// var orders =
......@@ -280,18 +280,17 @@ public class SamplesTest extends TestBase {
long count = db.from(new Product()).selectCount();
assertEquals(77, count);
}
//## Java 1.5 end ##
//## Java 1.5 end ##
/**
* A result set class containing product groups.
*/
//## Java 1.5 begin ##
public static class ProductGroup {
public String category;
public Long productCount;
}
//## Java 1.5 begin ##
private void testGroup() throws Exception {
// var orderGroups =
......
......@@ -242,7 +242,7 @@ public class Build extends BuildBase {
mkdir("docs/javadoc");
javadoc(new String[] { "-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx",
"org.h2.tools", "org.h2.api", "org.h2.constant",
"-doclet", "org.h2.build.doclet.Doclet" });
"-doclet", "org.h2.build.doclet.Doclet"});
copy("docs/javadoc", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc");
}
......@@ -250,8 +250,7 @@ public class Build extends BuildBase {
* Create the Javadocs of the implementation.
*/
public void javadocImpl() {
mkdir("docs/javadocImpl");
mkdir("docs/javadocImpl2");
javadoc(new String[] {
"-sourcepath", "src/main" + File.pathSeparator +
"src/test" + File.pathSeparator + "src/tools" ,
......@@ -263,7 +262,7 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/servlet-api-2.4.jar" +
File.pathSeparator + "ext/lucene-core-2.2.0.jar",
"-subpackages", "org.h2",
"-exclude", "org.h2.build.*,org.h2.dev.*" });
"-exclude", "org.h2.test.jaqu:org.h2.jaqu" });
System.setProperty("h2.interfacesOnly", "false");
System.setProperty("h2.destDir", "docs/javadocImpl");
......@@ -274,6 +273,7 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/servlet-api-2.4.jar" +
File.pathSeparator + "ext/lucene-core-2.2.0.jar",
"-subpackages", "org.h2",
"-exclude", "org.h2.test.jaqu:org.h2.jaqu",
"-package",
"-doclet", "org.h2.build.doclet.Doclet" });
copy("docs/javadocImpl", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc");
......
......@@ -11,6 +11,7 @@ import java.io.BufferedOutputStream;
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.OutputStream;
......@@ -78,6 +79,11 @@ public class BuildBase {
*/
protected PrintStream out = System.out;
/**
* If output should be disabled.
*/
protected boolean quiet;
/**
* This method should be called by the main method.
*
......@@ -90,6 +96,9 @@ public class BuildBase {
} else {
for (int i = 0; i < args.length; i++) {
String a = args[i];
if ("-quiet".equals(a)) {
quiet = true;
} else {
Method m = null;
try {
m = getClass().getMethod(a, new Class[0]);
......@@ -98,11 +107,12 @@ public class BuildBase {
projectHelp();
break;
}
out.println("Target: " + a);
println("Target: " + a);
invoke(m, this, new Object[0]);
}
}
out.println("Done in " + (System.currentTimeMillis() - time) + " ms");
}
println("Done in " + (System.currentTimeMillis() - time) + " ms");
}
private Object invoke(Method m, Object instance, Object[] args) {
......@@ -178,19 +188,19 @@ public class BuildBase {
*/
protected int exec(String command, String[] args) {
try {
out.print(command);
print(command);
for (int i = 0; args != null && i < args.length; i++) {
out.print(" " + args[i]);
print(" " + args[i]);
}
out.println();
println("");
String[] cmdArray = new String[1 + (args == null ? 0 : args.length)];
cmdArray[0] = command;
if (args != null) {
System.arraycopy(args, 0, cmdArray, 1, args.length);
}
Process p = Runtime.getRuntime().exec(cmdArray);
copyInThread(p.getInputStream(), out);
copyInThread(p.getErrorStream(), out);
copyInThread(p.getInputStream(), quiet ? null : out);
copyInThread(p.getErrorStream(), quiet ? null : out);
p.waitFor();
return p.exitValue();
} catch (Exception e) {
......@@ -207,8 +217,10 @@ public class BuildBase {
if (x < 0) {
return;
}
if (out != null) {
out.write(x);
}
}
} catch (Exception e) {
throw new Error("Error: " + e, e);
}
......@@ -260,7 +272,7 @@ public class BuildBase {
protected void copy(String targetDir, List files, String baseDir) {
File target = new File(targetDir);
File base = new File(baseDir);
out.println("Copying " + files.size() + " files to " + target.getPath());
println("Copying " + files.size() + " files to " + target.getPath());
String basePath = base.getPath();
for (int i = 0; i < files.size(); i++) {
File f = (File) files.get(i);
......@@ -271,6 +283,45 @@ public class BuildBase {
}
}
private PrintStream filter(PrintStream out, final String[] exclude) {
return new PrintStream(new FilterOutputStream(out) {
private ByteArrayOutputStream buff = new ByteArrayOutputStream();
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
public void write(byte[] b, int off, int len) throws IOException {
for (int i = off; i < len; i++) {
write(b[i]);
}
}
public void write(byte b) throws IOException {
buff.write(b);
if (b == '\n') {
byte[] data = buff.toByteArray();
String line = new String(data, "UTF-8");
boolean print = true;
for (int i = 0; i < exclude.length; i++) {
if (line.startsWith(exclude[i])) {
print = false;
break;
}
}
if (print) {
out.write(data);
}
buff.reset();
}
}
public void close() throws IOException {
write('\n');
}
});
}
/**
* Run a Javadoc task.
*
......@@ -278,13 +329,25 @@ public class BuildBase {
*/
protected void javadoc(String[] args) {
int result;
PrintStream old = System.out;
try {
out.println("Javadoc");
println("Javadoc");
if (quiet) {
System.setOut(filter(System.out, new String[] {
"Loading source files for package",
"Constructing Javadoc information",
"Generating ",
"Standard Doclet",
"Building "
}));
}
Class clazz = Class.forName("com.sun.tools.javadoc.Main");
Method execute = clazz.getMethod("execute", new Class[] { String[].class });
result = ((Integer) invoke(execute, null, new Object[] { args })).intValue();
} catch (Exception e) {
result = exec("javadoc", args);
} finally {
System.setOut(old);
}
if (result != 0) {
throw new Error("An error occurred");
......@@ -328,7 +391,7 @@ public class BuildBase {
targetFile.getAbsoluteFile().getParentFile().mkdirs();
ByteArrayOutputStream buff = new ByteArrayOutputStream();
try {
out.println("Downloading " + fileURL);
println("Downloading " + fileURL);
URL url = new URL(fileURL);
InputStream in = new BufferedInputStream(url.openStream());
long last = System.currentTimeMillis();
......@@ -336,7 +399,7 @@ public class BuildBase {
while (true) {
long now = System.currentTimeMillis();
if (now > last + 1000) {
out.println("Downloaded " + len + " bytes");
println("Downloaded " + len + " bytes");
last = now;
}
int x = in.read();
......@@ -353,7 +416,7 @@ public class BuildBase {
byte[] data = buff.toByteArray();
String got = getSHA1(data);
if (sha1Checksum == null) {
out.println("SHA1 checksum: " + got);
println("SHA1 checksum: " + got);
} else {
if (!got.equals(sha1Checksum)) {
......@@ -492,7 +555,7 @@ public class BuildBase {
*/
protected void jar(String destFile, List files, String basePath) {
long kb = zipOrJar(destFile, files, basePath, false, false, true);
out.println("Jar " + destFile + " (" + kb + " KB)");
println("Jar " + destFile + " (" + kb + " KB)");
}
/**
......@@ -506,7 +569,7 @@ public class BuildBase {
*/
protected void zip(String destFile, List files, String basePath, boolean storeOnly, boolean sortBySuffix) {
long kb = zipOrJar(destFile, files, basePath, storeOnly, sortBySuffix, false);
out.println("Zip " + destFile + " (" + kb + " KB)");
println("Zip " + destFile + " (" + kb + " KB)");
}
private long zipOrJar(String destFile, List files, String basePath, boolean storeOnly, boolean sortBySuffix, boolean jar) {
......@@ -585,13 +648,19 @@ public class BuildBase {
* @param files the file list
*/
protected void javac(String[] args, FileList files) {
out.println("Compiling " + files.size() + " classes");
println("Compiling " + files.size() + " classes");
ArrayList argList = new ArrayList(Arrays.asList(args));
argList.addAll(getPaths(filterFiles(files, true, ".java")));
args = new String[argList.size()];
argList.toArray(args);
int result;
PrintStream old = System.err;
try {
if (quiet) {
System.setErr(filter(System.err, new String[] {
"Note:"
}));
}
Class clazz = Class.forName("com.sun.tools.javac.Main");
Method compile = clazz.getMethod("compile", new Class[] { String[].class });
Object instance = clazz.newInstance();
......@@ -599,6 +668,8 @@ public class BuildBase {
} catch (Exception e) {
e.printStackTrace();
result = exec("javac", args);
} finally {
System.setErr(old);
}
if (result != 0) {
throw new Error("An error occurred");
......@@ -612,7 +683,7 @@ public class BuildBase {
* @param args the command line parameters to pass
*/
protected void java(String className, String[] args) {
out.println("Running " + className);
println("Running " + className);
if (args == null) {
args = new String[0];
}
......@@ -648,7 +719,7 @@ public class BuildBase {
* @param dir the name of the directory
*/
protected void delete(String dir) {
out.println("Deleting " + dir);
println("Deleting " + dir);
delete(new File(dir));
}
......@@ -686,4 +757,27 @@ public class BuildBase {
index = next + after.length();
}
}
/**
* Print a line to the output unless the quiet mode is enabled.
*
* @param s the text to write
*/
protected void println(String s) {
if (!quiet) {
out.println(s);
}
}
/**
* Print a message to the output unless the quiet mode is enabled.
*
* @param s the message to write
*/
protected void print(String s) {
if (!quiet) {
out.print(s);
}
}
}
......@@ -157,7 +157,7 @@ public class SwitchSource {
File fileCopy = new File(name);
fileNew.renameTo(fileCopy);
fileBack.delete();
System.out.println(name);
// System.out.println(name);
}
}
......
......@@ -551,4 +551,4 @@ geocoder geocoding longitude estimating microarray latitude magnolia pfgrc
refill analyzers patches popular came growing indication arabic graphic toc
numbering goto outline makensis macro hyperlink dispatch setlocal wend
widows msgbox designer styles families uno soffice orphans stan ucb rem
pdfurl upate pagebreak
pdfurl upate pagebreak ren echo
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论