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;
import
java.net.InetSocketAddress
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.Iterator
;
import
java.util.TreeMap
;
import
java.util.Map.Entry
;
import
org.h2.build.code.SwitchSource
;
...
...
@@ -61,15 +61,15 @@ public class Build extends BuildBase {
"ext/derbynet-10.4.2.0.jar"
+
File
.
pathSeparator
+
"ext/postgresql-8.3-603.jdbc3.jar"
+
File
.
pathSeparator
+
"ext/mysql-connector-java-5.1.6.jar"
;
StringList
args
=
new
StringList
(
new
String
[]{
"-Xmx128m"
,
"-cp"
,
cp
,
"org.h2.test.bench.TestPerformance"
}
);
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-init"
,
"-db"
,
"1"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"2"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"3"
,
"-out"
,
"pe.html"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-init"
,
"-db"
,
"4"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"5"
,
"-exit"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"6"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"7"
}
));
exec
(
"java"
,
args
.
plus
(
new
String
[]{
"-db"
,
"8"
,
"-out"
,
"ps.html"
}
));
StringList
args
=
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"org.h2.test.bench.TestPerformance"
);
exec
(
"java"
,
args
.
plus
(
"-init"
,
"-db"
,
"1"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"2"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"3"
,
"-out"
,
"pe.html"
));
exec
(
"java"
,
args
.
plus
(
"-init"
,
"-db"
,
"4"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"5"
,
"-exit"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"6"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"7"
));
exec
(
"java"
,
args
.
plus
(
"-db"
,
"8"
,
"-out"
,
"ps.html"
));
}
/**
...
...
@@ -80,7 +80,7 @@ public class Build extends BuildBase {
delete
(
"docs"
);
mkdir
(
"docs"
);
mkdir
(
"bin"
);
delete
(
getF
iles
(
"."
).
keep
(
"*/Thumbs.db"
));
delete
(
f
iles
(
"."
).
keep
(
"*/Thumbs.db"
));
}
/**
...
...
@@ -104,12 +104,12 @@ public class Build extends BuildBase {
File
.
pathSeparator
+
"ext/lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.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"
,
"-sp"
,
"src/main"
,
"-r"
,
"html,txt"
,
"-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 {
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
;
FileList
files
;
if
(
clientOnly
)
{
files
=
getF
iles
(
"src/main/org/h2/Driver.java"
);
files
.
addAll
(
getF
iles
(
"src/main/org/h2/jdbc"
));
files
.
addAll
(
getF
iles
(
"src/main/org/h2/jdbcx"
));
files
=
f
iles
(
"src/main/org/h2/Driver.java"
);
files
.
addAll
(
f
iles
(
"src/main/org/h2/jdbc"
));
files
.
addAll
(
f
iles
(
"src/main/org/h2/jdbcx"
));
}
else
{
files
=
getF
iles
(
"src/main"
);
files
=
f
iles
(
"src/main"
);
}
StringList
args
=
new
StringList
();
StringList
args
=
args
();
if
(
System
.
getProperty
(
"version"
)
!=
null
)
{
String
bcp
=
System
.
getProperty
(
"bcp"
);
// /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
)
{
args
=
args
.
plus
(
new
String
[]
{
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
}
);
args
=
args
.
plus
(
"-d"
,
"temp"
,
"-sourcepath"
,
"src/main"
,
"-classpath"
,
classpath
);
}
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
);
files
=
getF
iles
(
"src/main/META-INF/services"
);
files
=
f
iles
(
"src/main/META-INF/services"
);
copy
(
"temp"
,
files
,
"src/main"
);
if
(!
clientOnly
)
{
files
=
getF
iles
(
"src/test"
);
files
.
addAll
(
getF
iles
(
"src/tools"
));
args
=
new
StringList
(
new
String
[]
{
"-d"
,
"temp"
,
"-sourcepath"
,
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-classpath"
,
classpath
}
);
files
=
f
iles
(
"src/test"
);
files
.
addAll
(
f
iles
(
"src/tools"
));
args
=
args
(
"-d"
,
"temp"
,
"-sourcepath"
,
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-classpath"
,
classpath
);
javac
(
args
,
files
);
files
=
getF
iles
(
"src/test"
).
files
=
f
iles
(
"src/test"
).
exclude
(
"*.java"
).
exclude
(
"*/package.html"
);
copy
(
"temp"
,
files
,
"src/test"
);
...
...
@@ -189,7 +189,7 @@ public class Build extends BuildBase {
*/
public
void
docs
()
{
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.code.CheckJavadoc"
,
null
);
java
(
"org.h2.build.code.CheckTextFiles"
,
null
);
...
...
@@ -240,21 +240,21 @@ public class Build extends BuildBase {
* Create the h2.zip file and the Windows installer.
*/
public
void
installer
()
{
delete
(
getF
iles
(
"bin"
).
keep
(
"*.jar"
));
delete
(
f
iles
(
"bin"
).
keep
(
"*.jar"
));
jar
();
docs
();
exec
(
"soffice"
,
new
StringList
(
new
String
[]{
"-invisible"
,
"macro:///Standard.Module1.H2Pdf"
}
));
copy
(
"docs"
,
getF
iles
(
"../h2web/h2.pdf"
),
"../h2web"
);
exec
(
"soffice"
,
args
(
"-invisible"
,
"macro:///Standard.Module1.H2Pdf"
));
copy
(
"docs"
,
f
iles
(
"../h2web/h2.pdf"
),
"../h2web"
);
delete
(
"docs/html/onePage.html"
);
FileList
files
=
getF
iles
(
"../h2"
).
keep
(
"../h2/build.*"
);
files
.
addAll
(
getF
iles
(
"../h2/bin"
).
keep
(
"../h2/bin/h2*"
));
files
.
addAll
(
getF
iles
(
"../h2/docs"
));
files
.
addAll
(
getF
iles
(
"../h2/service"
));
files
.
addAll
(
getF
iles
(
"../h2/src"
));
FileList
files
=
f
iles
(
"../h2"
).
keep
(
"../h2/build.*"
);
files
.
addAll
(
f
iles
(
"../h2/bin"
).
keep
(
"../h2/bin/h2*"
));
files
.
addAll
(
f
iles
(
"../h2/docs"
));
files
.
addAll
(
f
iles
(
"../h2/service"
));
files
.
addAll
(
f
iles
(
"../h2/src"
));
zip
(
"../h2web/h2.zip"
,
files
,
"../"
,
false
,
false
);
boolean
installer
=
false
;
try
{
exec
(
"makensis"
,
new
StringList
(
new
String
[]{
"/v2"
,
"src/installer/h2.nsi"
}
));
exec
(
"makensis"
,
args
(
"/v2"
,
"src/installer/h2.nsi"
));
installer
=
true
;
}
catch
(
Error
e
)
{
print
(
"NSIS is not available: "
+
e
);
...
...
@@ -272,7 +272,7 @@ public class Build extends BuildBase {
public
void
jar
()
{
compile
();
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/dev/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
...
...
@@ -295,7 +295,7 @@ public class Build extends BuildBase {
*/
public
void
jarClient
()
{
compile
(
true
,
true
,
false
);
FileList
files
=
getF
iles
(
"temp"
).
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/dev/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
...
...
@@ -317,7 +317,7 @@ public class Build extends BuildBase {
*/
public
void
jarSmall
()
{
compile
(
false
,
false
,
true
);
FileList
files
=
getF
iles
(
"temp"
).
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org/h2/bnf/*"
).
exclude
(
"temp/org/h2/build/*"
).
exclude
(
"temp/org/h2/dev/*"
).
...
...
@@ -342,8 +342,8 @@ public class Build extends BuildBase {
public
void
jarJaqu
()
{
compile
(
true
,
false
,
true
);
manifest
(
"H2 JaQu"
,
""
);
FileList
files
=
getF
iles
(
"temp/org/h2/jaqu"
);
files
.
addAll
(
getF
iles
(
"temp/META-INF/MANIFEST.MF"
));
FileList
files
=
f
iles
(
"temp/org/h2/jaqu"
);
files
.
addAll
(
f
iles
(
"temp/META-INF/MANIFEST.MF"
));
jar
(
"bin/h2jaqu"
+
getJarSuffix
(),
files
,
"temp"
);
}
...
...
@@ -353,12 +353,12 @@ public class Build extends BuildBase {
public
void
javadoc
()
{
delete
(
"docs"
);
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"
,
"-doclet"
,
"org.h2.build.doclet.Doclet"
,
"-classpath"
,
"ext/lucene-core-2.2.0.jar"
})
);
copy
(
"docs/javadoc"
,
getF
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
"ext/lucene-core-2.2.0.jar"
);
copy
(
"docs/javadoc"
,
f
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
}
/**
...
...
@@ -366,8 +366,7 @@ public class Build extends BuildBase {
*/
public
void
javadocImpl
()
{
mkdir
(
"docs/javadocImpl2"
);
javadoc
(
new
StringList
(
new
String
[]
{
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
javadoc
(
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-noindex"
,
"-tag"
,
"h2.resource"
,
...
...
@@ -379,12 +378,11 @@ public class Build extends BuildBase {
File
.
pathSeparator
+
"ext/lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
,
"-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.destDir"
,
"docs/javadocImpl"
);
javadoc
(
new
StringList
(
new
String
[]
{
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
javadoc
(
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-classpath"
,
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
...
...
@@ -393,8 +391,8 @@ public class Build extends BuildBase {
"-subpackages"
,
"org.h2"
,
"-exclude"
,
"org.h2.test.jaqu:org.h2.jaqu"
,
"-package"
,
"-doclet"
,
"org.h2.build.doclet.Doclet"
})
);
copy
(
"docs/javadocImpl"
,
getF
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
"-doclet"
,
"org.h2.build.doclet.Doclet"
);
copy
(
"docs/javadocImpl"
,
f
iles
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
}
private
void
manifest
(
String
title
,
String
mainClassName
)
{
...
...
@@ -420,7 +418,7 @@ public class Build extends BuildBase {
String
pom
=
new
String
(
readFile
(
new
File
(
"src/installer/pom.xml"
)));
pom
=
replaceAll
(
pom
,
"@version@"
,
getVersion
());
writeFile
(
new
File
(
"bin/pom.xml"
),
pom
.
getBytes
());
execScript
(
"mvn"
,
new
StringList
(
new
String
[]
{
execScript
(
"mvn"
,
args
(
"deploy:deploy-file"
,
"-Dfile=bin/h2"
+
getJarSuffix
(),
"-Durl=file:///data/h2database/m2-repo"
,
...
...
@@ -428,7 +426,7 @@ public class Build extends BuildBase {
"-Dversion="
+
getVersion
(),
"-DpomFile=bin/pom.xml"
,
"-DartifactId=h2"
,
"-DgroupId=com.h2database"
}
));
"-DgroupId=com.h2database"
));
}
/**
...
...
@@ -440,22 +438,22 @@ public class Build extends BuildBase {
String
pom
=
new
String
(
readFile
(
new
File
(
"src/installer/pom.xml"
)));
pom
=
replaceAll
(
pom
,
"@version@"
,
"1.0-SNAPSHOT"
);
writeFile
(
new
File
(
"bin/pom.xml"
),
pom
.
getBytes
());
execScript
(
"mvn"
,
new
StringList
(
new
String
[]
{
execScript
(
"mvn"
,
args
(
"install:install-file"
,
"-Dversion=1.0-SNAPSHOT"
,
"-Dfile=bin/h2"
+
getJarSuffix
(),
"-Dpackaging=jar"
,
"-DpomFile=bin/pom.xml"
,
"-DartifactId=h2"
,
"-DgroupId=com.h2database"
}
));
"-DgroupId=com.h2database"
));
}
private
void
resources
(
boolean
clientOnly
,
boolean
basicOnly
)
{
if
(!
clientOnly
)
{
javadoc
(
new
StringList
(
new
String
[]
{
"-sourcepath"
,
"src/main"
,
"org.h2.tools"
,
"-doclet"
,
"org.h2.build.doclet.ResourceDoclet"
})
);
javadoc
(
"-sourcepath"
,
"src/main"
,
"org.h2.tools"
,
"-doclet"
,
"org.h2.build.doclet.ResourceDoclet"
);
}
FileList
files
=
getF
iles
(
"src/main"
).
FileList
files
=
f
iles
(
"src/main"
).
exclude
(
"*.MF"
).
exclude
(
"*.java"
).
exclude
(
"*/package.html"
).
...
...
@@ -491,20 +489,18 @@ public class Build extends BuildBase {
public
void
testNetwork
()
{
try
{
System
.
out
.
println
(
"environment settings:"
);
for
(
Iterator
it
=
new
TreeMap
(
System
.
getProperties
()).
entrySet
().
iterator
();
it
.
hasNext
();
)
{
System
.
out
.
println
(
it
.
next
()
);
for
(
Entry
<
Object
,
Object
>
e
:
new
TreeMap
<
Object
,
Object
>(
System
.
getProperties
()).
entrySet
()
)
{
System
.
out
.
println
(
e
);
}
System
.
out
.
println
();
System
.
out
.
println
(
"localhost:"
+
InetAddress
.
getByName
(
"localhost"
));
InetAddress
[]
addresses
=
InetAddress
.
getAllByName
(
"localhost"
);
for
(
int
i
=
0
;
i
<
addresses
.
length
;
i
++)
{
System
.
out
.
println
(
i
+
":"
+
addresses
[
i
]);
for
(
InetAddress
address
:
InetAddress
.
getAllByName
(
"localhost"
))
{
System
.
out
.
println
(
" "
+
address
);
}
InetAddress
localhost
=
InetAddress
.
getLocalHost
();
System
.
out
.
println
(
"getLocalHost:"
+
localhost
);
addresses
=
InetAddress
.
getAllByName
(
localhost
.
getHostAddress
());
for
(
int
i
=
0
;
i
<
addresses
.
length
;
i
++)
{
System
.
out
.
println
(
i
+
":"
+
addresses
[
i
]);
for
(
InetAddress
address
:
InetAddress
.
getAllByName
(
localhost
.
getHostAddress
()))
{
System
.
out
.
println
(
" "
+
address
);
}
InetAddress
address
=
InetAddress
.
getByName
(
localhost
.
getHostAddress
());
System
.
out
.
println
(
"byName:"
+
address
);
...
...
@@ -569,9 +565,9 @@ public class Build extends BuildBase {
throw
new
Error
(
"h2.ftpPassword not set"
);
}
String
cp
=
"bin"
+
File
.
pathSeparator
+
"temp"
;
exec
(
"java"
,
new
StringList
(
new
String
[]
{
"-Xmx128m"
,
"-cp"
,
cp
,
exec
(
"java"
,
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"-Dh2.ftpPassword="
+
password
,
"org.h2.build.doc.UploadBuild"
}
));
"org.h2.build.doc.UploadBuild"
));
}
/**
...
...
@@ -579,10 +575,10 @@ public class Build extends BuildBase {
*/
public
void
warConsole
()
{
jar
();
copy
(
"temp/WEB-INF"
,
getF
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/WEB-INF/lib"
,
getF
iles
(
"bin/h2"
+
getJarSuffix
()),
"bin"
);
FileList
files
=
getF
iles
(
"temp"
).
exclude
(
"temp/org*"
).
exclude
(
"temp/META-INF*"
);
copy
(
"temp/WEB-INF"
,
f
iles
(
"src/tools/WEB-INF/web.xml"
),
"src/tools/WEB-INF"
);
copy
(
"temp"
,
f
iles
(
"src/tools/WEB-INF/console.html"
),
"src/tools/WEB-INF"
);
copy
(
"temp/WEB-INF/lib"
,
f
iles
(
"bin/h2"
+
getJarSuffix
()),
"bin"
);
FileList
files
=
f
iles
(
"temp"
).
exclude
(
"temp/org*"
).
exclude
(
"temp/META-INF*"
);
jar
(
"bin/h2console.war"
,
files
,
"temp"
);
}
...
...
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
9919c5a0
...
...
@@ -46,15 +46,11 @@ public class BuildBase {
/**
* 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
;
StringList
()
{
super
();
}
StringList
(
String
[]
args
)
{
private
StringList
(
String
...
args
)
{
super
();
addAll
(
Arrays
.
asList
(
args
));
}
...
...
@@ -65,35 +61,22 @@ public class BuildBase {
* @param args the list to add
* @return the new list
*/
public
StringList
plus
(
String
[]
args
)
{
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
[]
toA
rray
()
{
public
String
[]
a
rray
()
{
String
[]
list
=
new
String
[
size
()];
for
(
int
i
=
0
;
i
<
size
();
i
++)
{
list
[
i
]
=
(
String
)
get
(
i
);
list
[
i
]
=
get
(
i
);
}
return
list
;
}
...
...
@@ -103,7 +86,7 @@ public class BuildBase {
/**
* 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
;
...
...
@@ -115,7 +98,7 @@ public class BuildBase {
* @return the new file list
*/
public
FileList
exclude
(
String
pattern
)
{
return
filter
Files
(
this
,
false
,
pattern
);
return
filter
(
false
,
pattern
);
}
/**
...
...
@@ -126,7 +109,39 @@ public class BuildBase {
* @return the new file list
*/
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 {
if
(
args
.
length
==
0
)
{
all
();
}
else
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
String
a
=
args
[
i
];
for
(
String
a
:
args
)
{
if
(
"-quiet"
.
equals
(
a
))
{
quiet
=
true
;
}
else
if
(
a
.
startsWith
(
"-D"
))
{
...
...
@@ -218,15 +232,13 @@ public class BuildBase {
*/
protected
void
projectHelp
()
{
Method
[]
methods
=
getClass
().
getDeclaredMethods
();
Arrays
.
sort
(
methods
,
new
Comparator
()
{
public
int
compare
(
Object
o1
,
Object
o2
)
{
Method
a
=
(
Method
)
o1
,
b
=
(
Method
)
o2
;
Arrays
.
sort
(
methods
,
new
Comparator
<
Method
>()
{
public
int
compare
(
Method
a
,
Method
b
)
{
return
a
.
getName
().
compareTo
(
b
.
getName
());
}
});
out
.
println
(
"Targets:"
);
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
Method
m
=
methods
[
i
];
for
(
Method
m
:
methods
)
{
int
mod
=
m
.
getModifiers
();
if
(!
Modifier
.
isStatic
(
mod
)
&&
Modifier
.
isPublic
(
mod
)
&&
m
.
getParameterTypes
().
length
==
0
)
{
out
.
println
(
m
.
getName
());
...
...
@@ -264,8 +276,8 @@ public class BuildBase {
protected
int
exec
(
String
command
,
StringList
args
)
{
try
{
print
(
command
);
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
size
();
i
++
)
{
print
(
" "
+
a
rgs
.
get
(
i
)
);
for
(
String
a
:
args
)
{
print
(
" "
+
a
);
}
StringList
cmd
=
new
StringList
();
cmd
=
cmd
.
plus
(
command
);
...
...
@@ -273,7 +285,7 @@ public class BuildBase {
cmd
.
addAll
(
args
);
}
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
.
getErrorStream
(),
quiet
?
null
:
out
);
p
.
waitFor
();
...
...
@@ -329,9 +341,9 @@ public class BuildBase {
*/
protected
String
getStaticValue
(
String
className
,
String
methodName
)
{
try
{
Class
clazz
=
Class
.
forName
(
className
);
Method
method
=
clazz
.
getMethod
(
methodName
,
new
Class
[
0
]
);
return
method
.
invoke
(
null
,
new
Object
[
0
]
).
toString
();
Class
<
?
>
clazz
=
Class
.
forName
(
className
);
Method
method
=
clazz
.
getMethod
(
methodName
);
return
method
.
invoke
(
null
).
toString
();
}
catch
(
Exception
e
)
{
throw
new
Error
(
"Can not read value "
+
className
+
"."
+
methodName
+
"()"
,
e
);
}
...
...
@@ -344,13 +356,12 @@ public class BuildBase {
* @param files the list of files to copy
* @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
base
=
new
File
(
baseDir
);
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
);
for
(
File
f
:
files
)
{
File
t
=
new
File
(
target
,
removeBase
(
basePath
,
f
.
getPath
()));
byte
[]
data
=
readFile
(
f
);
mkdirs
(
t
.
getParentFile
());
...
...
@@ -378,8 +389,8 @@ public class BuildBase {
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
]
))
{
for
(
String
l
:
exclude
)
{
if
(
line
.
startsWith
(
l
))
{
print
=
false
;
break
;
}
...
...
@@ -402,7 +413,7 @@ public class BuildBase {
*
* @param args the command line arguments to pass
*/
protected
void
javadoc
(
String
List
args
)
{
protected
void
javadoc
(
String
...
args
)
{
int
result
;
PrintStream
old
=
System
.
out
;
try
{
...
...
@@ -416,12 +427,11 @@ public class BuildBase {
"Building "
}));
}
Class
clazz
=
Class
.
forName
(
"com.sun.tools.javadoc.Main"
);
Method
execute
=
clazz
.
getMethod
(
"execute"
,
new
Class
[]
{
String
[].
class
});
String
[]
array
=
args
.
toArray
();
result
=
((
Integer
)
invoke
(
execute
,
null
,
new
Object
[]
{
array
})).
intValue
();
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
});
}
catch
(
Exception
e
)
{
result
=
exec
(
"javadoc"
,
args
);
result
=
exec
(
"javadoc"
,
args
(
args
)
);
}
finally
{
System
.
setOut
(
old
);
}
...
...
@@ -494,7 +504,6 @@ public class BuildBase {
if
(
sha1Checksum
==
null
)
{
println
(
"SHA1 checksum: "
+
got
);
}
else
{
if
(!
got
.
equals
(
sha1Checksum
))
{
throw
new
Error
(
"SHA1 checksum mismatch"
);
}
...
...
@@ -508,59 +517,35 @@ public class BuildBase {
* @param dir the source directory
* @return the file list
*/
protected
FileList
getF
iles
(
String
dir
)
{
protected
FileList
f
iles
(
String
dir
)
{
FileList
list
=
new
FileList
();
addFiles
(
list
,
new
File
(
dir
));
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"
))
{
// ignore
}
else
if
(
file
.
isDirectory
())
{
String
[]
fileNames
=
file
.
list
();
String
path
=
file
.
getPath
();
for
(
int
i
=
0
;
i
<
fileNames
.
length
;
i
++
)
{
addFiles
(
list
,
new
File
(
path
,
fileName
s
[
i
]
));
for
(
String
fileName
:
file
.
list
()
)
{
addFiles
(
list
,
new
File
(
path
,
fileName
));
}
}
else
{
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
)
{
if
(
path
.
startsWith
(
basePath
))
{
path
=
path
.
substring
(
basePath
.
length
());
...
...
@@ -630,7 +615,7 @@ public class BuildBase {
* @param basePath the base path
* @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
);
println
(
"Jar "
+
destFile
+
" ("
+
kb
+
" KB)"
);
return
kb
;
...
...
@@ -645,18 +630,18 @@ public class BuildBase {
* @param storeOnly if the files should not be compressed
* @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
);
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
)
{
// for better compressibility, sort by suffix, then name
Collections
.
sort
(
files
,
new
Comparator
()
{
public
int
compare
(
Object
o1
,
Object
o
2
)
{
String
p1
=
((
File
)
o1
)
.
getPath
();
String
p2
=
((
File
)
o2
)
.
getPath
();
Collections
.
sort
(
files
,
new
Comparator
<
File
>
()
{
public
int
compare
(
File
f1
,
File
f
2
)
{
String
p1
=
f1
.
getPath
();
String
p2
=
f2
.
getPath
();
int
comp
=
getSuffix
(
p1
).
compareTo
(
getSuffix
(
p2
));
if
(
comp
==
0
)
{
comp
=
p1
.
compareTo
(
p2
);
...
...
@@ -680,8 +665,7 @@ public class BuildBase {
zipOut
.
setMethod
(
ZipOutputStream
.
STORED
);
}
zipOut
.
setLevel
(
Deflater
.
BEST_COMPRESSION
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
File
file
=
(
File
)
files
.
get
(
i
);
for
(
File
file
:
files
)
{
String
fileName
=
file
.
getPath
();
String
entryName
=
removeBase
(
basePath
,
fileName
);
byte
[]
data
=
readFile
(
file
);
...
...
@@ -711,10 +695,10 @@ public class BuildBase {
return
System
.
getProperty
(
"java.specification.version"
);
}
private
List
getPaths
(
List
files
)
{
ArrayList
list
=
new
ArrayList
(
files
.
size
()
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++
)
{
list
.
add
(
((
File
)
files
.
get
(
i
))
.
getPath
());
private
List
<
String
>
getPaths
(
File
List
files
)
{
StringList
list
=
new
StringList
(
);
for
(
File
f
:
files
)
{
list
.
add
(
f
.
getPath
());
}
return
list
;
}
...
...
@@ -729,8 +713,8 @@ public class BuildBase {
println
(
"Compiling "
+
files
.
size
()
+
" classes"
);
StringList
params
=
new
StringList
();
params
.
addAll
(
args
);
params
.
addAll
(
getPaths
(
fil
terFiles
(
files
,
true
,
".java"
)));
String
[]
array
=
params
.
toA
rray
();
params
.
addAll
(
getPaths
(
fil
es
.
keep
(
".java"
)));
String
[]
array
=
params
.
a
rray
();
int
result
;
PrintStream
old
=
System
.
err
;
try
{
...
...
@@ -739,10 +723,10 @@ public class BuildBase {
"Note:"
}));
}
Class
clazz
=
Class
.
forName
(
"com.sun.tools.javac.Main"
);
Method
compile
=
clazz
.
getMethod
(
"compile"
,
new
Class
[]
{
String
[].
class
});
Class
<
?
>
clazz
=
Class
.
forName
(
"com.sun.tools.javac.Main"
);
Method
compile
=
clazz
.
getMethod
(
"compile"
,
new
Class
<
?
>
[]
{
String
[].
class
});
Object
instance
=
clazz
.
newInstance
();
result
=
(
(
Integer
)
invoke
(
compile
,
instance
,
new
Object
[]
{
array
})).
intValue
(
);
result
=
(
Integer
)
invoke
(
compile
,
instance
,
new
Object
[]
{
array
}
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
result
=
exec
(
"javac"
,
args
);
...
...
@@ -762,7 +746,7 @@ public class BuildBase {
*/
protected
void
java
(
String
className
,
StringList
args
)
{
println
(
"Running "
+
className
);
String
[]
array
=
args
==
null
?
new
String
[
0
]
:
args
.
toA
rray
();
String
[]
array
=
args
==
null
?
new
String
[
0
]
:
args
.
a
rray
();
try
{
Method
main
=
Class
.
forName
(
className
).
getMethod
(
"main"
,
new
Class
[]
{
String
[].
class
});
invoke
(
main
,
null
,
new
Object
[]
{
array
});
...
...
@@ -811,8 +795,7 @@ public class BuildBase {
* @param files the name of the files to delete
*/
protected
void
delete
(
FileList
files
)
{
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
File
f
=
(
File
)
files
.
get
(
i
);
for
(
File
f
:
files
)
{
delete
(
f
);
}
}
...
...
@@ -820,10 +803,9 @@ public class BuildBase {
private
void
delete
(
File
file
)
{
if
(
file
.
exists
())
{
if
(
file
.
isDirectory
())
{
String
[]
fileNames
=
file
.
list
();
String
path
=
file
.
getPath
();
for
(
int
i
=
0
;
i
<
fileNames
.
length
;
i
++
)
{
delete
(
new
File
(
path
,
fileName
s
[
i
]
));
for
(
String
fileName
:
file
.
list
()
)
{
delete
(
new
File
(
path
,
fileName
));
}
}
if
(!
file
.
delete
())
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论