HI all,
Adam , thanks for your comments , it seems like maven-antrun-plugin
could use for this , but still I don't have exact idea how can I use
it with my scenario, here I describe what I have done and what I
expect to do in details
I create a Maven project to create a archetype called "myquickstart"
according to [1] , this is the archetype.xml file for that.
<archetype>
<id>myquickstart</id>
<sources>
<source>src/main/java/SimpleService.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
<resources>
<resource>src/main/webapp/WEB-INF/web.xml</resource>
</resources>
</archetype>
and this is the POM file for "myquickstart" project.
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my</groupId>
<artifactId>myquickstart</artifactId>
<version>1.0.0</version>
<description></description>
</project>
running "mvn install " build and install myquickstart archetype in to
my local repo, then I can use "mvn archetype:generate
-DarchetypeGroupId=my -DarchetypeArtifactId=myquickstart
-DarchetypeVersion=1.0.0 " to create a sample project successfully .
But this will copy source and resources files from archetype to new
project directory as I described in archetype.xml , what I expect to
do is , in addition to these things run a java method automatically
when I use "mvn archetype:generate ........" command as above to
create new projects using myquickstart archetype.
I'm not sure where I have to define Ant task ...? is it possible to
define such custom task within my archetype.xml file ...?
otherwise how can enforce Maven to execute custom task with " "mvn
archetype:generate "..?
Thanks ,
On Tue, Feb 24, 2009 at 10:59 PM, Adam Leggett <[email protected]> wrote:
> 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 <[email protected]>
>> 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: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
> --
> Adam Leggett
> BuildFactory Principal Architect
> UPCO
> Office: 0113 20 10 600
> Direct Line: 0113 20 10 631
> Mobile: 07801 269056
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Sagara Gunathunga
Blog - ssagara.blogspot.com
Web - http://sagaras.awardspace.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]