Class MavenCommandRunner
- java.lang.Object
-
- core.support.annotation.helper.utils.MavenCommandRunner
-
public class MavenCommandRunner extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringMAVEN_DOWNLOAD_DESTINATIONstatic StringMAVEN_PATHstatic StringMAVEN_URL
-
Constructor Summary
Constructors Constructor Description MavenCommandRunner()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyURLToFile(URL source, File destination)static voiddownloadMavenIfNotExist()download maven if path is not foundprotected static ArrayList<String>excuteCommand(String command)run command based on windows or mac/linux environmentstatic voidexecuteMavenCommandEmbedded()static StringgetRootDir()get current project root directory, where pom.xml isprotected static booleanisMac()returns true if OS is macprotected static booleanisUnix()returns true if OS is unix or linuxprotected static booleanisWindows()returns true if OS is windowsstatic voidmain(String[] args)process of setting maven: 1.static voidsetMavenPath()Maven home: /usr/local/Cellar/maven/3.6.2/libexec get path of maven from "mvn -version"static voidsetMavenPathFromConfig()set maven path if set from config filestatic FileverifyAndGetMavenHomePath()verify maven bin path exists in maven path or parent folder set maven path to the correct value
-
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
process of setting maven: 1. set maven path from config, if exists 2. use mvn -version shell command to get maven path 3. if not available, download maven into runner/utils/maven folder 4. run maven through maven invoker 5. if maven invoker failed, run using shell command "mvn command"- Parameters:
args-- Throws:
Exception
-
setMavenPathFromConfig
public static void setMavenPathFromConfig()
set maven path if set from config file
-
downloadMavenIfNotExist
public static void downloadMavenIfNotExist() throws Exceptiondownload maven if path is not found
-
copyURLToFile
public static void copyURLToFile(URL source, File destination) throws IOException
- Throws:
IOException
-
setMavenPath
public static void setMavenPath()
Maven home: /usr/local/Cellar/maven/3.6.2/libexec get path of maven from "mvn -version"- Parameters:
results-
-
excuteCommand
protected static ArrayList<String> excuteCommand(String command)
run command based on windows or mac/linux environment- Parameters:
command-- Returns:
-
isMac
protected static boolean isMac()
returns true if OS is mac- Returns:
-
isWindows
protected static boolean isWindows()
returns true if OS is windows- Returns:
-
isUnix
protected static boolean isUnix()
returns true if OS is unix or linux- Returns:
-
verifyAndGetMavenHomePath
public static File verifyAndGetMavenHomePath()
verify maven bin path exists in maven path or parent folder set maven path to the correct value- Returns:
-
getRootDir
public static String getRootDir()
get current project root directory, where pom.xml is- Returns:
-
executeMavenCommandEmbedded
public static void executeMavenCommandEmbedded()
-
-