There are a number of ways to do this. A shell script is one option that
springs to mind. 
For a simple 'pure' Maven approach that doesnt require you to write much
code you could try something like this

A pom (make sure you rename it to bootstrap.xml or some such) - 

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.acme</groupId>
  <artifactId>project-gen</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <build>
       <directory>${genArtifactId}</directory>
       <plugins>
        <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                        <echo message="processing generated project 
${genArtifactId} ..."/>
                </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-archetype-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>create</goal>
            </goals>
            <configuration>
                <groupId>${genGroupId}</groupId>
                <artifactId>${genArtifactId}</artifactId>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Combined with the following command line:

mvn clean process-resources -DgenArtifactId=test-project
-DgenGroupId=com.acme -f bootstrap.xml

Should create you a basic quickstart project in a relative folder named
[genArtifactId]

You will need to invoke your Java 'method' via the antrun plugin.

On Tue, 2009-02-24 at 14:49 +0100, Nick Stolwijk wrote:
> First, the create goal has been deprecated, you can better use the
> generate goal.
> 
> Second, the documentation[1] says that it runs the "generate-sources"
> before executing, so maybe it is possible to add your own plugin
> there. Unfortunately, I don't know how it can be done and I can't find
> any documentation or examples. Can someone more knowledgeable share
> his insights?
> 
> [1] http://maven.apache.org/plugins/maven-archetype-plugin/generate-mojo.html
> 
> Hth,
> 
> Nick Stolwijk
> ~Java Developer~
> 
> Iprofs BV.
> Claus Sluterweg 125
> 2012 WS Haarlem
> www.iprofs.nl
> 
> 
> 
> On Tue, Feb 24, 2009 at 10:47 AM, Sagara Gunathunga <sagar...@gmail.com> 
> wrote:
> > Hi all
> >
> > AFAIK when execute "archetype:create" command , the archetype copy the
> >  folder structure with resources  according to  the archetype's
> > archetype.xml file . I want to execute a custom Java method  in
> > addition to above default behaviour  along  with "archetype:create"
> > command . Is there any way to achieve this ....? if so please update
> > me with some references .
> >
> >
> >
> > Thanks ,
> >
> >
> > Sagara Gunathunga
> >
> > Blog - http://ssagara.blogspot.com
> > Web - http://sagaras.awardspace.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
-- 
Adam Leggett
BuildFactory Principal Architect
UPCO
Office: 0113 20 10 600
Direct Line: 0113 20 10 631
Mobile: 07801 269056

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to