RE: calling an archetype goal from embedder

2006-11-27 Thread hermod.opstvedt
Hi

I am running on the latest version of Maven (2.1-SNAPSHOT). Download it from 
SVN, and build it.

Hermod

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 28, 2006 7:53 AM
To: Opstvedt, Hermod
Subject: RE: calling an archetype goal from embedder



thanks a lot, which version of the embeder r u using? it does not compile with 
mine.

hermod.opstvedt wrote:
 
 Hi
 
 Like this:
 
   MavenEmbedder embedder = new MavenEmbedder();
 
   
 embedder.setClassLoader(Thread.currentThread().getContextClassLoader());
 
   MavenEmbedderConsoleLogger logger = new 
 MavenEmbedderConsoleLogger();
   embedder.setLogger(logger); 
 
   try {
 embedder.start();
 } catch (MavenEmbedderException mee) {
 throw new MojoExecutionException(Embedder,mee);
 }
 
   Settings settings;
 try {
 settings = embedder.buildSettings(embedder
   .getUserSettingsPath(null),
 embedder.getGlobalSettingsPath(),
   false, false, false, Boolean.FALSE);
 } catch (SettingsConfigurationException sce) {
 throw new MojoExecutionException(Embedder,sce);
 }
 Properties main_props = new Properties();
   main_props.put(groupId, whatever);
   main_props.put(artifactId, whatever);
   main_props.put(name, whatever);
   main_props.put(version, whatever);
 
   List goals = new ArrayList();
   goals.add(archetype:create);
 
   MavenExecutionRequest request = new 
 DefaultMavenExecutionRequest()
   .setBasedir(new File(c:/Temp)).setGoals(goals)
   .setLocalRepositoryPath(
   
 embedder.getLocalRepositoryPath(settings))
   .setSettings(
   settings)
   .setProperties(main_props)
   .addEventMonitor(
   new DefaultEventMonitor(new 
 ConsoleLogger(
   
 ConsoleLogger.LEVEL_DEBUG, logger)));
 
   try {
 embedder.execute(request);
 } catch (MavenExecutionException mee) {
 throw new MojoExecutionException(Embedder,mee);
 }
 
 Hermod
 
 -Original Message-
 From: Israel Klein [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 21, 2006 10:55 PM
 To: users@maven.apache.org
 Subject: calling an archetype goal from embedder
 
 
 Hello List,
 
 How can I call an archetype:create goal using the embedder? Do I have to
 have a fake pom.xml for that? how can I pass the parameters?
 (archetypeGroupId, for example)
 
 Thanks,
 
 -- 
 Israel Klein
 
 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 
 This email with attachments is solely for the use of the individual or
 entity to whom it is addressed. Please also be aware that DnB NOR 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]
 
 
 
Quoted from: 
http://www.nabble.com/calling-an-archetype-goal-from-embedder-tf2682277s177.html#a7504545


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: calling an archetype goal from embedder

2006-11-23 Thread hermod.opstvedt
Hi

Like this:

MavenEmbedder embedder = new MavenEmbedder();


embedder.setClassLoader(Thread.currentThread().getContextClassLoader());

MavenEmbedderConsoleLogger logger = new 
MavenEmbedderConsoleLogger();
embedder.setLogger(logger); 

try {
embedder.start();
} catch (MavenEmbedderException mee) {
throw new MojoExecutionException(Embedder,mee);
}

Settings settings;
try {
settings = embedder.buildSettings(embedder
.getUserSettingsPath(null), 
embedder.getGlobalSettingsPath(),
false, false, false, Boolean.FALSE);
} catch (SettingsConfigurationException sce) {
throw new MojoExecutionException(Embedder,sce);
}
Properties main_props = new Properties();
main_props.put(groupId, whatever);
main_props.put(artifactId, whatever);
main_props.put(name, whatever);
main_props.put(version, whatever);

List goals = new ArrayList();
goals.add(archetype:create);

MavenExecutionRequest request = new 
DefaultMavenExecutionRequest()
.setBasedir(new File(c:/Temp)).setGoals(goals)
.setLocalRepositoryPath(

embedder.getLocalRepositoryPath(settings))
.setSettings(
settings)
.setProperties(main_props)
.addEventMonitor(
new DefaultEventMonitor(new 
ConsoleLogger(

ConsoleLogger.LEVEL_DEBUG, logger)));

try {
embedder.execute(request);
} catch (MavenExecutionException mee) {
throw new MojoExecutionException(Embedder,mee);
}

Hermod

-Original Message-
From: Israel Klein [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 21, 2006 10:55 PM
To: users@maven.apache.org
Subject: calling an archetype goal from embedder


Hello List,

How can I call an archetype:create goal using the embedder? Do I have to
have a fake pom.xml for that? how can I pass the parameters?
(archetypeGroupId, for example)

Thanks,

-- 
Israel Klein


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that DnB NOR 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]