You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Elmar Maan <El...@infosupport.com> on 2013/05/13 15:03:12 UTC
Run maven commands from Java code
Dear sir/madame,
I'm Elmar Maan and I'm studying software engineering in Holland.
I'm developing a desktop application, that can easily generate maven modules, inside a Maven project.
This will be a JavaFX application, so I need to call Maven commands from Java code.
This is what I've tried:
First I tried to use the Maven library, which I found in the Maven central repository. (org.apache.maven.archetype: archetype-common 2.2)
I wanted to use the DefaultArchetypeManager the generate a project from an archetype (generateProjectFromArchetype(ArchtypeRequest, request)
This gave me a lot of nullpointer exceptions, because almost all the classes that it uses are interfaces, which are never initialized.
So after three days of struggling with the library, I had no results.
Then I found the maven-embedder library.
This library lets me run the maven command-line commands, like mvn archetype:generate, and works just fine, but I think it's deprecated, because there is no more information on the maven site.
Also the library I used earlier has less or zero documentation or examples.
My question is, What's the best way to call the maven archetype:generate command, so I can generate archetypes from remote catalogs etc.
Is there another library, or am i developing something that is not even possible?
Yours sincerely,
Elmar Maan
student
e-mail: mailto:elmarm@infosupport.com
mobiel: +31 (0)652 290 928
Info Support
Kruisboog 42
3905 TG Veenendaal
tel: +31 (0)318 55 20 20
fax: + 31 (0)318 55 23 55
www.infosupport.com<http://www.infosupport.com/>
Op dit e-mailbericht is de disclaimer van Info Support van toepassing, zie http://www.infosupport.com/disclaimer
RE: Run maven commands from Java code
Posted by Martin Gainty <mg...@hotmail.com>.
attaching sample archetype-catalog.xml
Martin Gainty
______________________________________________
Gelieve niet veranderen of verstoren deze transmissie
From: mgainty@hotmail.com
To: dev@maven.apache.org
Subject: RE: Run maven commands from Java code
Date: Mon, 13 May 2013 20:05:31 -0400
MG>Elmar
MG>If you believe maven-embedder lacks documentation on generating archetypes
MG>perhaps you can gain insight into how archetypes are generated by want reading these URLS
MG>http://maven.apache.org/ref/3.0.2/maven-embedder/team-list.html
MG>http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
MG>to get started on generating archetypes
MG>Take a Look at how to generate the parameters using in maven-archetype-plugin
archetypeArtifactId
String
-
The archetype's artifactId.
archetypeCatalog
String
-
The archetype catalogs to use to build a list and let the user choose from. It is a comma separated list of catalogs. Catalogs use following schemes: •'file://...' witharchetype-catalog.xml automatically appended when pointing to a directory
•'http://...' or 'https://...' with archetype-catalog.xml appended
•'local' which is the shortcut for 'file://~/.m2/archetype-catalog.xml'
•'remote' which is the shortcut for Maven Central repository, ie 'http://repo1.maven.org/maven2'
•'internal' which is an internal catalog
Since 2.0-alpha-5, default value is no longerinternal,local but remote,local. If Maven Central repository catalog file is empty, internalcatalog is used instead.
Default value is: remote,local.
archetypeGroupId
String
-
The archetype's groupId.
archetypeRepository
String
-
The archetype's repository.
archetypeVersion
String
-
The archetype's version.
basedir
File
-
(no description)
filter
String
2.1
Applying some filter on displayed archetypes list: format isartifactId or groupId:artifactId. •org.apache: -> displays all archetypes which contain org.apache in groupId
•:jee or jee -> displays all archetypes which contain jee in artifactId
•org.apache:jee -> displays all archetypes which contain org.apache in groupId AND jee in artifactId
goals
String
-
Additional goals to immediately run on the project created from the archetype.
MG>If you want your user to have a user-selectable list specify catalog
MG>filter would be used to filter the presented archetypes , (jee or jdk come to mind)
MG>goals are another important aspect as each mojo can contain multiple actions (mojo)
MG>interactive would be a good idea to gain feedback from your client (but not if its called by embedder)
I am attaching a sample archetype-catalog.xml for your perusal
MG>This sounds like quite an interesting project you are working on
MG>Please feel free to ping back for questions\comments and or advice
Bedankt,
Martin
______________________________________________
Gelieve niet veranderen of verstoren deze transmissie
> From: ElmarM@infosupport.com
> To: dev@maven.apache.org
> CC: jorisn@infosupport.com
> Subject: Run maven commands from Java code
> Date: Mon, 13 May 2013 13:03:12 +0000
>
> Dear sir/madame,
>
> I'm Elmar Maan and I'm studying software engineering in Holland.
>
> I'm developing a desktop application, that can easily generate maven modules, inside a Maven project.
> This will be a JavaFX application, so I need to call Maven commands from Java code.
>
> This is what I've tried:
> First I tried to use the Maven library, which I found in the Maven central repository. (org.apache.maven.archetype: archetype-common 2.2)
> I wanted to use the DefaultArchetypeManager the generate a project from an archetype (generateProjectFromArchetype(ArchtypeRequest, request)
>
> This gave me a lot of nullpointer exceptions, because almost all the classes that it uses are interfaces, which are never initialized.
>
> So after three days of struggling with the library, I had no results.
> Then I found the maven-embedder library.
> This library lets me run the maven command-line commands, like mvn archetype:generate, and works just fine, but I think it's deprecated, because there is no more information on the maven site.
>
> Also the library I used earlier has less or zero documentation or examples.
>
> My question is, What's the best way to call the maven archetype:generate command, so I can generate archetypes from remote catalogs etc.
> Is there another library, or am i developing something that is not even possible?
>
> Yours sincerely,
>
> Elmar Maan
> student
>
> e-mail: mailto:elmarm@infosupport.com
> mobiel: +31 (0)652 290 928
>
> Info Support
> Kruisboog 42
> 3905 TG Veenendaal
> tel: +31 (0)318 55 20 20
> fax: + 31 (0)318 55 23 55
> www.infosupport.com<http://www.infosupport.com/>
>
>
> Op dit e-mailbericht is de disclaimer van Info Support van toepassing, zie http://www.infosupport.com/disclaimer
RE: Run maven commands from Java code
Posted by Martin Gainty <mg...@hotmail.com>.
MG>Elmar MG>If you believe maven-embedder lacks documentation on generating archetypes
MG>perhaps you can gain insight into how archetypes are generated by want reading these URLS
MG>http://maven.apache.org/ref/3.0.2/maven-embedder/team-list.htmlMG>http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
MG>to get started on generating archetypes
MG>Take a Look at how to generate the parameters using in maven-archetype-plugin archetypeArtifactIdString-The archetype's artifactId.
archetypeCatalogString-The archetype catalogs to use to build a list and let the user choose from. It is a comma separated list of catalogs. Catalogs use following schemes: •'file://...' witharchetype-catalog.xml automatically appended when pointing to a directory
•'http://...' or 'https://...' with archetype-catalog.xml appended
•'local' which is the shortcut for 'file://~/.m2/archetype-catalog.xml'
•'remote' which is the shortcut for Maven Central repository, ie 'http://repo1.maven.org/maven2'
•'internal' which is an internal catalog
Since 2.0-alpha-5, default value is no longerinternal,local but remote,local. If Maven Central repository catalog file is empty, internalcatalog is used instead.
Default value is: remote,local.
archetypeGroupIdString-The archetype's groupId.
archetypeRepositoryString-The archetype's repository.
archetypeVersionString-The archetype's version.
basedirFile-(no description)
filterString2.1Applying some filter on displayed archetypes list: format isartifactId or groupId:artifactId. •org.apache: -> displays all archetypes which contain org.apache in groupId
•:jee or jee -> displays all archetypes which contain jee in artifactId
•org.apache:jee -> displays all archetypes which contain org.apache in groupId AND jee in artifactId
goalsString-Additional goals to immediately run on the project created from the archetype.
MG>If you want your user to have a user-selectable list specify catalog
MG>filter would be used to filter the presented archetypes , (jee or jdk come to mind)
MG>goals are another important aspect as each mojo can contain multiple actions (mojo)
MG>interactive would be a good idea to gain feedback from your client (but not if its called by embedder)I am attaching a sample archetype-catalog.xml for your perusal
MG>This sounds like quite an interesting project you are working on
MG>Please feel free to ping back for questions\comments and or advice Bedankt,
Martin
______________________________________________
Gelieve niet veranderen of verstoren deze transmissie
> From: ElmarM@infosupport.com
> To: dev@maven.apache.org
> CC: jorisn@infosupport.com
> Subject: Run maven commands from Java code
> Date: Mon, 13 May 2013 13:03:12 +0000
>
> Dear sir/madame,
>
> I'm Elmar Maan and I'm studying software engineering in Holland.
>
> I'm developing a desktop application, that can easily generate maven modules, inside a Maven project.
> This will be a JavaFX application, so I need to call Maven commands from Java code.
>
> This is what I've tried:
> First I tried to use the Maven library, which I found in the Maven central repository. (org.apache.maven.archetype: archetype-common 2.2)
> I wanted to use the DefaultArchetypeManager the generate a project from an archetype (generateProjectFromArchetype(ArchtypeRequest, request)
>
> This gave me a lot of nullpointer exceptions, because almost all the classes that it uses are interfaces, which are never initialized.
>
> So after three days of struggling with the library, I had no results.
> Then I found the maven-embedder library.
> This library lets me run the maven command-line commands, like mvn archetype:generate, and works just fine, but I think it's deprecated, because there is no more information on the maven site.
>
> Also the library I used earlier has less or zero documentation or examples.
>
> My question is, What's the best way to call the maven archetype:generate command, so I can generate archetypes from remote catalogs etc.
> Is there another library, or am i developing something that is not even possible?
>
> Yours sincerely,
>
> Elmar Maan
> student
>
> e-mail: mailto:elmarm@infosupport.com
> mobiel: +31 (0)652 290 928
>
> Info Support
> Kruisboog 42
> 3905 TG Veenendaal
> tel: +31 (0)318 55 20 20
> fax: + 31 (0)318 55 23 55
> www.infosupport.com<http://www.infosupport.com/>
>
>
> Op dit e-mailbericht is de disclaimer van Info Support van toepassing, zie http://www.infosupport.com/disclaimer
Re: Run maven commands from Java code
Posted by Robert Scholte <rf...@apache.org>.
Hi,
You should have a look at the Maven Invoker[1]
It is used by the Maven Release Plugin and Maven Invoker Plugin to fire up
a Maven build in a new JVM.
Robert
ps. next time you should the Maven User Mailinglist for such questions.
The Maven Developers list is used for development on Maven itself.
[1] http://maven.apache.org/shared/maven-invoker/
Op Mon, 13 May 2013 15:03:12 +0200 schreef Elmar Maan
<El...@infosupport.com>:
> Dear sir/madame,
>
> I'm Elmar Maan and I'm studying software engineering in Holland.
>
> I'm developing a desktop application, that can easily generate maven
> modules, inside a Maven project.
> This will be a JavaFX application, so I need to call Maven commands from
> Java code.
>
> This is what I've tried:
> First I tried to use the Maven library, which I found in the Maven
> central repository. (org.apache.maven.archetype: archetype-common 2.2)
> I wanted to use the DefaultArchetypeManager the generate a project from
> an archetype (generateProjectFromArchetype(ArchtypeRequest, request)
>
> This gave me a lot of nullpointer exceptions, because almost all the
> classes that it uses are interfaces, which are never initialized.
>
> So after three days of struggling with the library, I had no results.
> Then I found the maven-embedder library.
> This library lets me run the maven command-line commands, like mvn
> archetype:generate, and works just fine, but I think it's deprecated,
> because there is no more information on the maven site.
>
> Also the library I used earlier has less or zero documentation or
> examples.
>
> My question is, What's the best way to call the maven archetype:generate
> command, so I can generate archetypes from remote catalogs etc.
> Is there another library, or am i developing something that is not even
> possible?
>
> Yours sincerely,
>
> Elmar Maan
> student
>
> e-mail: mailto:elmarm@infosupport.com
> mobiel: +31 (0)652 290 928
>
> Info Support
> Kruisboog 42
> 3905 TG Veenendaal
> tel: +31 (0)318 55 20 20
> fax: + 31 (0)318 55 23 55
> www.infosupport.com<http://www.infosupport.com/>
>
>
> Op dit e-mailbericht is de disclaimer van Info Support van toepassing,
> zie http://www.infosupport.com/disclaimer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org