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

allow compiling 1.0 and 1.1

上级 d8542d7b
...@@ -18,17 +18,17 @@ Change Log ...@@ -18,17 +18,17 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Linked tables that point to the same database now share the connection <ul><li>Linked tables that point to the same database can now share the connection
within the same database. Access to the same connection is serialized. within the same database. Access to the same connection is serialized. To enable this feature,
set the system property h2.shareLinkedConnections to true.
</li><li>Multiple processes can now access the same database without having to explicitly </li><li>Multiple processes can now access the same database without having to explicitly
start the server. To do that, append ;AUTO_SERVER=TRUE to the database URL. start the server. To do that, append ;AUTO_SERVER=TRUE to the database URL.
In this case, the server is started automatically if the connection is in embedded mode, In this case, the server is started automatically if the connection is in embedded mode,
and the server mode is used if a server is running. If the process that opened the first and the server mode is used if a server is running. If the process that opened the first
connection is closed, the other client need to reconnect (there is no automatic re-connect so far). connection is closed, the other client need to reconnect (there is no automatic re-connect so far).
Remote connections are allowed, but only to this database.
</li><li>The server tool now displays the correct IP address if networked. </li><li>The server tool now displays the correct IP address if networked.
</li><li>Can now start a TCP server with port 0 (automatically select a port). </li><li>Can now start a TCP server with port 0 (automatically select a port).
</li><li>LOB files are now stored in sub-directories by default for new databases.
Existing databases with LOB files will work as before.
</li><li>Result sets with just a unique index can now be updated (previously a primary key was required). </li><li>Result sets with just a unique index can now be updated (previously a primary key was required).
</li><li>LINKED TABLE: the schema name can now be set. When multiple tables exist in different schema, </li><li>LINKED TABLE: the schema name can now be set. When multiple tables exist in different schema,
and the schema name is not set, an exception is thrown. and the schema name is not set, an exception is thrown.
...@@ -40,7 +40,6 @@ Change Log ...@@ -40,7 +40,6 @@ Change Log
</li><li>Multiple UNION queries could not be used in derived tables. </li><li>Multiple UNION queries could not be used in derived tables.
</li><li>Linked tables can now be read-only. </li><li>Linked tables can now be read-only.
</li><li>Temporary linked tables are now supported. </li><li>Temporary linked tables are now supported.
</li><li>The optimization for IN(...) is now enabled by default. Use -Dh2.optimizeInJoin=false to disable it.
</li><li>It was possible to create tables in read-only databases. </li><li>It was possible to create tables in read-only databases.
</li><li>SET SCHEMA_SEARCH_PATH is now documented. </li><li>SET SCHEMA_SEARCH_PATH is now documented.
</li><li>SET SCHEMA did not work for views. </li><li>SET SCHEMA did not work for views.
......
...@@ -23,7 +23,7 @@ Of course, patches are always welcome, but are not always applied as is. Patches ...@@ -23,7 +23,7 @@ Of course, patches are always welcome, but are not always applied as is. Patches
<h2>In Version 1.1</h2> <h2>In Version 1.1</h2>
<ul> <ul>
<li>Add version number. Install directory: h2-1.0, jar file: h2-1.0.jar. Micro version: use build number, staring with 1.1.100 <li>Add version number. Install directory: h2-1.1, jar file: h2-1.1.100.jar. Micro version: use build number, staring with 1.1.100
</li><li>Automatic upgrade if there is a file format change </li><li>Automatic upgrade if there is a file format change
</li><li>Change Constants.DEFAULT_MAX_MEMORY_UNDO to 10000 (and change the docs). Test. </li><li>Change Constants.DEFAULT_MAX_MEMORY_UNDO to 10000 (and change the docs). Test.
</li><li>Enable and document optimizations, LOB files in directories </li><li>Enable and document optimizations, LOB files in directories
......
...@@ -75,10 +75,11 @@ public class SysProperties { ...@@ -75,10 +75,11 @@ public class SysProperties {
* System property <code>h2.aliasColumnName</code> (default: false).<br /> * System property <code>h2.aliasColumnName</code> (default: false).<br />
* When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the * When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the
* real table and column name in ResultSetMetaData.getTableName() and * real table and column name in ResultSetMetaData.getTableName() and
* getColumnName(). This is disabled by default for compatibility with other * getColumnName().
* <p>
* This feature is disabled by default for compatibility with other
* databases (HSQLDB, Apache Derby, PostgreSQL, some version of MySQL). * databases (HSQLDB, Apache Derby, PostgreSQL, some version of MySQL).
*/ */
// TODO change in version 1.1
public static final boolean ALIAS_COLUMN_NAME = getBooleanSetting("h2.aliasColumnName", false); public static final boolean ALIAS_COLUMN_NAME = getBooleanSetting("h2.aliasColumnName", false);
/** /**
...@@ -97,7 +98,8 @@ public class SysProperties { ...@@ -97,7 +98,8 @@ public class SysProperties {
/** /**
* System property <code>h2.enableAnonymousSSL</code> (default: true).<br /> * System property <code>h2.enableAnonymousSSL</code> (default: true).<br />
* Comma separated list of class names or prefixes. * When using SSL connection, the anonymous cipher suite
* SSL_DH_anon_WITH_RC4_128_MD5 should be enabled.
*/ */
public static final boolean ENABLE_ANONYMOUS_SSL = getBooleanSetting("h2.enableAnonymousSSL", true); public static final boolean ENABLE_ANONYMOUS_SSL = getBooleanSetting("h2.enableAnonymousSSL", true);
...@@ -223,12 +225,16 @@ public class SysProperties { ...@@ -223,12 +225,16 @@ public class SysProperties {
public static boolean lobCloseBetweenReads = getBooleanSetting("h2.lobCloseBetweenReads", false); public static boolean lobCloseBetweenReads = getBooleanSetting("h2.lobCloseBetweenReads", false);
/** /**
* System property <code>h2.lobFilesInDirectories</code> (default: false).<br /> * System property <code>h2.lobFilesInDirectories</code>.<br />
* Store LOB files in subdirectories. * Store LOB files in subdirectories.
* <p>
* In version 1.0, it is disabled by default.
* <p>
* In version 1.1, it is enabled by default.
*/ */
// TODO: when removing this property, also remove // TODO: when removing this property, also remove
// DataHandler.allocateObjectId, createTempFile it // DataHandler.allocateObjectId, createTempFile it
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", true); public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", Constants.VERSION > 1.0);
/** /**
* System property <code>h2.lobFilesPerDirectory</code> (default: 256).<br /> * System property <code>h2.lobFilesPerDirectory</code> (default: 256).<br />
...@@ -310,11 +316,14 @@ public class SysProperties { ...@@ -310,11 +316,14 @@ public class SysProperties {
public static final int OBJECT_CACHE_SIZE = MathUtils.nextPowerOf2(getIntSetting("h2.objectCacheSize", 1024)); public static final int OBJECT_CACHE_SIZE = MathUtils.nextPowerOf2(getIntSetting("h2.objectCacheSize", 1024));
/** /**
* System property <code>h2.oldCommandLineOptions</code> (default: true).<br /> * System property <code>h2.oldCommandLineOptions</code>.<br />
* Support old command line options. * Support old command line options.
* <p>
* In version 1.0, it is enabled by default.
* <p>
* In version 1.1, it is disabled by default.
*/ */
// TODO change in version 1.1 public static final boolean OLD_COMMAND_LINE_OPTIONS = getBooleanSetting("h2.oldCommandLineOptions", Constants.VERSION < 1.1);
public static final boolean OLD_COMMAND_LINE_OPTIONS = getBooleanSetting("h2.oldCommandLineOptions", true);
/** /**
* System property <code>h2.optimizeDropDependencies</code> (default: * System property <code>h2.optimizeDropDependencies</code> (default:
...@@ -346,11 +355,15 @@ public class SysProperties { ...@@ -346,11 +355,15 @@ public class SysProperties {
public static final boolean OPTIMIZE_EVALUATABLE_SUBQUERIES = getBooleanSetting("h2.optimizeEvaluatableSubqueries", true); public static final boolean OPTIMIZE_EVALUATABLE_SUBQUERIES = getBooleanSetting("h2.optimizeEvaluatableSubqueries", true);
/** /**
* System property <code>h2.optimizeGroupSorted</code> (default: false).<br /> * System property <code>h2.optimizeGroupSorted</code>.<br />
* Optimize GROUP BY queries if an index can be used that matches the group * Optimize GROUP BY queries if an index can be used that matches the group
* by columns. * by columns.
* <p>
* In version 1.0, it is disabled by default.
* <p>
* In version 1.1, it is enabled by default.
*/ */
public static final boolean OPTIMIZE_GROUP_SORTED = getBooleanSetting("h2.optimizeGroupSorted", false); public static final boolean OPTIMIZE_GROUP_SORTED = getBooleanSetting("h2.optimizeGroupSorted", Constants.VERSION > 1.0);
/** /**
* System property <code>h2.optimizeIn</code> (default: true).<br /> * System property <code>h2.optimizeIn</code> (default: true).<br />
...@@ -361,8 +374,12 @@ public class SysProperties { ...@@ -361,8 +374,12 @@ public class SysProperties {
/** /**
* System property <code>h2.optimizeInJoin</code> (default: false).<br /> * System property <code>h2.optimizeInJoin</code> (default: false).<br />
* Optimize IN(...) comparisons by converting them to inner joins. * Optimize IN(...) comparisons by converting them to inner joins.
* <p>
* In version 1.0, it is disabled by default.
* <p>
* In version 1.1, it is enabled by default.
*/ */
public static boolean optimizeInJoin = getBooleanSetting("h2.optimizeInJoin", true); public static boolean optimizeInJoin = getBooleanSetting("h2.optimizeInJoin", Constants.VERSION > 1.0);
/** /**
* System property <code>h2.optimizeMinMax</code> (default: true).<br /> * System property <code>h2.optimizeMinMax</code> (default: true).<br />
...@@ -453,6 +470,17 @@ public class SysProperties { ...@@ -453,6 +470,17 @@ public class SysProperties {
*/ */
public static final int SERVER_RESULT_SET_FETCH_SIZE = getIntSetting("h2.serverResultSetFetchSize", 100); public static final int SERVER_RESULT_SET_FETCH_SIZE = getIntSetting("h2.serverResultSetFetchSize", 100);
/**
* System property <code>h2.shareLinkedConnections</code>.<br />
* Linked connections should be shared, that means connections to the same
* database should be used for all linked tables that connect to the same database.
* <p>
* In version 1.0, it is disabled by default.
* <p>
* In version 1.1, it is enabled by default.
*/
public static final boolean SHARE_LINKED_CONNECTIONS = getBooleanSetting("h2.shareLinkedConnections", Constants.VERSION > 1.0);
/** /**
* System property <code>h2.sortNullsHigh</code> (default: false).<br /> * System property <code>h2.sortNullsHigh</code> (default: false).<br />
* Invert the default sorting behavior for NULL values, such that NULL * Invert the default sorting behavior for NULL values, such that NULL
......
...@@ -96,6 +96,7 @@ public class FileLock { ...@@ -96,6 +96,7 @@ public class FileLock {
private String method, ipAddress; private String method, ipAddress;
private Properties properties; private Properties properties;
private boolean locked; private boolean locked;
private String uniqueId;
/** /**
* Create a new file locking object. * Create a new file locking object.
...@@ -234,12 +235,17 @@ public class FileLock { ...@@ -234,12 +235,17 @@ public class FileLock {
throw error("Lock file recently modified"); throw error("Lock file recently modified");
} }
private void setUniqueId() {
byte[] bytes = RandomUtils.getSecureBytes(RANDOM_BYTES);
String random = ByteUtils.convertBytesToString(bytes);
uniqueId = Long.toHexString(System.currentTimeMillis()) + random;
properties.setProperty("id", uniqueId);
}
private void lockFile() throws SQLException { private void lockFile() throws SQLException {
method = FILE; method = FILE;
properties = new SortedProperties(); properties = new SortedProperties();
byte[] bytes = RandomUtils.getSecureBytes(RANDOM_BYTES); setUniqueId();
String random = ByteUtils.convertBytesToString(bytes);
properties.setProperty("id", Long.toHexString(System.currentTimeMillis())+random);
if (!fs.createNewFile(fileName)) { if (!fs.createNewFile(fileName)) {
waitUntilOld(); waitUntilOld();
String m2 = load().getProperty("method", FILE); String m2 = load().getProperty("method", FILE);
...@@ -293,6 +299,7 @@ public class FileLock { ...@@ -293,6 +299,7 @@ public class FileLock {
private void lockSocket() throws SQLException { private void lockSocket() throws SQLException {
method = SOCKET; method = SOCKET;
properties = new SortedProperties(); properties = new SortedProperties();
setUniqueId();
try { try {
// TODO documentation: if this returns 127.0.0.1, // TODO documentation: if this returns 127.0.0.1,
// the computer is probably not networked // the computer is probably not networked
...@@ -390,13 +397,14 @@ public class FileLock { ...@@ -390,13 +397,14 @@ public class FileLock {
private SQLException error(String reason) { private SQLException error(String reason) {
JdbcSQLException ex = Message.getSQLException(ErrorCode.DATABASE_ALREADY_OPEN_1, reason); JdbcSQLException ex = Message.getSQLException(ErrorCode.DATABASE_ALREADY_OPEN_1, reason);
String server = null; String payload = null;
try { try {
server = load().getProperty("server"); Properties prop = load();
payload = prop.getProperty("server") + "/" + prop.getProperty("id");
} catch (SQLException e) { } catch (SQLException e) {
// ignore // ignore
} }
ex.setPayload(server); ex.setPayload(payload);
return ex; return ex;
} }
...@@ -419,4 +427,8 @@ public class FileLock { ...@@ -419,4 +427,8 @@ public class FileLock {
} }
} }
public String getUniqueId() {
return uniqueId;
}
} }
...@@ -10,6 +10,7 @@ import java.sql.Connection; ...@@ -10,6 +10,7 @@ import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import org.h2.constant.SysProperties;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -42,8 +43,13 @@ public class TableLinkConnection { ...@@ -42,8 +43,13 @@ public class TableLinkConnection {
public static TableLinkConnection open(HashMap map, String driver, String url, String user, String password) throws SQLException { public static TableLinkConnection open(HashMap map, String driver, String url, String user, String password) throws SQLException {
TableLinkConnection t = new TableLinkConnection(map, driver, url, user, password); TableLinkConnection t = new TableLinkConnection(map, driver, url, user, password);
if (SysProperties.SHARE_LINKED_CONNECTIONS) {
t.open();
return t;
}
synchronized (map) { synchronized (map) {
TableLinkConnection result = (TableLinkConnection) map.get(t); TableLinkConnection result;
result = (TableLinkConnection) map.get(t);
if (result == null) { if (result == null) {
synchronized (t) { synchronized (t) {
t.open(); t.open();
...@@ -105,7 +111,7 @@ public class TableLinkConnection { ...@@ -105,7 +111,7 @@ public class TableLinkConnection {
* Closes the connection if this is the last link to it. * Closes the connection if this is the last link to it.
*/ */
synchronized void close() throws SQLException { synchronized void close() throws SQLException {
if (--useCounter == 0) { if (--useCounter <= 0) {
conn.close(); conn.close();
conn = null; conn = null;
synchronized (map) { synchronized (map) {
......
...@@ -11,6 +11,7 @@ import java.util.ArrayList; ...@@ -11,6 +11,7 @@ import java.util.ArrayList;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.store.fs.FileSystem;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.Tool; import org.h2.util.Tool;
...@@ -107,7 +108,15 @@ public class DeleteDbFiles extends Tool { ...@@ -107,7 +108,15 @@ public class DeleteDbFiles extends Tool {
} }
private void process(String fileName, boolean quiet) throws SQLException { private void process(String fileName, boolean quiet) throws SQLException {
if (quiet || fileName.endsWith(Constants.SUFFIX_TEMP_FILE) || fileName.endsWith(Constants.SUFFIX_TRACE_FILE)) { if (FileUtils.isDirectory(fileName)) {
try {
FileSystem.getInstance(fileName).deleteRecursive(fileName);
} catch (SQLException e) {
if (!quiet) {
throw e;
}
}
} else if (quiet || fileName.endsWith(Constants.SUFFIX_TEMP_FILE) || fileName.endsWith(Constants.SUFFIX_TRACE_FILE)) {
FileUtils.tryDelete(fileName); FileUtils.tryDelete(fileName);
} else { } else {
FileUtils.delete(fileName); FileUtils.delete(fileName);
......
...@@ -9,6 +9,7 @@ package org.h2.test; ...@@ -9,6 +9,7 @@ package org.h2.test;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import org.h2.engine.Constants;
import org.h2.store.fs.FileSystemDisk; import org.h2.store.fs.FileSystemDisk;
import org.h2.test.bench.TestPerformance; import org.h2.test.bench.TestPerformance;
import org.h2.test.db.TestAutoRecompile; import org.h2.test.db.TestAutoRecompile;
...@@ -274,6 +275,11 @@ java org.h2.test.TestAll timer ...@@ -274,6 +275,11 @@ java org.h2.test.TestAll timer
/* /*
14.zip
check all version(s) before releasing
Add version number. Install directory: h2-1.1, jar file: h2-1.1.100.jar. Micro version: use build number, staring with 1.1.100
test on linux test on linux
TestMVCC: TestMVCC:
...@@ -617,11 +623,12 @@ http://www.w3schools.com/sql/ ...@@ -617,11 +623,12 @@ http://www.w3schools.com/sql/
private void printSystem() { private void printSystem() {
Properties prop = System.getProperties(); Properties prop = System.getProperties();
System.out.println("Java: " + System.out.println("H2 " + Constants.getFullVersion());
System.out.println("Java " +
prop.getProperty("java.runtime.version") + ", " + prop.getProperty("java.runtime.version") + ", " +
prop.getProperty("java.vm.name")+", " + prop.getProperty("java.vm.name")+", " +
prop.getProperty("java.vendor")); prop.getProperty("java.vendor"));
System.out.println("Env: " + System.out.println(
prop.getProperty("os.name") + ", " + prop.getProperty("os.name") + ", " +
prop.getProperty("os.arch")+", "+ prop.getProperty("os.arch")+", "+
prop.getProperty("os.version")+", "+ prop.getProperty("os.version")+", "+
......
...@@ -32,7 +32,7 @@ public class TestOutOfMemory extends TestBase { ...@@ -32,7 +32,7 @@ public class TestOutOfMemory extends TestBase {
Connection conn = getConnection("outOfMemory"); Connection conn = getConnection("outOfMemory");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table stuff (id int primary key, text varchar as space(100) || id)"); stat.execute("create table stuff (id int primary key, text varchar as space(100) || id)");
stat.execute("insert into stuff(id) select x from system_range(1, 1000)"); stat.execute("insert into stuff(id) select x from system_range(1, 2000)");
PreparedStatement prep = conn.prepareStatement("update stuff set text = text || ' upd'"); PreparedStatement prep = conn.prepareStatement("update stuff set text = text || ' upd'");
prep.execute(); prep.execute();
eatMemory(80); eatMemory(80);
......
...@@ -21,6 +21,7 @@ import java.sql.SQLException; ...@@ -21,6 +21,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.engine.Constants;
import org.h2.test.TestAll; import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -43,7 +44,8 @@ public class TestScript extends TestBase { ...@@ -43,7 +44,8 @@ public class TestScript extends TestBase {
private String putBack; private String putBack;
private StringBuffer errors; private StringBuffer errors;
private ArrayList statements; private ArrayList statements;
private String fileName = "org/h2/test/test.in.txt"; private String fileName = "org/h2/test/test-" +
Constants.VERSION_MAJOR + "." + Constants.VERSION_MINOR + ".txt";
/** /**
* Get all SQL statements of this file. * Get all SQL statements of this file.
...@@ -52,9 +54,8 @@ public class TestScript extends TestBase { ...@@ -52,9 +54,8 @@ public class TestScript extends TestBase {
* @param file the file name * @param file the file name
* @return the list of statements * @return the list of statements
*/ */
public ArrayList getAllStatements(TestAll conf, String file) throws Exception { public ArrayList getAllStatements(TestAll conf) throws Exception {
config = conf; config = conf;
fileName = file;
statements = new ArrayList(); statements = new ArrayList();
test(); test();
return statements; return statements;
......
...@@ -47,10 +47,11 @@ public class TestAutoServer extends TestBase { ...@@ -47,10 +47,11 @@ public class TestAutoServer extends TestBase {
for (; i > 0; i--) { for (; i > 0; i--) {
Thread.sleep(100); Thread.sleep(100);
SortedProperties prop = SortedProperties.loadProperties(baseDir + "/autoServer.lock.db"); SortedProperties prop = SortedProperties.loadProperties(baseDir + "/autoServer.lock.db");
String key = prop.getProperty("id");
String server = prop.getProperty("server"); String server = prop.getProperty("server");
if (server != null) { if (server != null) {
String u2 = url.substring(url.indexOf("autoServer")); String u2 = url.substring(url.indexOf("autoServer"));
u2 = "jdbc:h2:tcp://" + server + "/" + baseDir + "/" + u2; u2 = "jdbc:h2:tcp://" + server + "/" + key;
conn = DriverManager.getConnection(u2, user, password); conn = DriverManager.getConnection(u2, user, password);
conn.close(); conn.close();
break; break;
......
...@@ -397,7 +397,7 @@ public class TestCrashAPI extends TestBase { ...@@ -397,7 +397,7 @@ public class TestCrashAPI extends TestBase {
baseDir = TestBase.getTestDir("crash"); baseDir = TestBase.getTestDir("crash");
startServerIfRequired(); startServerIfRequired();
TestScript script = new TestScript(); TestScript script = new TestScript();
ArrayList add = script.getAllStatements(config, "org/h2/test/test.in.txt"); ArrayList add = script.getAllStatements(config);
initMethods(); initMethods();
org.h2.Driver.load(); org.h2.Driver.load();
statements.addAll(add); statements.addAll(add);
......
差异被折叠。
...@@ -257,7 +257,17 @@ public class TestTools extends TestBase { ...@@ -257,7 +257,17 @@ public class TestTools extends TestBase {
conn.close(); conn.close();
Recover.main(new String[]{"-dir", baseDir, "-db", "toolsRecover"}); Recover.main(new String[]{"-dir", baseDir, "-db", "toolsRecover"});
deleteDb("toolsRecover");
// deleteDb would delete the .lob.db directory as well
// deleteDb("toolsRecover");
ArrayList list = FileLister.getDatabaseFiles(baseDir, "toolsRecover", true);
for (int i = 0; i < list.size(); i++) {
String fileName = (String) list.get(i);
if (!FileUtils.isDirectory(fileName)) {
FileUtils.delete(fileName);
}
}
conn = DriverManager.getConnection(url, "another", "another"); conn = DriverManager.getConnection(url, "another", "another");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("runscript from '" + baseDir + "/toolsRecover.data.sql'"); stat.execute("runscript from '" + baseDir + "/toolsRecover.data.sql'");
......
...@@ -47,7 +47,7 @@ public class Build extends BuildBase { ...@@ -47,7 +47,7 @@ public class Build extends BuildBase {
download("ext/mysql-connector-java-5.1.6.jar", download("ext/mysql-connector-java-5.1.6.jar",
"http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar", "http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar",
"380ef5226de2c85ff3b38cbfefeea881c5fce09d"); "380ef5226de2c85ff3b38cbfefeea881c5fce09d");
String cp = "temp" + File.pathSeparator + "bin/h2.jar" + File.pathSeparator + String cp = "temp" + File.pathSeparator + "bin/h2" + getJarSuffix() + File.pathSeparator +
"ext/hsqldb-1.8.0.7.jar" + File.pathSeparator + "ext/hsqldb-1.8.0.7.jar" + File.pathSeparator +
"ext/derby-10.4.2.0.jar" + File.pathSeparator + "ext/derby-10.4.2.0.jar" + File.pathSeparator +
"ext/derbyclient-10.4.2.0.jar" + File.pathSeparator + "ext/derbyclient-10.4.2.0.jar" + File.pathSeparator +
...@@ -178,6 +178,14 @@ public class Build extends BuildBase { ...@@ -178,6 +178,14 @@ public class Build extends BuildBase {
return getStaticValue("org.h2.engine.Constants", "getVersion"); return getStaticValue("org.h2.engine.Constants", "getVersion");
} }
private String getJarSuffix() {
String version = getVersion();
if (version.startsWith("1.0.")) {
return ".jar";
}
return "-" + version + ".jar";
}
/** /**
* Create the h2.zip file and the Windows installer. * Create the h2.zip file and the Windows installer.
*/ */
...@@ -215,7 +223,7 @@ public class Build extends BuildBase { ...@@ -215,7 +223,7 @@ public class Build extends BuildBase {
exclude("*.bat"). exclude("*.bat").
exclude("*.sh"). exclude("*.sh").
exclude("*.txt"); exclude("*.txt");
jar("bin/h2.jar", files, "temp"); jar("bin/h2" + getJarSuffix(), files, "temp");
} }
/** /**
...@@ -234,7 +242,7 @@ public class Build extends BuildBase { ...@@ -234,7 +242,7 @@ public class Build extends BuildBase {
exclude("*.bat"). exclude("*.bat").
exclude("*.sh"). exclude("*.sh").
exclude("*.txt"); exclude("*.txt");
long kb = jar("bin/h2client.jar", files, "temp"); long kb = jar("bin/h2client" + getJarSuffix(), files, "temp");
if (kb < 300 || kb > 350) { if (kb < 300 || kb > 350) {
throw new Error("Expected file size 300 - 350 KB, got: " + kb); throw new Error("Expected file size 300 - 350 KB, got: " + kb);
} }
...@@ -261,7 +269,7 @@ public class Build extends BuildBase { ...@@ -261,7 +269,7 @@ public class Build extends BuildBase {
exclude("*.bat"). exclude("*.bat").
exclude("*.sh"). exclude("*.sh").
exclude("*.txt"); exclude("*.txt");
jar("bin/h2small.jar", files, "temp"); jar("bin/h2small" + getJarSuffix(), files, "temp");
} }
/** /**
...@@ -273,7 +281,7 @@ public class Build extends BuildBase { ...@@ -273,7 +281,7 @@ public class Build extends BuildBase {
manifest("H2 JaQu", ""); manifest("H2 JaQu", "");
FileList files = getFiles("temp/org/h2/jaqu"); FileList files = getFiles("temp/org/h2/jaqu");
files.addAll(getFiles("temp/META-INF/MANIFEST.MF")); files.addAll(getFiles("temp/META-INF/MANIFEST.MF"));
jar("bin/h2jaqu.jar", files, "temp"); jar("bin/h2jaqu" + getJarSuffix(), files, "temp");
} }
/** /**
...@@ -346,7 +354,7 @@ public class Build extends BuildBase { ...@@ -346,7 +354,7 @@ public class Build extends BuildBase {
writeFile(new File("bin/pom.xml"), pom.getBytes()); writeFile(new File("bin/pom.xml"), pom.getBytes());
execScript("mvn", new String[] { execScript("mvn", new String[] {
"deploy:deploy-file", "deploy:deploy-file",
"-Dfile=bin/h2.jar", "-Dfile=bin/h2" + getJarSuffix(),
"-Durl=file:///data/h2database/m2-repo", "-Durl=file:///data/h2database/m2-repo",
"-Dpackaging=jar", "-Dpackaging=jar",
"-Dversion=" + getVersion(), "-Dversion=" + getVersion(),
...@@ -367,7 +375,7 @@ public class Build extends BuildBase { ...@@ -367,7 +375,7 @@ public class Build extends BuildBase {
execScript("mvn", new String[] { execScript("mvn", new String[] {
"install:install-file", "install:install-file",
"-Dversion=1.0-SNAPSHOT", "-Dversion=1.0-SNAPSHOT",
"-Dfile=bin/h2.jar", "-Dfile=bin/h2" + getJarSuffix(),
"-Dpackaging=jar", "-Dpackaging=jar",
"-DpomFile=bin/pom.xml", "-DpomFile=bin/pom.xml",
"-DartifactId=h2", "-DartifactId=h2",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论