Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9919c5a0
提交
9919c5a0
authored
5月 20, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Require Java 1.5 compiler
上级
0a3590f0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
163 行增加
和
185 行删除
+163
-185
Build.java
h2/src/tools/org/h2/build/Build.java
+69
-73
BuildBase.java
h2/src/tools/org/h2/build/BuildBase.java
+94
-112
没有找到文件。
h2/src/tools/org/h2/build/Build.java
浏览文件 @
9919c5a0
...
@@ -12,8 +12,8 @@ import java.net.InetAddress;
...
@@ -12,8 +12,8 @@ import java.net.InetAddress;
import
java.net.InetSocketAddress
;
import
java.net.InetSocketAddress
;
import
java.net.ServerSocket
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.util.Iterator
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.Map.Entry
;
import
org.h2.build.code.SwitchSource
;
import
org.h2.build.code.SwitchSource
;
...
@@ -61,15 +61,15 @@ public class Build extends BuildBase {
...
@@ -61,15 +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"
;
StringList
args
=
new
StringList
(
new
String
[]{
"-Xmx128m"
,
"-cp"
,
cp
,
"org.h2.test.bench.TestPerformance"
}
);
StringList
args
=
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"org.h2.test.bench.TestPerformance"
);
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-init"
,
"-db"
,
"1"
}
));
exec
(
"java"
,
args
.
plus
(
"-init"
,
"-db"
,
"1"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"2"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"2"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"3"
,
"-out"
,
"pe.html"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"3"
,
"-out"
,
"pe.html"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-init"
,
"-db"
,
"4"
}
));
exec
(
"java"
,
args
.
plus
(
"-init"
,
"-db"
,
"4"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"5"
,
"-exit"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"5"
,
"-exit"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"6"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"6"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"7"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"7"
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"8"
,
"-out"
,
"ps.html"
}
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"8"
,
"-out"
,
"ps.html"
));
}
}
/**
/**
...
@@ -80,7 +80,7 @@ public class Build extends BuildBase {
...
@@ -80,7 +80,7 @@ public class Build extends BuildBase {
delete
(
"docs"
);
delete
(
"docs"
);
mkdir
(
"docs"
);
mkdir
(
"docs"
);
mkdir
(
"bin"
);
mkdir
(
"bin"
);
delete
(
getF
iles
(
"."
).
keep
(
"*/Thumbs.db"
));
delete
(
f
iles
(
"."
).
keep
(
"*/Thumbs.db"
));
}
}
/**
/**
...
@@ -104,12 +104,12 @@ public class Build extends BuildBase {
...
@@ -104,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
StringList
(
new
String
[]
{
"-Xmx128m"
,
"-cp"
,
cp
,
"emma"
,
"run"
,
exec
(
"java"
,
args
(
"-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"
));
}
}
/**
/**
...
@@ -141,35 +141,35 @@ public class Build extends BuildBase {
...
@@ -141,35 +141,35 @@ public class Build extends BuildBase {
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
;
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
;
FileList
files
;
FileList
files
;
if
(
clientOnly
)
{
if
(
clientOnly
)
{
files
=
getF
iles
(
"src/main/org/h2/Driver.java"
);
files
=
f
iles
(
"src/main/org/h2/Driver.java"
);
files
.
addAll
(
getF
iles
(
"src/main/org/h2/jdbc"
));
files
.
addAll
(
f
iles
(
"src/main/org/h2/jdbc"
));
files
.
addAll
(
getF
iles
(
"src/main/org/h2/jdbcx"
));
files
.
addAll
(
f
iles
(
"src/main/org/h2/jdbcx"
));
}
else
{
}
else
{
files
=
getF
iles
(
"src/main"
);
files
=
f
iles
(
"src/main"
);
}
}
StringList
args
=
new
StringList
();
StringList
args
=
args
();
if
(
System
.
getProperty
(
"version"
)
!=
null
)
{
if
(
System
.
getProperty
(
"version"
)
!=
null
)
{
String
bcp
=
System
.
getProperty
(
"bcp"
);
String
bcp
=
System
.
getProperty
(
"bcp"
);
// /System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes/classes.jar
// /System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes/classes.jar
args
=
args
.
plus
(
new
String
[]
{
"-source"
,
"1.5"
,
"-target"
,
"jsr14"
,
"-bootclasspath"
,
bcp
}
);
args
=
args
.
plus
(
"-source"
,
"1.5"
,
"-target"
,
"jsr14"
,
"-bootclasspath"
,
bcp
);
}
}
if
(
debugInfo
)
{
if
(
debugInfo
)
{
args
=
args
.
plus
(
new
String
[]
{
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
}
);
args
=
args
.
plus
(
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
);
}
else
{
}
else
{
args
=
args
.
plus
(
new
String
[]
{
"-g:none"
,
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
}
);
args
=
args
.
plus
(
"-g:none"
,
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
);
}
}
javac
(
args
,
files
);
javac
(
args
,
files
);
files
=
getF
iles
(
"src/main/META-INF/services"
);
files
=
f
iles
(
"src/main/META-INF/services"
);
copy
(
"temp"
,
files
,
"src/main"
);
copy
(
"temp"
,
files
,
"src/main"
);
if
(!
clientOnly
)
{
if
(!
clientOnly
)
{
files
=
getF
iles
(
"src/test"
);
files
=
f
iles
(
"src/test"
);
files
.
addAll
(
getF
iles
(
"src/tools"
));
files
.
addAll
(
f
iles
(
"src/tools"
));
args
=
new
StringList
(
new
String
[]
{
"-d"
,
"temp"
,
"-sourcepath"
,
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
args
=
args
(
"-d"
,
"temp"
,
"-sourcepath"
,
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-classpath"
,
classpath
}
);
"-classpath"
,
classpath
);
javac
(
args
,
files
);
javac
(
args
,
files
);
files
=
getF
iles
(
"src/test"
).
files
=
f
iles
(
"src/test"
).
exclude
(
"*.java"
).
exclude
(
"*.java"
).
exclude
(
"*/package.html"
);
exclude
(
"*/package.html"
);
copy
(
"temp"
,
files
,
"src/test"
);
copy
(
"temp"
,
files
,
"src/test"
);
...
@@ -189,7 +189,7 @@ public class Build extends BuildBase {
...
@@ -189,7 +189,7 @@ public class Build extends BuildBase {
*/
*/
public
void
docs
()
{
public
void
docs
()
{
javadoc
();
javadoc
();
copy
(
"docs"
,
getF
iles
(
"src/docsrc/index.html"
),
"src/docsrc"
);
copy
(
"docs"
,
f
iles
(
"src/docsrc/index.html"
),
"src/docsrc"
);
java
(
"org.h2.build.doc.XMLChecker"
,
null
);
java
(
"org.h2.build.doc.XMLChecker"
,
null
);
java
(
"org.h2.build.code.CheckJavadoc"
,
null
);
java
(
"org.h2.build.code.CheckJavadoc"
,
null
);
java
(
"org.h2.build.code.CheckTextFiles"
,
null
);
java
(
"org.h2.build.code.CheckTextFiles"
,
null
);
...
@@ -240,21 +240,21 @@ public class Build extends BuildBase {
...
@@ -240,21 +240,21 @@ public class Build extends BuildBase {
* Create the h2.zip file and the Windows installer.
* Create the h2.zip file and the Windows installer.
*/
*/
public
void
installer
()
{
public
void
installer
()
{
delete
(
getF
iles
(
"bin"
).
keep
(
"*.jar"
));
delete
(
f
iles
(
"bin"
).
keep
(
"*.jar"
));
jar
();
jar
();
docs
();
docs
();
exec
(
"soffice"
,
new
StringList
(
new
String
[]{
"-invisible"
,
"macro:///Standard.Module1.H2Pdf"
}
));
exec
(
"soffice"
,
args
(
"-invisible"
,
"macro:///Standard.Module1.H2Pdf"
));
copy
(
"docs"
,
getF
iles
(
"../h2web/h2.pdf"
),
"../h2web"
);
copy
(
"docs"
,
f
iles
(
"../h2web/h2.pdf"
),
"../h2web"
);
delete
(
"docs/html/onePage.html"
);
delete
(
"docs/html/onePage.html"
);
FileList
files
=
getF
iles
(
"../h2"
).
keep
(
"../h2/build.*"
);
FileList
files
=
f
iles
(
"../h2"
).
keep
(
"../h2/build.*"
);
files
.
addAll
(
getF
iles
(
"../h2/bin"
).
keep
(
"../h2/bin/h2*"
));
files
.
addAll
(
f
iles
(
"../h2/bin"
).
keep
(
"../h2/bin/h2*"
));
files
.
addAll
(
getF
iles
(
"../h2/docs"
));
files
.
addAll
(
f
iles
(
"../h2/docs"
));
files
.
addAll
(
getF
iles
(
"../h2/service"
));
files
.
addAll
(
f
iles
(
"../h2/service"
));
files
.
addAll
(
getF
iles
(
"../h2/src"
));
files
.
addAll
(
f
iles
(
"../h2/src"
));
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
StringList
(
new
String
[]{
"/v2"
,
"src/installer/h2.nsi"
}
));
exec
(
"makensis"
,
args
(
"/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
);
...
@@ -272,7 +272,7 @@ public class Build extends BuildBase {
...
@@ -272,7 +272,7 @@ public class Build extends BuildBase {
public
void
jar
()
{
public
void
jar
()
{
compile
();
compile
();
manifest
(
"H2 Database Engine"
,
"org.h2.tools.Console"
);
manifest
(
"H2 Database Engine"
,
"org.h2.tools.Console"
);
FileList
files
=
getF
iles
(
"temp"
).
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
...
@@ -295,7 +295,7 @@ public class Build extends BuildBase {
...
@@ -295,7 +295,7 @@ public class Build extends BuildBase {
*/
*/
public
void
jarClient
()
{
public
void
jarClient
()
{
compile
(
true
,
true
,
false
);
compile
(
true
,
true
,
false
);
FileList
files
=
getF
iles
(
"temp"
).
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
...
@@ -317,7 +317,7 @@ public class Build extends BuildBase {
...
@@ -317,7 +317,7 @@ public class Build extends BuildBase {
*/
*/
public
void
jarSmall
()
{
public
void
jarSmall
()
{
compile
(
false
,
false
,
true
);
compile
(
false
,
false
,
true
);
FileList
files
=
getF
iles
(
"temp"
).
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org/h2/bnf/*"
).
exclude
(
"temp/org/h2/bnf/*"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/dev/*"
).
...
@@ -342,8 +342,8 @@ public class Build extends BuildBase {
...
@@ -342,8 +342,8 @@ public class Build extends BuildBase {
public
void
jarJaqu
()
{
public
void
jarJaqu
()
{
compile
(
true
,
false
,
true
);
compile
(
true
,
false
,
true
);
manifest
(
"H2 JaQu"
,
""
);
manifest
(
"H2 JaQu"
,
""
);
FileList
files
=
getF
iles
(
"temp/org/h2/jaqu"
);
FileList
files
=
f
iles
(
"temp/org/h2/jaqu"
);
files
.
addAll
(
getF
iles
(
"temp/META-INF/MANIFEST.MF"
));
files
.
addAll
(
f
iles
(
"temp/META-INF/MANIFEST.MF"
));
jar
(
"bin/h2jaqu"
+
getJarSuffix
(),
files
,
"temp"
);
jar
(
"bin/h2jaqu"
+
getJarSuffix
(),
files
,
"temp"
);
}
}
...
@@ -353,12 +353,12 @@ public class Build extends BuildBase {
...
@@ -353,12 +353,12 @@ public class Build extends BuildBase {
public
void
javadoc
()
{
public
void
javadoc
()
{
delete
(
"docs"
);
delete
(
"docs"
);
mkdir
(
"docs/javadoc"
);
mkdir
(
"docs/javadoc"
);
javadoc
(
new
StringList
(
new
String
[]
{
"-sourcepath"
,
"src/main"
,
"org.h2.jdbc"
,
"org.h2.jdbcx"
,
javadoc
(
"-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"
,
getF
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
copy
(
"docs/javadoc"
,
f
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
}
}
/**
/**
...
@@ -366,8 +366,7 @@ public class Build extends BuildBase {
...
@@ -366,8 +366,7 @@ public class Build extends BuildBase {
*/
*/
public
void
javadocImpl
()
{
public
void
javadocImpl
()
{
mkdir
(
"docs/javadocImpl2"
);
mkdir
(
"docs/javadocImpl2"
);
javadoc
(
new
StringList
(
new
String
[]
{
javadoc
(
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-noindex"
,
"-noindex"
,
"-tag"
,
"h2.resource"
,
"-tag"
,
"h2.resource"
,
...
@@ -379,12 +378,11 @@ public class Build extends BuildBase {
...
@@ -379,12 +378,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
StringList
(
new
String
[]
{
javadoc
(
"-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"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
...
@@ -393,8 +391,8 @@ public class Build extends BuildBase {
...
@@ -393,8 +391,8 @@ 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"
,
getF
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
copy
(
"docs/javadocImpl"
,
f
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
}
}
private
void
manifest
(
String
title
,
String
mainClassName
)
{
private
void
manifest
(
String
title
,
String
mainClassName
)
{
...
@@ -420,7 +418,7 @@ public class Build extends BuildBase {
...
@@ -420,7 +418,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
StringList
(
new
String
[]
{
execScript
(
"mvn"
,
args
(
"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"
,
...
@@ -428,7 +426,7 @@ public class Build extends BuildBase {
...
@@ -428,7 +426,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"
));
}
}
/**
/**
...
@@ -440,22 +438,22 @@ public class Build extends BuildBase {
...
@@ -440,22 +438,22 @@ 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
StringList
(
new
String
[]
{
execScript
(
"mvn"
,
args
(
"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
StringList
(
new
String
[]
{
"-sourcepath"
,
"src/main"
,
"org.h2.tools"
,
javadoc
(
"-sourcepath"
,
"src/main"
,
"org.h2.tools"
,
"-doclet"
,
"org.h2.build.doclet.ResourceDoclet"
})
);
"-doclet"
,
"org.h2.build.doclet.ResourceDoclet"
);
}
}
FileList
files
=
getF
iles
(
"src/main"
).
FileList
files
=
f
iles
(
"src/main"
).
exclude
(
"*.MF"
).
exclude
(
"*.MF"
).
exclude
(
"*.java"
).
exclude
(
"*.java"
).
exclude
(
"*/package.html"
).
exclude
(
"*/package.html"
).
...
@@ -491,20 +489,18 @@ public class Build extends BuildBase {
...
@@ -491,20 +489,18 @@ public class Build extends BuildBase {
public
void
testNetwork
()
{
public
void
testNetwork
()
{
try
{
try
{
System
.
out
.
println
(
"environment settings:"
);
System
.
out
.
println
(
"environment settings:"
);
for
(
Iterator
it
=
new
TreeMap
(
System
.
getProperties
()).
entrySet
().
iterator
();
it
.
hasNext
();
)
{
for
(
Entry
<
Object
,
Object
>
e
:
new
TreeMap
<
Object
,
Object
>(
System
.
getProperties
()).
entrySet
()
)
{
System
.
out
.
println
(
it
.
next
()
);
System
.
out
.
println
(
e
);
}
}
System
.
out
.
println
();
System
.
out
.
println
();
System
.
out
.
println
(
"localhost:"
+
InetAddress
.
getByName
(
"localhost"
));
System
.
out
.
println
(
"localhost:"
+
InetAddress
.
getByName
(
"localhost"
));
InetAddress
[]
addresses
=
InetAddress
.
getAllByName
(
"localhost"
);
for
(
InetAddress
address
:
InetAddress
.
getAllByName
(
"localhost"
))
{
for
(
int
i
=
0
;
i
<
addresses
.
length
;
i
++)
{
System
.
out
.
println
(
" "
+
address
);
System
.
out
.
println
(
i
+
":"
+
addresses
[
i
]);
}
}
InetAddress
localhost
=
InetAddress
.
getLocalHost
();
InetAddress
localhost
=
InetAddress
.
getLocalHost
();
System
.
out
.
println
(
"getLocalHost:"
+
localhost
);
System
.
out
.
println
(
"getLocalHost:"
+
localhost
);
addresses
=
InetAddress
.
getAllByName
(
localhost
.
getHostAddress
());
for
(
InetAddress
address
:
InetAddress
.
getAllByName
(
localhost
.
getHostAddress
()))
{
for
(
int
i
=
0
;
i
<
addresses
.
length
;
i
++)
{
System
.
out
.
println
(
" "
+
address
);
System
.
out
.
println
(
i
+
":"
+
addresses
[
i
]);
}
}
InetAddress
address
=
InetAddress
.
getByName
(
localhost
.
getHostAddress
());
InetAddress
address
=
InetAddress
.
getByName
(
localhost
.
getHostAddress
());
System
.
out
.
println
(
"byName:"
+
address
);
System
.
out
.
println
(
"byName:"
+
address
);
...
@@ -569,9 +565,9 @@ public class Build extends BuildBase {
...
@@ -569,9 +565,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
StringList
(
new
String
[]
{
"-Xmx128m"
,
"-cp"
,
cp
,
exec
(
"java"
,
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"-Dh2.ftpPassword="
+
password
,
"-Dh2.ftpPassword="
+
password
,
"org.h2.build.doc.UploadBuild"
}
));
"org.h2.build.doc.UploadBuild"
));
}
}
/**
/**
...
@@ -579,10 +575,10 @@ public class Build extends BuildBase {
...
@@ -579,10 +575,10 @@ public class Build extends BuildBase {
*/
*/
public
void
warConsole
()
{
public
void
warConsole
()
{
jar
();
jar
();
copy
(
"temp/WEB-INF"
,
getF
iles
(
"src/tools/WEB-INF/web.xml"
),
"src/tools/WEB-INF"
);
copy
(
"temp/WEB-INF"
,
f
iles
(
"src/tools/WEB-INF/web.xml"
),
"src/tools/WEB-INF"
);
copy
(
"temp"
,
getF
iles
(
"src/tools/WEB-INF/console.html"
),
"src/tools/WEB-INF"
);
copy
(
"temp"
,
f
iles
(
"src/tools/WEB-INF/console.html"
),
"src/tools/WEB-INF"
);
copy
(
"temp/WEB-INF/lib"
,
getF
iles
(
"bin/h2"
+
getJarSuffix
()),
"bin"
);
copy
(
"temp/WEB-INF/lib"
,
f
iles
(
"bin/h2"
+
getJarSuffix
()),
"bin"
);
FileList
files
=
getF
iles
(
"temp"
).
exclude
(
"temp/org*"
).
exclude
(
"temp/META-INF*"
);
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org*"
).
exclude
(
"temp/META-INF*"
);
jar
(
"bin/h2console.war"
,
files
,
"temp"
);
jar
(
"bin/h2console.war"
,
files
,
"temp"
);
}
}
...
...
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
9919c5a0
...
@@ -46,15 +46,11 @@ public class BuildBase {
...
@@ -46,15 +46,11 @@ public class BuildBase {
/**
/**
* A list of strings.
* A list of strings.
*/
*/
public
static
class
StringList
extends
ArrayList
implements
List
{
public
static
class
StringList
extends
ArrayList
<
String
>
implements
List
<
String
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
StringList
()
{
private
StringList
(
String
...
args
)
{
super
();
}
StringList
(
String
[]
args
)
{
super
();
super
();
addAll
(
Arrays
.
asList
(
args
));
addAll
(
Arrays
.
asList
(
args
));
}
}
...
@@ -65,35 +61,22 @@ public class BuildBase {
...
@@ -65,35 +61,22 @@ public class BuildBase {
* @param args the list to add
* @param args the list to add
* @return the new list
* @return the new list
*/
*/
public
StringList
plus
(
String
[]
args
)
{
public
StringList
plus
(
String
...
args
)
{
StringList
newList
=
new
StringList
();
StringList
newList
=
new
StringList
();
newList
.
addAll
(
this
);
newList
.
addAll
(
this
);
newList
.
addAll
(
Arrays
.
asList
(
args
));
newList
.
addAll
(
Arrays
.
asList
(
args
));
return
newList
;
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.
* Convert this list to a string array.
*
*
* @return the string array
* @return the string array
*/
*/
public
String
[]
toA
rray
()
{
public
String
[]
a
rray
()
{
String
[]
list
=
new
String
[
size
()];
String
[]
list
=
new
String
[
size
()];
for
(
int
i
=
0
;
i
<
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
size
();
i
++)
{
list
[
i
]
=
(
String
)
get
(
i
);
list
[
i
]
=
get
(
i
);
}
}
return
list
;
return
list
;
}
}
...
@@ -103,7 +86,7 @@ public class BuildBase {
...
@@ -103,7 +86,7 @@ public class BuildBase {
/**
/**
* A list of files.
* A list of files.
*/
*/
public
static
class
FileList
extends
ArrayList
implements
List
{
public
static
class
FileList
extends
ArrayList
<
File
>
implements
List
<
File
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -115,7 +98,7 @@ public class BuildBase {
...
@@ -115,7 +98,7 @@ public class BuildBase {
* @return the new file list
* @return the new file list
*/
*/
public
FileList
exclude
(
String
pattern
)
{
public
FileList
exclude
(
String
pattern
)
{
return
filter
Files
(
this
,
false
,
pattern
);
return
filter
(
false
,
pattern
);
}
}
/**
/**
...
@@ -126,7 +109,39 @@ public class BuildBase {
...
@@ -126,7 +109,39 @@ public class BuildBase {
* @return the new file list
* @return the new file list
*/
*/
public
FileList
keep
(
String
pattern
)
{
public
FileList
keep
(
String
pattern
)
{
return
filterFiles
(
this
,
true
,
pattern
);
return
filter
(
true
,
pattern
);
}
/**
* Filter a list of file names.
*
* @param files the original list
* @param keep if matching file names should be kept or removed
* @param pattern the file name pattern
* @return the filtered file list
*/
private
FileList
filter
(
boolean
keep
,
String
pattern
)
{
boolean
start
=
false
;
if
(
pattern
.
endsWith
(
"*"
))
{
pattern
=
pattern
.
substring
(
0
,
pattern
.
length
()
-
1
);
start
=
true
;
}
else
if
(
pattern
.
startsWith
(
"*"
))
{
pattern
=
pattern
.
substring
(
1
);
}
if
(
pattern
.
indexOf
(
'*'
)
>=
0
)
{
throw
new
Error
(
"Unsupported pattern, may only start or end with *:"
+
pattern
);
}
// normalize / and \
pattern
=
replaceAll
(
pattern
,
"/"
,
File
.
separator
);
FileList
list
=
new
FileList
();
for
(
File
f
:
this
)
{
String
path
=
f
.
getPath
();
boolean
match
=
start
?
path
.
startsWith
(
pattern
)
:
path
.
endsWith
(
pattern
);
if
(
match
==
keep
)
{
list
.
add
(
f
);
}
}
return
list
;
}
}
}
}
...
@@ -151,8 +166,7 @@ public class BuildBase {
...
@@ -151,8 +166,7 @@ public class BuildBase {
if
(
args
.
length
==
0
)
{
if
(
args
.
length
==
0
)
{
all
();
all
();
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
String
a
:
args
)
{
String
a
=
args
[
i
];
if
(
"-quiet"
.
equals
(
a
))
{
if
(
"-quiet"
.
equals
(
a
))
{
quiet
=
true
;
quiet
=
true
;
}
else
if
(
a
.
startsWith
(
"-D"
))
{
}
else
if
(
a
.
startsWith
(
"-D"
))
{
...
@@ -218,15 +232,13 @@ public class BuildBase {
...
@@ -218,15 +232,13 @@ public class BuildBase {
*/
*/
protected
void
projectHelp
()
{
protected
void
projectHelp
()
{
Method
[]
methods
=
getClass
().
getDeclaredMethods
();
Method
[]
methods
=
getClass
().
getDeclaredMethods
();
Arrays
.
sort
(
methods
,
new
Comparator
()
{
Arrays
.
sort
(
methods
,
new
Comparator
<
Method
>()
{
public
int
compare
(
Object
o1
,
Object
o2
)
{
public
int
compare
(
Method
a
,
Method
b
)
{
Method
a
=
(
Method
)
o1
,
b
=
(
Method
)
o2
;
return
a
.
getName
().
compareTo
(
b
.
getName
());
return
a
.
getName
().
compareTo
(
b
.
getName
());
}
}
});
});
out
.
println
(
"Targets:"
);
out
.
println
(
"Targets:"
);
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
for
(
Method
m
:
methods
)
{
Method
m
=
methods
[
i
];
int
mod
=
m
.
getModifiers
();
int
mod
=
m
.
getModifiers
();
if
(!
Modifier
.
isStatic
(
mod
)
&&
Modifier
.
isPublic
(
mod
)
&&
m
.
getParameterTypes
().
length
==
0
)
{
if
(!
Modifier
.
isStatic
(
mod
)
&&
Modifier
.
isPublic
(
mod
)
&&
m
.
getParameterTypes
().
length
==
0
)
{
out
.
println
(
m
.
getName
());
out
.
println
(
m
.
getName
());
...
@@ -264,8 +276,8 @@ public class BuildBase {
...
@@ -264,8 +276,8 @@ public class BuildBase {
protected
int
exec
(
String
command
,
StringList
args
)
{
protected
int
exec
(
String
command
,
StringList
args
)
{
try
{
try
{
print
(
command
);
print
(
command
);
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
size
();
i
++
)
{
for
(
String
a
:
args
)
{
print
(
" "
+
a
rgs
.
get
(
i
)
);
print
(
" "
+
a
);
}
}
StringList
cmd
=
new
StringList
();
StringList
cmd
=
new
StringList
();
cmd
=
cmd
.
plus
(
command
);
cmd
=
cmd
.
plus
(
command
);
...
@@ -273,7 +285,7 @@ public class BuildBase {
...
@@ -273,7 +285,7 @@ public class BuildBase {
cmd
.
addAll
(
args
);
cmd
.
addAll
(
args
);
}
}
println
(
""
);
println
(
""
);
Process
p
=
Runtime
.
getRuntime
().
exec
(
cmd
.
toA
rray
());
Process
p
=
Runtime
.
getRuntime
().
exec
(
cmd
.
a
rray
());
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
();
...
@@ -329,9 +341,9 @@ public class BuildBase {
...
@@ -329,9 +341,9 @@ public class BuildBase {
*/
*/
protected
String
getStaticValue
(
String
className
,
String
methodName
)
{
protected
String
getStaticValue
(
String
className
,
String
methodName
)
{
try
{
try
{
Class
clazz
=
Class
.
forName
(
className
);
Class
<
?
>
clazz
=
Class
.
forName
(
className
);
Method
method
=
clazz
.
getMethod
(
methodName
,
new
Class
[
0
]
);
Method
method
=
clazz
.
getMethod
(
methodName
);
return
method
.
invoke
(
null
,
new
Object
[
0
]
).
toString
();
return
method
.
invoke
(
null
).
toString
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
Error
(
"Can not read value "
+
className
+
"."
+
methodName
+
"()"
,
e
);
throw
new
Error
(
"Can not read value "
+
className
+
"."
+
methodName
+
"()"
,
e
);
}
}
...
@@ -344,13 +356,12 @@ public class BuildBase {
...
@@ -344,13 +356,12 @@ public class BuildBase {
* @param files the list of files to copy
* @param files the list of files to copy
* @param baseDir the base directory
* @param baseDir the base directory
*/
*/
protected
void
copy
(
String
targetDir
,
List
files
,
String
baseDir
)
{
protected
void
copy
(
String
targetDir
,
File
List
files
,
String
baseDir
)
{
File
target
=
new
File
(
targetDir
);
File
target
=
new
File
(
targetDir
);
File
base
=
new
File
(
baseDir
);
File
base
=
new
File
(
baseDir
);
println
(
"Copying "
+
files
.
size
()
+
" files to "
+
target
.
getPath
());
println
(
"Copying "
+
files
.
size
()
+
" files to "
+
target
.
getPath
());
String
basePath
=
base
.
getPath
();
String
basePath
=
base
.
getPath
();
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
for
(
File
f
:
files
)
{
File
f
=
(
File
)
files
.
get
(
i
);
File
t
=
new
File
(
target
,
removeBase
(
basePath
,
f
.
getPath
()));
File
t
=
new
File
(
target
,
removeBase
(
basePath
,
f
.
getPath
()));
byte
[]
data
=
readFile
(
f
);
byte
[]
data
=
readFile
(
f
);
mkdirs
(
t
.
getParentFile
());
mkdirs
(
t
.
getParentFile
());
...
@@ -378,8 +389,8 @@ public class BuildBase {
...
@@ -378,8 +389,8 @@ public class BuildBase {
byte
[]
data
=
buff
.
toByteArray
();
byte
[]
data
=
buff
.
toByteArray
();
String
line
=
new
String
(
data
,
"UTF-8"
);
String
line
=
new
String
(
data
,
"UTF-8"
);
boolean
print
=
true
;
boolean
print
=
true
;
for
(
int
i
=
0
;
i
<
exclude
.
length
;
i
++
)
{
for
(
String
l
:
exclude
)
{
if
(
line
.
startsWith
(
exclude
[
i
]
))
{
if
(
line
.
startsWith
(
l
))
{
print
=
false
;
print
=
false
;
break
;
break
;
}
}
...
@@ -402,7 +413,7 @@ public class BuildBase {
...
@@ -402,7 +413,7 @@ public class BuildBase {
*
*
* @param args the command line arguments to pass
* @param args the command line arguments to pass
*/
*/
protected
void
javadoc
(
String
List
args
)
{
protected
void
javadoc
(
String
...
args
)
{
int
result
;
int
result
;
PrintStream
old
=
System
.
out
;
PrintStream
old
=
System
.
out
;
try
{
try
{
...
@@ -416,12 +427,11 @@ public class BuildBase {
...
@@ -416,12 +427,11 @@ public class BuildBase {
"Building "
"Building "
}));
}));
}
}
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
});
String
[]
array
=
args
.
toArray
();
result
=
(
Integer
)
invoke
(
execute
,
null
,
new
Object
[]
{
args
});
result
=
((
Integer
)
invoke
(
execute
,
null
,
new
Object
[]
{
array
})).
intValue
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
result
=
exec
(
"javadoc"
,
args
);
result
=
exec
(
"javadoc"
,
args
(
args
)
);
}
finally
{
}
finally
{
System
.
setOut
(
old
);
System
.
setOut
(
old
);
}
}
...
@@ -494,7 +504,6 @@ public class BuildBase {
...
@@ -494,7 +504,6 @@ public class BuildBase {
if
(
sha1Checksum
==
null
)
{
if
(
sha1Checksum
==
null
)
{
println
(
"SHA1 checksum: "
+
got
);
println
(
"SHA1 checksum: "
+
got
);
}
else
{
}
else
{
if
(!
got
.
equals
(
sha1Checksum
))
{
if
(!
got
.
equals
(
sha1Checksum
))
{
throw
new
Error
(
"SHA1 checksum mismatch"
);
throw
new
Error
(
"SHA1 checksum mismatch"
);
}
}
...
@@ -508,59 +517,35 @@ public class BuildBase {
...
@@ -508,59 +517,35 @@ public class BuildBase {
* @param dir the source directory
* @param dir the source directory
* @return the file list
* @return the file list
*/
*/
protected
FileList
getF
iles
(
String
dir
)
{
protected
FileList
f
iles
(
String
dir
)
{
FileList
list
=
new
FileList
();
FileList
list
=
new
FileList
();
addFiles
(
list
,
new
File
(
dir
));
addFiles
(
list
,
new
File
(
dir
));
return
list
;
return
list
;
}
}
private
void
addFiles
(
List
list
,
File
file
)
{
/**
* Create a string list.
*
* @param args the arguments
* @return the string list
*/
protected
StringList
args
(
String
...
args
)
{
return
new
StringList
(
args
);
}
private
void
addFiles
(
FileList
list
,
File
file
)
{
if
(
file
.
getName
().
startsWith
(
".svn"
))
{
if
(
file
.
getName
().
startsWith
(
".svn"
))
{
// ignore
// ignore
}
else
if
(
file
.
isDirectory
())
{
}
else
if
(
file
.
isDirectory
())
{
String
[]
fileNames
=
file
.
list
();
String
path
=
file
.
getPath
();
String
path
=
file
.
getPath
();
for
(
int
i
=
0
;
i
<
fileNames
.
length
;
i
++
)
{
for
(
String
fileName
:
file
.
list
()
)
{
addFiles
(
list
,
new
File
(
path
,
fileName
s
[
i
]
));
addFiles
(
list
,
new
File
(
path
,
fileName
));
}
}
}
else
{
}
else
{
list
.
add
(
file
);
list
.
add
(
file
);
}
}
}
}
/**
* Filter a list of file names.
*
* @param files the original list
* @param keep if matching file names should be kept or removed
* @param pattern the file name pattern
* @return the filtered file list
*/
static
FileList
filterFiles
(
FileList
files
,
boolean
keep
,
String
pattern
)
{
boolean
start
=
false
;
if
(
pattern
.
endsWith
(
"*"
))
{
pattern
=
pattern
.
substring
(
0
,
pattern
.
length
()
-
1
);
start
=
true
;
}
else
if
(
pattern
.
startsWith
(
"*"
))
{
pattern
=
pattern
.
substring
(
1
);
}
if
(
pattern
.
indexOf
(
'*'
)
>=
0
)
{
throw
new
Error
(
"Unsupported pattern, may only start or end with *:"
+
pattern
);
}
// normalize / and \
pattern
=
replaceAll
(
pattern
,
"/"
,
File
.
separator
);
FileList
list
=
new
FileList
();
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
File
f
=
(
File
)
files
.
get
(
i
);
String
path
=
f
.
getPath
();
boolean
match
=
start
?
path
.
startsWith
(
pattern
)
:
path
.
endsWith
(
pattern
);
if
(
match
==
keep
)
{
list
.
add
(
f
);
}
}
return
list
;
}
private
String
removeBase
(
String
basePath
,
String
path
)
{
private
String
removeBase
(
String
basePath
,
String
path
)
{
if
(
path
.
startsWith
(
basePath
))
{
if
(
path
.
startsWith
(
basePath
))
{
path
=
path
.
substring
(
basePath
.
length
());
path
=
path
.
substring
(
basePath
.
length
());
...
@@ -630,7 +615,7 @@ public class BuildBase {
...
@@ -630,7 +615,7 @@ public class BuildBase {
* @param basePath the base path
* @param basePath the base path
* @return the size of the jar file in KB
* @return the size of the jar file in KB
*/
*/
protected
long
jar
(
String
destFile
,
List
files
,
String
basePath
)
{
protected
long
jar
(
String
destFile
,
File
List
files
,
String
basePath
)
{
long
kb
=
zipOrJar
(
destFile
,
files
,
basePath
,
false
,
false
,
true
);
long
kb
=
zipOrJar
(
destFile
,
files
,
basePath
,
false
,
false
,
true
);
println
(
"Jar "
+
destFile
+
" ("
+
kb
+
" KB)"
);
println
(
"Jar "
+
destFile
+
" ("
+
kb
+
" KB)"
);
return
kb
;
return
kb
;
...
@@ -645,18 +630,18 @@ public class BuildBase {
...
@@ -645,18 +630,18 @@ public class BuildBase {
* @param storeOnly if the files should not be compressed
* @param storeOnly if the files should not be compressed
* @param sortBySuffix if the file should be sorted by the file suffix
* @param sortBySuffix if the file should be sorted by the file suffix
*/
*/
protected
void
zip
(
String
destFile
,
List
files
,
String
basePath
,
boolean
storeOnly
,
boolean
sortBySuffix
)
{
protected
void
zip
(
String
destFile
,
File
List
files
,
String
basePath
,
boolean
storeOnly
,
boolean
sortBySuffix
)
{
long
kb
=
zipOrJar
(
destFile
,
files
,
basePath
,
storeOnly
,
sortBySuffix
,
false
);
long
kb
=
zipOrJar
(
destFile
,
files
,
basePath
,
storeOnly
,
sortBySuffix
,
false
);
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
)
{
private
long
zipOrJar
(
String
destFile
,
File
List
files
,
String
basePath
,
boolean
storeOnly
,
boolean
sortBySuffix
,
boolean
jar
)
{
if
(
sortBySuffix
)
{
if
(
sortBySuffix
)
{
// for better compressibility, sort by suffix, then name
// for better compressibility, sort by suffix, then name
Collections
.
sort
(
files
,
new
Comparator
()
{
Collections
.
sort
(
files
,
new
Comparator
<
File
>
()
{
public
int
compare
(
Object
o1
,
Object
o
2
)
{
public
int
compare
(
File
f1
,
File
f
2
)
{
String
p1
=
((
File
)
o1
)
.
getPath
();
String
p1
=
f1
.
getPath
();
String
p2
=
((
File
)
o2
)
.
getPath
();
String
p2
=
f2
.
getPath
();
int
comp
=
getSuffix
(
p1
).
compareTo
(
getSuffix
(
p2
));
int
comp
=
getSuffix
(
p1
).
compareTo
(
getSuffix
(
p2
));
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
comp
=
p1
.
compareTo
(
p2
);
comp
=
p1
.
compareTo
(
p2
);
...
@@ -680,8 +665,7 @@ public class BuildBase {
...
@@ -680,8 +665,7 @@ public class BuildBase {
zipOut
.
setMethod
(
ZipOutputStream
.
STORED
);
zipOut
.
setMethod
(
ZipOutputStream
.
STORED
);
}
}
zipOut
.
setLevel
(
Deflater
.
BEST_COMPRESSION
);
zipOut
.
setLevel
(
Deflater
.
BEST_COMPRESSION
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
for
(
File
file
:
files
)
{
File
file
=
(
File
)
files
.
get
(
i
);
String
fileName
=
file
.
getPath
();
String
fileName
=
file
.
getPath
();
String
entryName
=
removeBase
(
basePath
,
fileName
);
String
entryName
=
removeBase
(
basePath
,
fileName
);
byte
[]
data
=
readFile
(
file
);
byte
[]
data
=
readFile
(
file
);
...
@@ -711,10 +695,10 @@ public class BuildBase {
...
@@ -711,10 +695,10 @@ public class BuildBase {
return
System
.
getProperty
(
"java.specification.version"
);
return
System
.
getProperty
(
"java.specification.version"
);
}
}
private
List
getPaths
(
List
files
)
{
private
List
<
String
>
getPaths
(
File
List
files
)
{
ArrayList
list
=
new
ArrayList
(
files
.
size
()
);
StringList
list
=
new
StringList
(
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++
)
{
for
(
File
f
:
files
)
{
list
.
add
(
((
File
)
files
.
get
(
i
))
.
getPath
());
list
.
add
(
f
.
getPath
());
}
}
return
list
;
return
list
;
}
}
...
@@ -729,8 +713,8 @@ public class BuildBase {
...
@@ -729,8 +713,8 @@ public class BuildBase {
println
(
"Compiling "
+
files
.
size
()
+
" classes"
);
println
(
"Compiling "
+
files
.
size
()
+
" classes"
);
StringList
params
=
new
StringList
();
StringList
params
=
new
StringList
();
params
.
addAll
(
args
);
params
.
addAll
(
args
);
params
.
addAll
(
getPaths
(
fil
terFiles
(
files
,
true
,
".java"
)));
params
.
addAll
(
getPaths
(
fil
es
.
keep
(
".java"
)));
String
[]
array
=
params
.
toA
rray
();
String
[]
array
=
params
.
a
rray
();
int
result
;
int
result
;
PrintStream
old
=
System
.
err
;
PrintStream
old
=
System
.
err
;
try
{
try
{
...
@@ -739,10 +723,10 @@ public class BuildBase {
...
@@ -739,10 +723,10 @@ public class BuildBase {
"Note:"
"Note:"
}));
}));
}
}
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
[]
{
array
})).
intValue
(
);
result
=
(
Integer
)
invoke
(
compile
,
instance
,
new
Object
[]
{
array
}
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
result
=
exec
(
"javac"
,
args
);
result
=
exec
(
"javac"
,
args
);
...
@@ -762,7 +746,7 @@ public class BuildBase {
...
@@ -762,7 +746,7 @@ public class BuildBase {
*/
*/
protected
void
java
(
String
className
,
StringList
args
)
{
protected
void
java
(
String
className
,
StringList
args
)
{
println
(
"Running "
+
className
);
println
(
"Running "
+
className
);
String
[]
array
=
args
==
null
?
new
String
[
0
]
:
args
.
toA
rray
();
String
[]
array
=
args
==
null
?
new
String
[
0
]
:
args
.
a
rray
();
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
[]
{
array
});
invoke
(
main
,
null
,
new
Object
[]
{
array
});
...
@@ -811,8 +795,7 @@ public class BuildBase {
...
@@ -811,8 +795,7 @@ public class BuildBase {
* @param files the name of the files to delete
* @param files the name of the files to delete
*/
*/
protected
void
delete
(
FileList
files
)
{
protected
void
delete
(
FileList
files
)
{
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
for
(
File
f
:
files
)
{
File
f
=
(
File
)
files
.
get
(
i
);
delete
(
f
);
delete
(
f
);
}
}
}
}
...
@@ -820,10 +803,9 @@ public class BuildBase {
...
@@ -820,10 +803,9 @@ public class BuildBase {
private
void
delete
(
File
file
)
{
private
void
delete
(
File
file
)
{
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
if
(
file
.
isDirectory
())
{
if
(
file
.
isDirectory
())
{
String
[]
fileNames
=
file
.
list
();
String
path
=
file
.
getPath
();
String
path
=
file
.
getPath
();
for
(
int
i
=
0
;
i
<
fileNames
.
length
;
i
++
)
{
for
(
String
fileName
:
file
.
list
()
)
{
delete
(
new
File
(
path
,
fileName
s
[
i
]
));
delete
(
new
File
(
path
,
fileName
));
}
}
}
}
if
(!
file
.
delete
())
{
if
(!
file
.
delete
())
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论