You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by iiggzz <ih...@yahoo.com> on 2008/04/21 16:50:25 UTC

passing parameters to plugin Archetype

I have created Archetype for my project using link
http://maven.apache.org/guides/mini/guide-creating-archetypes.html. My new
pom looks like 
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>${groupId}</groupId>
  <artifactId>${artifactId}</artifactId>
  <packaging>jar</packaging>
  <version>${version}</version>
  <name>A custom project</name>
  <url>http://www.myorganization.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
When I am creating new project from my Archetype i pass parameters 
${groupId}, ${artifactId} and ${version} using command line and everything
is ok. But I don't know how to pass an additional parameter for example
projectname, so I can use it in my new pom like this:
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>${groupId}</groupId>
  <artifactId>${artifactId}</artifactId>
  <packaging>jar</packaging>
  <version>${version}</version>
  <name>${projectname}</name>
  <url>http://www.myorganization.org</url>
I tried to pass it using command line -Dprojectname = HelloWorld. Didn't
work. I tried to do it using archetype-metadata.xml.
<requiredProperties>
  <requiredProperty key="projectname" /> 
 </requiredProperties>
It supposed to ask me when creating for projectname but it didn't work
either.
-- 
View this message in context: http://www.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963s177p16807963.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by slew77 <sl...@googlemail.com>.
Thanks Martin.  I've looked through all 3 parts, but can't find any details
on passing custom paramters to the archetype.

E.g. in my generated code if I want to be able to substitute ${myProperty},
I can't figure out how to supply this to Maven via the command line, e.g:

mvn archetype:generate -DarchetypeGroupId=%ARCHETYPE_GROUPID%
-DarchetypeArtifactId=%ARCHETYPE_ARTIFACTID%
-DarchetypeVersion=%ARCHETYPE_VERSION% -DgroupId=%GROUPID%
-DartifactId=%MODULE_PREFIX%%MODULE_NAME%
-Dpackage=%PACKAGE_PREFIX%%MODULE_NAME_PACKAGE% -Dversion=%VERSION%
-DmyProperty=test

However, if I use M2Eclipse there is a section for specifying the archetype
parameters including a list of custom name/value parameters.  If I use this
section to specify, e.g. myProperty=test then the project is generated with
this value correctly substituted.

Thanks again,
Steve.



matinh wrote:
> 
> Did you have a look at 
> http://blogs.mikeci.com/2010/01/14/working-with-custom-maven-archetypes-part-1/
> and
> http://blogs.mikeci.com/2010/01/26/working-with-custom-maven-archetypes-part-2/
> and its references!
> 
> hth,
> - martin
> 
> Am Montag, 26. April 2010 10:44:29 schrieb slew77:
>> Anyone have any idea on this?  It's really frustrating me :confused:
>>
>> Thanks,
>> Steve.
>>
>> slew77 wrote:
>> > I'm trying to do the same thing - can someone post instructions, I've
>> > searched everywhere.  I can see it's possible as when I use m2eclipse
>> it
>> > allows me to specify custom properties that are picked up, I just can't
>> > figure out how to do it from the command line.
>> >
>> > Thanks,
>> > Steve.
>> >
>> > iiggzz wrote:
>> >> I found it out! So if anybody has the same problem go ahead and ask
>> me.
>> >> Now I have another problem. I need to specify the path to my files
>> like
>> >> this: ${projectName}-mymodule/myfile.txt so after creation it should
>> >> look like this: helloworld-mymodule.
> 
>  
> 

-- 
View this message in context: http://old.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963p28363473.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by Martin Höller <ma...@xss.co.at>.
Did you have a look at 
http://blogs.mikeci.com/2010/01/14/working-with-custom-maven-archetypes-part-1/
and
http://blogs.mikeci.com/2010/01/26/working-with-custom-maven-archetypes-part-2/
and its references!

hth,
- martin

Am Montag, 26. April 2010 10:44:29 schrieb slew77:
> Anyone have any idea on this?  It's really frustrating me :confused:
>
> Thanks,
> Steve.
>
> slew77 wrote:
> > I'm trying to do the same thing - can someone post instructions, I've
> > searched everywhere.  I can see it's possible as when I use m2eclipse it
> > allows me to specify custom properties that are picked up, I just can't
> > figure out how to do it from the command line.
> >
> > Thanks,
> > Steve.
> >
> > iiggzz wrote:
> >> I found it out! So if anybody has the same problem go ahead and ask me.
> >> Now I have another problem. I need to specify the path to my files like
> >> this: ${projectName}-mymodule/myfile.txt so after creation it should
> >> look like this: helloworld-mymodule.

Re: passing parameters to plugin Archetype

