maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Baptiste MATHUS <bmat...@batmat.net>
Subject Re: Calling versions plugin from code?
Date Thu, 28 Mar 2013 09:06:26 GMT
Hi,
Plugins run in a managed environment, parameters are injected, etc.
So instantiating the mojos manually is not going to working.

You should have a look at maven embedder.

Cheers


2013/3/27 motes motes <mort.motes@gmail.com>

> I am writing a java class where I need to use the
> versions-maven-plugin to basically do what I normally do from command
> line:
>
> mvn versions:set -DnewVersion=1.0.1-SNAPSHOT
>
> Having maven installed locally (and on the path) is not an option. In
> a project I have added:
>
>                 <dependency>
>                         <groupId>org.codehaus.mojo</groupId>
>                         <artifactId>versions-maven-plugin</artifactId>
>                         <version>2.0</version>
>                 </dependency>
>
> an started work on at test:
>
>     SetMojo ss = new SetMojo();
>     Model model = new Model();
>     MavenProject project = new MavenProject(model);
>     project.setFile(new File("test/pom.xml"));
>     ss.setProject(project);
>     try {
>       ss.execute();
>     } catch (MojoExecutionException e) {
>       e.printStackTrace();
>     } catch (MojoFailureException e) {
>       e.printStackTrace();
>     }
>
> But it could be nice with some examples/unit tests that shows how to
> do this the right way. Any recommendations for this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message