Package io.openliberty.tools.ant
Class AbstractTask
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- io.openliberty.tools.ant.AbstractTask
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
CleanTask,DeployTask,FeatureManagerTask,InstallLibertyTask,ServerTask,SpringBootUtilTask,UndeployTask
public abstract class AbstractTask extends org.apache.tools.ant.Task
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDEFAULT_LOG_FILEprotected static StringDEFAULT_SERVERprotected FileinstallDirprotected static booleanisWindowsprotected static ResourceBundlemessagesprotected static StringosNameprotected FileoutputDirprotected ProcessBuilderprocessBuilderprotected Stringrefprotected FileserverConfigDirprotected StringserverNameprotected FileserverOutputDirprotected FileuserDirprotected static StringWLP_OUTPUT_DIR_VARprotected static StringWLP_USER_DIR_VAR
-
Constructor Summary
Constructors Constructor Description AbstractTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckReturnCode(Process p, String commandLine, int... expectedExitCodes)voidcheckReturnCodeAndError(Process p, String commandLine, int expectedExitCode, int allowedExitCode, String allowedErrorMessage)intcountStringOccurrencesInFile(String regexp, File fileToSearch)Searches the given file for the given regular expression, and returns the number of times it occurs.StringfindStringInFile(String regexp, File fileToSearch)Searches the given file for the given regular expression.List<String>findStringsInFile(String regexp, File fileToSearch)Searches the given file for the given regular expression.protected StringgetFileName(String fileName)FilegetInstallDir()FilegetLogFile()protected StringgetMessage(String key, Object... args)FilegetOutputDir()StringgetRef()protected intgetReturnCode(Process p, String commandLine)StringgetServerName()FilegetServerOutputDir()FilegetUserDir()protected voidinitTask()voidsendErrorInvokeCommand(String commandLine, int returnCode, int... expectedExitCodes)voidsetInstallDir(File installDir)voidsetOutputDir(File outputDir)voidsetRef(String ref)voidsetServerName(String serverName)voidsetUserDir(File userDir)protected voidstopServer(String timeout)StringwaitForStringInLog(String regexp, long timeout, File outputFile)Check for a number of strings in a potentially remote fileStringwaitForUpdatedStringInLog(String regexp, long timeout, File outputFile, int previousOccurrences)Wait until the number of occurrences of the regular expression in the file increases above the given number of previous occurrences.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Field Detail
-
installDir
protected File installDir
-
userDir
protected File userDir
-
outputDir
protected File outputDir
-
serverConfigDir
protected File serverConfigDir
-
serverOutputDir
protected File serverOutputDir
-
serverName
protected String serverName
-
ref
protected String ref
-
osName
protected static String osName
-
isWindows
protected static boolean isWindows
-
processBuilder
protected ProcessBuilder processBuilder
-
DEFAULT_SERVER
protected static final String DEFAULT_SERVER
- See Also:
- Constant Field Values
-
DEFAULT_LOG_FILE
protected static final String DEFAULT_LOG_FILE
- See Also:
- Constant Field Values
-
WLP_USER_DIR_VAR
protected static final String WLP_USER_DIR_VAR
- See Also:
- Constant Field Values
-
WLP_OUTPUT_DIR_VAR
protected static final String WLP_OUTPUT_DIR_VAR
- See Also:
- Constant Field Values
-
messages
protected static final ResourceBundle messages
-
-
Method Detail
-
initTask
protected void initTask()
-
getInstallDir
public File getInstallDir()
-
setInstallDir
public void setInstallDir(File installDir)
-
getUserDir
public File getUserDir()
-
setUserDir
public void setUserDir(File userDir)
-
getOutputDir
public File getOutputDir()
-
setOutputDir
public void setOutputDir(File outputDir)
-
getServerOutputDir
public File getServerOutputDir()
-
getServerName
public String getServerName()
- Returns:
- the serverName
-
setServerName
public void setServerName(String serverName)
- Parameters:
serverName- the serverName to set
-
getLogFile
public File getLogFile()
-
getRef
public String getRef()
- Returns:
- the ref
-
setRef
public void setRef(String ref)
- Parameters:
ref- the ref to set
-
getReturnCode
protected int getReturnCode(Process p, String commandLine) throws InterruptedException
- Throws:
InterruptedException
-
checkReturnCode
public void checkReturnCode(Process p, String commandLine, int... expectedExitCodes) throws InterruptedException
- Throws:
InterruptedException
-
checkReturnCodeAndError
public void checkReturnCodeAndError(Process p, String commandLine, int expectedExitCode, int allowedExitCode, String allowedErrorMessage) throws InterruptedException
- Throws:
InterruptedException
-
sendErrorInvokeCommand
public void sendErrorInvokeCommand(String commandLine, int returnCode, int... expectedExitCodes)
-
waitForStringInLog
public String waitForStringInLog(String regexp, long timeout, File outputFile)
Check for a number of strings in a potentially remote file- Parameters:
regexp- a regular expression to search fortimeout- a timeout, in millisecondsoutputFile- file to check- Returns:
- line that matched the regexp
-
findStringInFile
public String findStringInFile(String regexp, File fileToSearch)
Searches the given file for the given regular expression.- Parameters:
regexp- a regular expression (or just a text snippet) to search forfileToSearch- the file to search- Returns:
- The first line which includes the pattern, or null if the pattern isn't found or if the file doesn't exist
-
findStringsInFile
public List<String> findStringsInFile(String regexp, File fileToSearch)
Searches the given file for the given regular expression.- Parameters:
regexp- a regular expression (or just a text snippet) to search forfileToSearch- the file to search- Returns:
- List of lines which includes the pattern, or null if the pattern isn't found or if the file doesn't exist
-
countStringOccurrencesInFile
public int countStringOccurrencesInFile(String regexp, File fileToSearch)
Searches the given file for the given regular expression, and returns the number of times it occurs.- Parameters:
regexp- a regular expression (or just a text snippet) to search forfileToSearch- the file to search- Returns:
- the number of occurrences of the regular expression
-
waitForUpdatedStringInLog
public String waitForUpdatedStringInLog(String regexp, long timeout, File outputFile, int previousOccurrences)
Wait until the number of occurrences of the regular expression in the file increases above the given number of previous occurrences.- Parameters:
regexp- a regular expression to search fortimeout- a timeout, in millisecondsoutputFile- file to checkpreviousOccurrences- . the previous number of occurrences of the regular expression- Returns:
- updated line that matched the regexp
-
stopServer
protected void stopServer(String timeout)
-
-