You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sonja Stocker <so...@gmx.de> on 2010/11/05 13:06:46 UTC

How to set some variables in archetypes?

Hi all,

I´m developing an archetype for out projects. Their general structure is Customer --> Project --> Submodule_1, ..., Submodule_n. For each project the customer and project vary. During the archetype generating I´m able to set the name of the top directory, customer. But after this I have to change the name of the project in the generated Maven project, in all subordinated directories. 

Is there a possibility to use place holder for this name which whould be replaced during the generating of the archetype? I´ve tried it with 
<modules>
    <module>${project}</module>
</modules>
in the upper POM and using archetype.properties where this property was declared: project=PROJECTNAME. But it didn´t work. Any other idea?

Many thanks for every reply.
-- 
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome

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


AW: How to set some variables in archetypes?

Posted by Sonja Stocker <so...@gmx.de>.
Step by step I could resolve some of my problems - thanks for your answers.
My mistake in using the property file was that I used the archetype.properties-property in the goal generate instead of the goal create-from-archetype. After changing this it works fine.

It remains the message: Parent element not overwritten in ...
Can I change any setting so that the parent element will be overwritten?

  

-----Ursprüngliche Nachricht-----
Von: Sonja Stocker [mailto:sonja.stocker@gmx.de] 
Gesendet: Freitag, 5. November 2010 18:39
An: 'Maven Users List'
Betreff: AW: How to set some variables in archetypes?

I think my problem is that I have one hierarchy more than a multi module project usually has. The artifactId in the upper level (customer) will be replaced with the id I enter during the generation. But I also would like to replace the name of the artifactId in the second level - PROJECT. 

In the first step I use the artifactId Template for the top level and PROJECT for the second level. Then I use the goal create-from-project and get my archetype. Here I execute the changes: I replace PROJECT with ${project} in the both POMs. After installing and generating the project with the property archetype.properties I get the new project. The string ${project} hasnt been replaced.

Can the problem stick together with to the message which I get during the generating:
Parent element not overwritten in C:\tmp\archetype\CUSTOMER\PROJECT\pom.xml 
Is there a possibility to force the replacing? The attribute filtered="true" in the archetype descriptor is set.


-----Ursprngliche Nachricht-----
Von: lukewpatterson [mailto:lukewpatterson@gmail.com] 
Gesendet: Freitag, 5. November 2010 16:20
An: users@maven.apache.org
Betreff: Re: How to set some variables in archetypes?



Sonja Stocker wrote:
> 
> Ive tried it with 
> <modules>
>     <module>${project}</module>
> </modules>
> in the upper POM and using archetype.properties where this property was
> declared: project=PROJECTNAME. But it didnt work. 
> 

Just to clarify, are you saying that "${project}" wasn't replaced with the
value of the archetype-gathered property?  Or are you fighting a problem
with folder names matching up with module names?
-- 
View this message in context: http://maven.40175.n5.nabble.com/How-to-set-some-variables-in-archetypes-tp3251703p3251980.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


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


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


AW: How to set some variables in archetypes?

Posted by Sonja Stocker <so...@gmx.de>.
I think my problem is that I have one hierarchy more than a multi module project usually has. The artifactId in the upper level (customer) will be replaced with the id I enter during the generation. But I also would like to replace the name of the artifactId in the second level - PROJECT. 

In the first step I use the artifactId Template for the top level and PROJECT for the second level. Then I use the goal create-from-project and get my archetype. Here I execute the changes: I replace PROJECT with ${project} in the both POMs. After installing and generating the project with the property archetype.properties I get the new project. The string ${project} hasn´t been replaced.

Can the problem stick together with to the message which I get during the generating:
Parent element not overwritten in C:\tmp\archetype\CUSTOMER\PROJECT\pom.xml 
Is there a possibility to force the replacing? The attribute filtered="true" in the archetype descriptor is set.


-----Ursprüngliche Nachricht-----
Von: lukewpatterson [mailto:lukewpatterson@gmail.com] 
Gesendet: Freitag, 5. November 2010 16:20
An: users@maven.apache.org
Betreff: Re: How to set some variables in archetypes?



Sonja Stocker wrote:
> 
> Ive tried it with 
> <modules>
>     <module>${project}</module>
> </modules>
> in the upper POM and using archetype.properties where this property was
> declared: project=PROJECTNAME. But it didnt work. 
> 

Just to clarify, are you saying that "${project}" wasn't replaced with the
value of the archetype-gathered property?  Or are you fighting a problem
with folder names matching up with module names?
-- 
View this message in context: http://maven.40175.n5.nabble.com/How-to-set-some-variables-in-archetypes-tp3251703p3251980.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


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


Re: How to set some variables in archetypes?

Posted by lukewpatterson <lu...@gmail.com>.

Sonja Stocker wrote:
> 
> I´ve tried it with 
> <modules>
>     <module>${project}</module>
> </modules>
> in the upper POM and using archetype.properties where this property was
> declared: project=PROJECTNAME. But it didn´t work. 
> 

Just to clarify, are you saying that "${project}" wasn't replaced with the
value of the archetype-gathered property?  Or are you fighting a problem
with folder names matching up with module names?
-- 
View this message in context: http://maven.40175.n5.nabble.com/How-to-set-some-variables-in-archetypes-tp3251703p3251980.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: How to set some variables in archetypes?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/5 Sonja Stocker <so...@gmx.de>:
> I´m developing an archetype for out projects. Their general structure is Customer --> Project --> Submodule_1, ..., Submodule_n. For each project the customer and project vary. During the archetype generating I´m able to set the name of the top directory, customer. But after this I have to change the name of the project in the generated Maven project, in all subordinated directories.
>
> Is there a possibility to use place holder for this name which whould be replaced during the generating of the archetype? I´ve tried it with
> <modules>
>    <module>${project}</module>
> </modules>
> in the upper POM and using archetype.properties where this property was declared: project=PROJECTNAME. But it didn´t work.
Any other idea?

I suppose that you are using create-from-project goal.
You can have module names automatically replaced when module names are
an "extension" to the name of the project.
For example:
my-project
-- my-project-ear
-- my-project-ejb
-- my-project-war
See here for more information:
http://maven.apache.org/archetype/maven-archetype-plugin/examples/create-multi-module-project.html

Antonio

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