public class BuildBase
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BuildBase.Description
Stores descriptions for methods which can be invoked as build targets.
|
static class |
BuildBase.FileList
A list of files.
|
static class |
BuildBase.StringList
A list of strings.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
javaExecutable
The full path to the executable of the current JRE.
|
protected java.lang.String |
javaToolsJar
The full path to the tools jar of the current JDK.
|
protected boolean |
quiet
If output should be disabled.
|
protected java.io.PrintStream |
sysOut
The output stream (System.out).
|
| Constructor and Description |
|---|
BuildBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
all()
This method is called if no other target is specified in the command
line.
|
protected static BuildBase.StringList |
args(java.lang.String... args)
Create a string list.
|
protected void |
beep()
Emit a beep.
|
protected void |
copy(java.lang.String targetDir,
BuildBase.FileList files,
java.lang.String baseDir)
Copy files to the specified target directory.
|
protected void |
delete(BuildBase.FileList files)
Delete all files in the list.
|
protected void |
delete(java.lang.String dir)
Delete all files in the given directory and all subdirectories.
|
protected void |
download(java.lang.String target,
java.lang.String fileURL,
java.lang.String sha1Checksum)
Download a file if it does not yet exist.
|
protected void |
downloadUsingMaven(java.lang.String target,
java.lang.String group,
java.lang.String artifact,
java.lang.String version,
java.lang.String sha1Checksum)
Download a file if it does not yet exist.
|
protected int |
exec(java.lang.String command,
BuildBase.StringList args)
Execute a program in a separate process.
|
protected int |
execJava(BuildBase.StringList args)
Execute java in a separate process, but using the java executable of the
current JRE.
|
protected int |
execScript(java.lang.String script,
BuildBase.StringList args)
Execute a script in a separate process.
|
protected BuildBase.FileList |
files(java.lang.String dir)
Get the list of files in the given directory and all subdirectories.
|
protected static java.lang.String |
getJavaSpecVersion()
Get the current java specification version (for example, 1.4).
|
protected java.lang.String |
getLocalMavenDir() |
protected static java.lang.String |
getSHA1(byte[] data)
Generate the SHA1 checksum of a byte array.
|
protected static java.lang.String |
getStaticField(java.lang.String className,
java.lang.String fieldName)
Read a final static field in a class using reflection.
|
protected static java.lang.String |
getStaticValue(java.lang.String className,
java.lang.String methodName)
Reads the value from a static method of a class using reflection.
|
protected long |
jar(java.lang.String destFile,
BuildBase.FileList files,
java.lang.String basePath)
Create a jar file.
|
protected void |
java(java.lang.String className,
BuildBase.StringList args)
Call the main method of the given Java class using reflection.
|
protected void |
javac(BuildBase.StringList args,
BuildBase.FileList files)
Compile the files.
|
protected void |
javadoc(java.lang.String... args)
Run a Javadoc task.
|
protected static void |
mkdir(java.lang.String dir)
Create the directory including the parent directories if they don't
exist.
|
protected void |
print(java.lang.String s)
Print a message to the output unless the quiet mode is enabled.
|
protected void |
println(java.lang.String s)
Print a line to the output unless the quiet mode is enabled.
|
protected void |
projectHelp()
Lists all targets (all public methods non-static methods without
parameters).
|
static byte[] |
readFile(java.io.File file)
Read a file.
|
protected static java.lang.String |
replaceAll(java.lang.String s,
java.lang.String before,
java.lang.String after)
Replace each substring in a given string.
|
protected void |
run(java.lang.String... args)
This method should be called by the main method.
|
static void |
writeFile(java.io.File file,
byte[] data)
Create or overwrite a file.
|
protected void |
zip(java.lang.String destFile,
BuildBase.FileList files,
java.lang.String basePath,
boolean storeOnly,
boolean sortBySuffix)
Create a zip file.
|
protected final java.io.PrintStream sysOut
protected boolean quiet
protected final java.lang.String javaExecutable
protected final java.lang.String javaToolsJar
protected void run(java.lang.String... args)
args - the command line parametersprotected void all()
protected void beep()
protected void projectHelp()
protected int execScript(java.lang.String script,
BuildBase.StringList args)
script - the program to runargs - the command line parametersprotected int execJava(BuildBase.StringList args)
args - the command line parameters for the java commandprotected int exec(java.lang.String command,
BuildBase.StringList args)
command - the program to runargs - the command line parametersprotected static java.lang.String getStaticField(java.lang.String className,
java.lang.String fieldName)
className - the name of the classfieldName - the field nameprotected static java.lang.String getStaticValue(java.lang.String className,
java.lang.String methodName)
className - the name of the classmethodName - the field nameprotected void copy(java.lang.String targetDir,
BuildBase.FileList files,
java.lang.String baseDir)
targetDir - the target directoryfiles - the list of files to copybaseDir - the base directoryprotected void javadoc(java.lang.String... args)
args - the command line arguments to passprotected static java.lang.String getSHA1(byte[] data)
data - the byte arrayprotected void downloadUsingMaven(java.lang.String target,
java.lang.String group,
java.lang.String artifact,
java.lang.String version,
java.lang.String sha1Checksum)
target - the target file namegroup - the Maven group idartifact - the Maven artifact idversion - the Maven version idsha1Checksum - the SHA-1 checksum or nullprotected java.lang.String getLocalMavenDir()
protected void download(java.lang.String target,
java.lang.String fileURL,
java.lang.String sha1Checksum)
target - the target file namefileURL - the source url of the filesha1Checksum - the SHA-1 checksum or nullprotected BuildBase.FileList files(java.lang.String dir)
dir - the source directoryprotected static BuildBase.StringList args(java.lang.String... args)
args - the argumentspublic static void writeFile(java.io.File file,
byte[] data)
file - the filedata - the data to writepublic static byte[] readFile(java.io.File file)
file - the fileprotected long jar(java.lang.String destFile,
BuildBase.FileList files,
java.lang.String basePath)
destFile - the target file namefiles - the file listbasePath - the base pathprotected void zip(java.lang.String destFile,
BuildBase.FileList files,
java.lang.String basePath,
boolean storeOnly,
boolean sortBySuffix)
destFile - the target file namefiles - the file listbasePath - the base pathstoreOnly - if the files should not be compressedsortBySuffix - if the file should be sorted by the file suffixprotected static java.lang.String getJavaSpecVersion()
protected void javac(BuildBase.StringList args, BuildBase.FileList files)
args - the command line parametersfiles - the file listprotected void java(java.lang.String className,
BuildBase.StringList args)
className - the class nameargs - the command line parameters to passprotected static void mkdir(java.lang.String dir)
dir - the directory to createprotected void delete(java.lang.String dir)
dir - the name of the directoryprotected void delete(BuildBase.FileList files)
files - the name of the files to deleteprotected static java.lang.String replaceAll(java.lang.String s,
java.lang.String before,
java.lang.String after)
s - the original textbefore - the old substringafter - the new substringprotected void println(java.lang.String s)
s - the text to writeprotected void print(java.lang.String s)
s - the message to write