Package org.kissweb.builder
Class BuildUtils
java.lang.Object
org.kissweb.builder.BuildUtils
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
buildJava
(String srcPath, String destDir, BuildUtils.LocalDependencies localLibs, org.kissweb.builder.BuildUtils.ForeignDependencies foreignLibs, String additionalSourceRoot) static void
buildJavadoc
(String srcPath, String libPath, String destDir, String overviewFile) Build JavaDocsstatic void
buildWS
(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String dest, String sdir, String service) static String
convertToCamelCase
(String input) Convert a string from dashed notation to camel case notation.static void
Copy file only if missing or earlier date.static void
Copy file regardless of file datestatic void
Copies all files that match a (Java!) regex from one directory to another excluding another (Java!) regex.static void
Copy one directory tree to anotherstatic void
copyTreeForce
(String source, String dest) Copy one directory tree to another.static void
copyTreeRegex
(String source, String dest, String includeRegex) Copy one directory tree to another
The regular expression applies to file names and not directory names.static void
copyTreeRegex
(String source, String dest, String includeRegex, String excludeRegex) Copy one directory tree to another The regular expression applies to file names and not directory names.static void
copyTreeRegex
(String source, String dest, String includeRegex, String excludeRegex, boolean force) Copy one directory tree to another
The regular expression applies to file names and not directory names.static void
Create a JAR filestatic void
createManifest
(String manifest, String mainClass) Create a Java manifest filestatic String
cwd()
static void
static boolean
static String
getcwd()
static String
static String
static void
gunzip and untar a .gz file into the specified directorystatic void
javac
(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String sourcePath, String destPath, String filelist, String additionalSourceRoot) static void
killProcess
(Process proc) static void
makeExecutable
(String file) Set a file to executablestatic void
Creates a directory including any missing parent directories.static void
Move a file from one location to another.static void
printError
(String str) static void
static void
printlnIfVerbose
(String str) static int
readChar()
static void
removeFromCache
(String fname) static void
Remove a file or empty directorystatic void
Remove a file or empty directorystatic void
Delete all files in a directory that match a (Java!) regex.static void
Remove a file or entire directory treestatic Process
run
(boolean useShell, boolean wait, boolean echoCmd, boolean showOutput, String startDir, String cmd) This is the main driving method for all external procedure calls.static Process
runBackground
(String cmd) Run a command in the underlying OS in the background.static void
Run a command in the underlying OS shell in the foreground.static void
Run a command in the underlying OS shell in the foreground.static void
Run a command in the underlying OS in the foreground.static void
Run a command in the underlying OS in the foreground.static void
Works like Unix "tail -F" command.static void
static void
static void
Unpack a JAR file.static void
unJarAllLibs
(String rootDir, BuildUtils.LocalDependencies ld, org.kissweb.builder.BuildUtils.ForeignDependencies fd) static String
writeArgsToFile
(ArrayList<File> lst) Create a command line input file (used in Windows)static String
writeDocArgsToFile
(ArrayList<File> libs, ArrayList<File> lst) static void
writeToFile
(String fname, String txt) Writes a string to file if it doesn't already exist.
-
Field Details
-
isWindows
public static boolean isWindows -
isLinux
public static boolean isLinux -
isMacOS
public static boolean isMacOS -
isSunOS
public static boolean isSunOS -
isHaiku
public static boolean isHaiku -
isFreeBSD
public static boolean isFreeBSD
-
-
Constructor Details
-
BuildUtils
public BuildUtils()
-
-
Method Details
-
build
- Throws:
Exception
-
getJavaPathOnWindows
-
getTomcatPath
-
exists
-
download
-
getcwd
-
printlnIfVerbose
-
println
-
printError
-
move
Move a file from one location to another.- Parameters:
from
- a file name with a pathto
- a file name with a path
-
mkdir
Creates a directory including any missing parent directories.- Parameters:
dname
-
-
copy
Copy file only if missing or earlier date.- Parameters:
source
- filedest
- file or directory
-
copyForce
Copy file regardless of file date- Parameters:
source
- filedest
- file or directory
-
copyRegex
public static void copyRegex(String srcDir, String targetDir, String includeRegex, String excludeRegex, boolean force) Copies all files that match a (Java!) regex from one directory to another excluding another (Java!) regex.
Normally only copies files that have a later date unlessforce
istrue
- Parameters:
srcDir
-targetDir
-includeRegex
- or null if allexcludeRegex
- or null of no exclusionsforce
- if true ignore file dates
-
rmRegex
Delete all files in a directory that match a (Java!) regex.- Parameters:
dirName
-fnameRegex
-
-
copyTree
Copy one directory tree to another- Parameters:
source
-dest
-
-
copyTreeForce
Copy one directory tree to another. Force copy regardless of file dates.- Parameters:
source
-dest
-
-
copyTreeRegex
Copy one directory tree to another
The regular expression applies to file names and not directory names. If includeRegex is null, all files are included.- Parameters:
source
-dest
-includeRegex
- regular expression for files to include or null
-
copyTreeRegex
public static void copyTreeRegex(String source, String dest, String includeRegex, String excludeRegex) Copy one directory tree to another The regular expression applies to file names and not directory names. If includeRegex is null, all files are included. If excludeRegex is null, no files are excluded.- Parameters:
source
-dest
-includeRegex
- regular expression for files to include or nullexcludeRegex
- regular expression for files to exclude or null
-
copyTreeRegex
public static void copyTreeRegex(String source, String dest, String includeRegex, String excludeRegex, boolean force) Copy one directory tree to another
The regular expression applies to file names and not directory names. If includeRegex is null, all files are included. If excludeRegex is null, no files are excluded.- Parameters:
source
-dest
-includeRegex
- regular expression for files to include or nullexcludeRegex
- regular expression for files to exclude or nullforce
- force copy regardless of date
-
rm
Remove a file or empty directory- Parameters:
file
-
-
rmdir
Remove a file or empty directory- Parameters:
file
-
-
rmTree
Remove a file or entire directory tree- Parameters:
name
-
-
writeToFile
Writes a string to file if it doesn't already exist.- Parameters:
fname
-txt
-
-
createManifest
Create a Java manifest file- Parameters:
manifest
-mainClass
-
-
makeExecutable
Set a file to executable- Parameters:
file
-
-
writeArgsToFile
Create a command line input file (used in Windows)- Parameters:
lst
-- Returns:
-
writeDocArgsToFile
-
buildJava
public static void buildJava(String srcPath, String destDir, BuildUtils.LocalDependencies localLibs, org.kissweb.builder.BuildUtils.ForeignDependencies foreignLibs, String additionalSourceRoot) -
buildJavadoc
public static void buildJavadoc(String srcPath, String libPath, String destDir, String overviewFile) Build JavaDocs- Parameters:
srcPath
-libPath
-destDir
-
-
readChar
public static int readChar() -
run
public static Process run(boolean useShell, boolean wait, boolean echoCmd, boolean showOutput, String startDir, String cmd) This is the main driving method for all external procedure calls.
IfuseShell
istrue
than normal shell processing (such as >file and <file) is performed. Otherwiseexec
is called (which is faster).
Ifwait
istrue
than this method waits for the process to complete. Otherwise, it returns immediately with the process object.
IfechoCmd
istrue
then the command being executed will be echoed to stdout.
IfshowOutput
istrue
the output of the process is displayed to stdout. Otherwise, it is silent.
startDir
provides the starting directory for the process. If null, then the current directory is used.
cmd
represents the command (with arguments) to be executed. IfuseShell
is true, thencmd
can also use the shell syntax.- Parameters:
useShell
-wait
-echoCmd
-showOutput
-startDir
-cmd
-- Returns:
- the process either running or completed (depending on wait)
-
runWait
Run a command in the underlying OS in the foreground. Wait till it is done. This command does not support shell processing such as > and < etc.- Parameters:
showOutput
- true if output should be shownstartDir
- starting directory or nullcmd
- the command to execute- See Also:
-
runShell
Run a command in the underlying OS shell in the foreground. Wait till it is done. This command supports all of the shell processing such as > and < etc.- Parameters:
startDir
- starting directory or nullcmd
- the command to execute- See Also:
-
runWait
Run a command in the underlying OS in the foreground.- Parameters:
showOutput
-cmd
-- See Also:
-
runShell
Run a command in the underlying OS shell in the foreground.- Parameters:
cmd
-- See Also:
-
runBackground
Run a command in the underlying OS in the background. Does not wait till it is done. The Process is returned so that it can be killed.- Parameters:
cmd
- the command to execute- Returns:
- the Process
- See Also:
-
killProcess
-
createJar
Create a JAR file- Parameters:
rootDir
- to be jar'ed upjarFile
- name of the JAR file
-
unJar
Unpack a JAR file.
A tag file is also created in order to track the date of the unjar vs. the date of the jar file.- Parameters:
rootDir
- where to unjar the filesjarFile
- the jar file
-
touch
-
touch
-
unJarAllLibs
public static void unJarAllLibs(String rootDir, BuildUtils.LocalDependencies ld, org.kissweb.builder.BuildUtils.ForeignDependencies fd) -
javac
public static void javac(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String sourcePath, String destPath, String filelist, String additionalSourceRoot) -
buildWS
public static void buildWS(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String dest, String sdir, String service) -
gunzip
gunzip and untar a .gz file into the specified directory- Parameters:
fname
-dir
-nPathsElementsToDelete
- number of leading path elements in tar file to eliminate
-
cwd
-
removeFromCache
-
tail
Works like Unix "tail -F" command. It never exits. Useful for continuous display of a log file that may rotate.- Parameters:
fileName
-- Throws:
Exception
-
convertToCamelCase
Convert a string from dashed notation to camel case notation.- Parameters:
input
- The string in dashed notation.- Returns:
- The string in camel case notation.
-