Hi Thank you for the tip. However the ting is that the functionality that I am after actualy presumes that there does not exist any pom. Your sample does require a pom.
I was hoping to create an archetype that creates a complete project setup for new developers coming into any of our projects. As far as I have been able to find out, the Maven 2 archetypes are "stupid" in the sense that there does no seem to be any way have them execute a mojo as part of the lifecycle. They only create the directory structures and copy in the predefines resources. So unless someone can tell me otherwise I'll have to stick with the newest embedder and create a batchfile/shellscript that runs a configurable set set of goals. Not quite what I was hoping for. Maybe I should enter en RFE for the archetype architecture to enable it to run goals? Hermod -----Original Message----- From: Rinku [mailto:[EMAIL PROTECTED] Sent: Monday, May 29, 2006 10:19 PM To: Maven Developers List Subject: Re: creating a new project with the MavenEmbedder Hi Hermod, Coincidently, there was a thread on maven-users list about delegating goal to another mojo (see yesterday's posts). I have posted a similar code snippet there that uses embedder, you might want give it a try if you want to stick to released version. HTH, Rahul ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <dev@maven.apache.org> Sent: Tuesday, May 30, 2006 12:34 AM Subject: RE: creating a new project with the MavenEmbedder Hi Ok, I'll get it from SVN and compile it. Thnx Hermod -----Original Message----- From: Ovidio Mallo [mailto:[EMAIL PROTECTED] Sent: Monday, May 29, 2006 1:58 PM To: Maven Developers List Subject: Re: creating a new project with the MavenEmbedder Hi Hermod! The class compiles against the current 2.1-SNAPSHOT version. The previous versions 2.0.3 and 2.0.4 seem to have a somewhat different API, so it will not compile with those. Prior to my original post on this subject, I was trying to get the whole thing working with the version 2.0.4, but failed, so I'm not sure whether it is possible to achieve the same thing with the old API. Unfortunately, since the version 2.1-SNAPSHOT is probably not on the central repository, you probably have to compile it from the sources. That's at least what I did. Hope that helps! Best regards, Ovidio [EMAIL PROTECTED] wrote: > Hi > > Which version of the embedder is this? I get errors on the methods: > getUserSettingsPath and getGlobalSettingsPath - No such methods in the > Maven embedder (2.0.3). > > Hermod > > -----Original Message----- > From: Ovidio Mallo [mailto:[EMAIL PROTECTED] > Sent: Sunday, May 28, 2006 12:36 PM > To: Maven Developers List > Subject: Re: creating a new project with the MavenEmbedder > > > Hi, > > Thanks a lot, Kenney, for your explanation and code snippet! This is > exactly what I was looking for! I have filled in the tiny missing > details in your sample code to build up a working example which you > can find below. Just in case anyone else is interested in it. > > One thing I noticed is that the example should not be run from > within a directory containing a pom.xml file since, otherwise, > this project file is interpreted as being the parent model file! > > Well, again, thanks a lot! > > Regards, > Ovidio > > > ================================================================================ > > public class ProjectCreator { > > public static void main(String[] args) throws Exception { > MavenEmbedder embedder = new MavenEmbedder(); > > embedder.setClassLoader( > Thread.currentThread().getContextClassLoader() ); > > embedder.setLogger( new MavenEmbedderConsoleLogger() ); > > embedder.start(); > > Settings settings = embedder.buildSettings( > embedder.getUserSettingsPath( null ), > embedder.getGlobalSettingsPath(), > false, > false, > false, > Boolean.FALSE ); > > Properties properties = new Properties(); > properties.put( "groupId", "net.sytes.meco" ); > properties.put( "artifactId", "new_project" ); > > MavenExecutionRequest request = new > DefaultMavenExecutionRequest() > .setBasedir( new File( "/tmp" ) ) > .setGoals( Arrays.asList( new String[] { > "archetype:create" } ) ) > .setLocalRepositoryPath( embedder.getLocalRepositoryPath( > settings ) ) > .setSettings( settings ) > .setProperties( properties ) > .addEventMonitor( > new DefaultEventMonitor( > new ConsoleLogger( ConsoleLogger.LEVEL_DISABLED, > "logger" ) ) ); > > embedder.execute( request ); > } > } > > ================================================================================ > > > Kenney Westerhof wrote: > > On Sat, 27 May 2006, Ovidio Mallo wrote: > > > > Hi, > > > > Well, currently running archetype:create seems the simplest way to > me. > > The embedder is primarily meant to build projects, not to create > them. > > > > You might want to take a look at the maven-cli project. Some > plugins, like > > archetype, don't require an existing pom.xml. > > > > A sequence like this (more or less) should work for you: > > > > MavenEmbedder embedder = new MavenEmbedder(); > > > > embedder.start(); > > > > Settings settings = embedder.buildSettings( > > embedder.getUserSettingsPath( null ), > > embedder.getGlobalSettingsPath(), > > false, > > false, > > false, > > false ); > > > > Properties properties = new Properties(); > > // set archetype parameters in properties > > > > MavenExecutionRequest request = new DefaultMavenExecutionRequest() > > .setBasedir(..) > > .setGoals( Arrays.asList( new String[] { "archetype.create" } ) > > .setLocalRepositoryPath( embedder.getLocalRepositoryPath( > settings ) > > .setSettings( settings ) > > .setProperties( properties ); > > > > embedder.execute( request ); > > > > .. and we don't set a pom file here. > > > > Good luck! > > > > -- Kenney > > > > > > > >>Hi everyone! > >> > >>I just wanted to ask whether there is a clean way to create a new > maven > >>project using the MavenEmbedder API. It is of course possible to > >>execute the "archetype:create" goal but the API seems to always > >>require that you already pass in an existing project (at least > >>an existing pom.xml file) in order to execute any goal. > >>I think such a feature would be quite handy for other projects > >>such as the Maven2 Eclipse Plugin. > >> > >>Thanks in advance for any help! > >> > >>Regards, > >> Ovidio > >> > > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > > > > > > -- > > Kenney Westerhof > > http://www.neonics.com > > GPG public key: http://www.gods.nl/~forge/kenneyw.key > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * > > This email with attachments is solely for the use of the individual or > entity to whom it is addressed. Please also be aware that the DnB NOR > Group > cannot accept any payment orders or other legally binding > correspondence with > customers as a part of an email. > > This email message has been virus checked by the anti virus programs > used > in the DnB NOR Group. > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]