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]