Posted by slew77 <sl...@googlemail.com>.
Anyone have any idea on this?  It's really frustrating me :confused:

Thanks,
Steve.


slew77 wrote:
> 
> I'm trying to do the same thing - can someone post instructions, I've
> searched everywhere.  I can see it's possible as when I use m2eclipse it
> allows me to specify custom properties that are picked up, I just can't
> figure out how to do it from the command line.
> 
> Thanks,
> Steve.
> 
> 
> iiggzz wrote:
>> 
>> I found it out! So if anybody has the same problem go ahead and ask me.
>> Now I have another problem. I need to specify the path to my files like
>> this: ${projectName}-mymodule/myfile.txt so after creation it should look
>> like this: helloworld-mymodule.
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963p28362249.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by slew77 <sl...@googlemail.com>.
I'm trying to do the same thing - can someone post instructions, I've
searched everywhere.  I can see it's possible as when I use m2eclipse it
allows me to specify custom properties that are picked up, I just can't
figure out how to do it from the command line.

Thanks,
Steve.


iiggzz wrote:
> 
> I found it out! So if anybody has the same problem go ahead and ask me.
> Now I have another problem. I need to specify the path to my files like
> this: ${projectName}-mymodule/myfile.txt so after creation it should look
> like this: helloworld-mymodule.
> 

-- 
View this message in context: http://old.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963p28341796.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by mirekSz <m....@gmail.com>.


Olivier Dehon-2 wrote:
> 
> 
> For files and directory names, you can use the syntax in your archetype
> file structure:
> __rootArtifactId__-mytest.txt
> 
> The archetype:generate will replace the double-underscore with the
> actual value of rootArtifactId.
> 
> NB: I have had problems recently  with that structure when there are
> multiple instances of that syntax in one given path:
> 
> proj/__rootArtifactId__Module1/src/main/resources/__rootArtifactId__Module1.properties
> 
> the folder name at the top of the hierarchy gets interpolated correctly,
> but not the properties file below in the structure.
> 
> I have seen a few JIRAs that seem related to that but not exactly that
> particular issue ( http://jira.codehaus.org/browse/ARCHETYPE-191 )
> I can forge a use/test case illustrating the issue and create a new JIRA
> if other users have been facing the same issue.
> 
> -Olivier
> 
> On Sat, 2010-01-09 at 05:23 -0800, mirekSz wrote:
> 
>> I hava the same problems. Could you explain how to resolve it
>> 
>> Best regards
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 
Thanks for replay
How passing parameters to plugin Archetype -Dname=project name dosen't work

-- 
View this message in context: http://old.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963p27091119.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by Olivier Dehon <od...@gmail.com>.
For files and directory names, you can use the syntax in your archetype
file structure:
__rootArtifactId__-mytest.txt

The archetype:generate will replace the double-underscore with the
actual value of rootArtifactId.

NB: I have had problems recently  with that structure when there are
multiple instances of that syntax in one given path:

proj/__rootArtifactId__Module1/src/main/resources/__rootArtifactId__Module1.properties

the folder name at the top of the hierarchy gets interpolated correctly,
but not the properties file below in the structure.

I have seen a few JIRAs that seem related to that but not exactly that
particular issue ( http://jira.codehaus.org/browse/ARCHETYPE-191 )
I can forge a use/test case illustrating the issue and create a new JIRA
if other users have been facing the same issue.

-Olivier

On Sat, 2010-01-09 at 05:23 -0800, mirekSz wrote:

> I hava the same problems. Could you explain how to resolve it
> 
> Best regards
> 



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


Re: passing parameters to plugin Archetype

Posted by mirekSz <m....@gmail.com>.
Hi,
I hava the same problems. Could you explain how to resolve it

Best regards

-- 
View this message in context: http://old.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963p27088665.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by iiggzz <ih...@yahoo.com>.
I did it too. Thanks for your attention.

iiggzz wrote:
> 
> I found it out! So if anybody has the same problem go ahead and ask me.
> Now I have another problem. I need to specify the path to my files like
> this: ${projectName}-mymodule/myfile.txt so after creation it should look
> like this: helloworld-mymodule.
> 

-- 
View this message in context: http://www.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963s177p16850915.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: passing parameters to plugin Archetype

Posted by iiggzz <ih...@yahoo.com>.
I found it out! So if anybody has the same problem go ahead and ask me. Now I
have another problem. I need to specify the path to my files like this:
${projectName}-mymodule/myfile.txt so after creation it should look like
this: helloworld-mymodule.
-- 
View this message in context: http://www.nabble.com/passing-parameters-to-plugin-Archetype-tp16807963s177p16833971.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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