You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by 張旭 <zh...@gmail.com> on 2007/05/29 16:57:49 UTC

invoke maven from java

Hi, everyone. Is there a way to invoking maven from java code? Thanks in
advance.

Re: invoke maven from java

Posted by Henry Isidro <hi...@exist.com>.
?? wrote:
> Hi, everyone. Is there a way to invoking maven from java code? Thanks in
> advance.
>
Hi ??,

Continuum does something like that. You can check out the continuum code 
at https://svn.apache.org/repos/asf/maven/continuum/trunk. Then look at 
continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java

HTH,
Henry

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: invoke maven from java

Posted by Jason van Zyl <ja...@maven.org>.
I just updated the embedder guide so it's accurate now. Note that the  
embedder is only for the code in trunk which is slated for 2.1.
On 31 May 07, at 9:07 PM 31 May 07, 張旭 wrote:

> Thanks to Jiaqi Guo. But I also found maybe maven-embedder can give  
> me some
> help (http://maven.apache.org/guides/mini/guide-embedding-m2.html).
>
> On 5/30/07, Jiaqi Guo <cy...@gmail.com> wrote:
>>
>> Check $M2_HOME/bin/mvn please.
>>
>> ......
>> exec "$JAVACMD" \
>> $MAVEN_OPTS \
>> -classpath "${M2_HOME}"/boot/classworlds-*.jar \
>> "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
>> "-Dmaven.home=${M2_HOME}" \
>> ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
>>
>> So in a typical case, "mvn compile package" will be
>>
>> java -cp $M2_HOME/boot/classworlds-*.jar
>> -Dclassworlds.conf=$M2_HOME/bin/m2.conf -Dmaven.home=$M2_HOME
>> org.codehaus.classworlds.Launcher "compile package"
>>
>> It's an application loaded by classworlds. By digging into  
>> m2.conf, you
>> can find out that the actual main class is  
>> org.apache.maven.cli.MavenCli.
>>
>>
>> Regards
>> -Jiaqi
>>
>> 張旭 wrote:
>> > Hi, everyone. Is there a way to invoking maven from java code?  
>> Thanks in
>> > advance.
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder and PMC Chair, Apache Maven
jason at sonatype dot com
----------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: invoke maven from java

Posted by 張旭 <zh...@gmail.com>.
Thanks to Jiaqi Guo. But I also found maybe maven-embedder can give me some
help (http://maven.apache.org/guides/mini/guide-embedding-m2.html).

On 5/30/07, Jiaqi Guo <cy...@gmail.com> wrote:
>
> Check $M2_HOME/bin/mvn please.
>
> ......
> exec "$JAVACMD" \
> $MAVEN_OPTS \
> -classpath "${M2_HOME}"/boot/classworlds-*.jar \
> "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
> "-Dmaven.home=${M2_HOME}" \
> ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
>
> So in a typical case, "mvn compile package" will be
>
> java -cp $M2_HOME/boot/classworlds-*.jar
> -Dclassworlds.conf=$M2_HOME/bin/m2.conf -Dmaven.home=$M2_HOME
> org.codehaus.classworlds.Launcher "compile package"
>
> It's an application loaded by classworlds. By digging into m2.conf, you
> can find out that the actual main class is org.apache.maven.cli.MavenCli.
>
>
> Regards
> -Jiaqi
>
> 張旭 wrote:
> > Hi, everyone. Is there a way to invoking maven from java code? Thanks in
> > advance.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: invoke maven from java

Posted by Jiaqi Guo <cy...@gmail.com>.
Check $M2_HOME/bin/mvn please.

......
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/classworlds-*.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS

So in a typical case, "mvn compile package" will be

java -cp $M2_HOME/boot/classworlds-*.jar 
-Dclassworlds.conf=$M2_HOME/bin/m2.conf -Dmaven.home=$M2_HOME 
org.codehaus.classworlds.Launcher "compile package"

It's an application loaded by classworlds. By digging into m2.conf, you 
can find out that the actual main class is org.apache.maven.cli.MavenCli.


Regards
-Jiaqi

張旭 wrote:
> Hi, everyone. Is there a way to invoking maven from java code? Thanks in
> advance.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org