Package org.kissweb.builder
Class BuildUtils
java.lang.Object
org.kissweb.builder.BuildUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidbuildJava(String srcPath, String destDir, BuildUtils.LocalDependencies localLibs, org.kissweb.builder.BuildUtils.ForeignDependencies foreignLibs, String additionalSourceRoot) static voidbuildJavadoc(String srcPath, String libPath, String destDir, String overviewFile) Build JavaDocsstatic voidbuildWS(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String dest, String sdir, String service) static StringconvertToCamelCase(String input) Convert a string from dashed notation to camel case notation.static voidCopy file only if missing or earlier date.static voidCopy file regardless of file datestatic voidCopies all files that match a (Java!) regex from one directory to another excluding another (Java!) regex.static voidCopy one directory tree to anotherstatic voidcopyTreeForce(String source, String dest) Copy one directory tree to another.static voidcopyTreeRegex(String source, String dest, String includeRegex) Copy one directory tree to another
The regular expression applies to file names and not directory names.static voidcopyTreeRegex(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 voidcopyTreeRegex(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 voidCreate a JAR filestatic voidcreateManifest(String manifest, String mainClass) Create a Java manifest filestatic Stringcwd()static voidstatic booleanstatic Stringgetcwd()static Stringstatic Stringstatic voidgunzip and untar a .gz file into the specified directorystatic voidjavac(BuildUtils.LocalDependencies ldep, org.kissweb.builder.BuildUtils.ForeignDependencies fdep, String sourcePath, String destPath, String filelist, String additionalSourceRoot) static voidkillProcess(Process proc) static voidmakeExecutable(String file) Set a file to executablestatic voidCreates a directory including any missing parent directories.static voidMove a file from one location to another.static voidprintError(String str) static voidstatic voidprintlnIfVerbose(String str) static intreadChar()static voidremoveFromCache(String fname) static voidRemove a file or empty directorystatic voidRemove a file or empty directorystatic voidDelete all files in a directory that match a (Java!) regex.static voidRemove a file or entire directory treestatic Processrun(boolean useShell, boolean wait, boolean echoCmd, boolean showOutput, String startDir, String cmd) This is the main driving method for all external procedure calls.static ProcessrunBackground(String cmd) Run a command in the underlying OS in the background.static voidRun a command in the underlying OS shell in the foreground.static voidRun a command in the underlying OS shell in the foreground.static voidRun a command in the underlying OS in the foreground.static voidRun a command in the underlying OS in the foreground.static voidWorks like Unix "tail -F" command.static voidstatic voidstatic voidUnpack a JAR file.static voidunJarAllLibs(String rootDir, BuildUtils.LocalDependencies ld, org.kissweb.builder.BuildUtils.ForeignDependencies fd) static StringwriteArgsToFile(ArrayList<File> lst) Create a command line input file (used in Windows)static StringwriteDocArgsToFile(ArrayList<File> libs, ArrayList<File> lst) static voidwriteToFile(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 unlessforceistrue- 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.
IfuseShellistruethan normal shell processing (such as >file and <file) is performed. Otherwiseexecis called (which is faster).
Ifwaitistruethan this method waits for the process to complete. Otherwise, it returns immediately with the process object.
IfechoCmdistruethen the command being executed will be echoed to stdout.
IfshowOutputistruethe output of the process is displayed to stdout. Otherwise, it is silent.
startDirprovides the starting directory for the process. If null, then the current directory is used.
cmdrepresents the command (with arguments) to be executed. IfuseShellis true, thencmdcan 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.
-