2012-01-05 62 views
0

在我的java代码中,我想编译一个maven项目(mvn clean install)。我怎么能不做Runtime.getRuntime().exec()编译来自Java的maven项目

+0

哪个版本的maven? 2.2.x或3.0.x? – bmargulies 2012-01-05 13:41:22

回答

3

让我们来看看...

$ which mvn 
/usr/bin/mvn 

$ cat `which mvn` 
... lots of code ending with... 
exec "$JAVACMD" \ 
    $MAVEN_OPTS \ 
    -classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \ 
    "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ 
    "-Dmaven.home=${M2_HOME}" \ 
    ${CLASSWORLDS_LAUNCHER} "[email protected]" 

$ cat `which mvn` | grep CLASSWORLDS 
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 
    ${CLASSWORLDS_LAUNCHER} "[email protected]" 

所以我相信你需要运行org.codehaus.plexus.classworlds.launcher.Launcher.main(new String[] {"clean", "install"})。因人而异。

+0

好吧,我必须找到如何启动这个! – midix 2012-01-05 13:53:03

+0

为你的classpath添加库,并运行'org.codehaus.plexus.classworlds.launcher.Launcher.main(new String [] {“clean”,“install”})''。 – alf 2012-01-05 13:53:46

+0

我在寻找Maven依赖:) – midix 2012-01-05 14:00:30

相关问题