You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Herve Boutemy (JIRA)" <ji...@codehaus.org> on 2010/08/13 18:48:33 UTC

[jira] Updated: (ARCHETYPE-110) Maven archetype overwrites parent information

     [ http://jira.codehaus.org/browse/ARCHETYPE-110?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Herve Boutemy updated ARCHETYPE-110:
------------------------------------

    Description: 
When creating a new archetype that I want to use for my projects I ran into some trouble with the created/copied pom.xml.

The archetype pom.xml (\src\main\resources\archetype-resources\pom.xml) looks like this:
{code:xml}
 <project>
  <parent>
		<groupId>group</groupId>
		<artifactId>masterpom</artifactId>
		<version>1.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>group</groupId>
  <artifactId>${artifactId}</artifactId>
  <version>1.0</version>
</project>{code}

When I run my archetype it creates a pom.xml that looks like:
{code:xml}
<project>
  <parent>
  <artifactId>integration</artifactId>
    <groupId>group</groupId>
    <version>1.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>group</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
</project>
{code}
Where "integration" is the name of the pom in the folder that I'm running mvn archetype:create from.
Digging into the source we find in DefaultArchetype.java that processTemplate is indeed reading the parent pom and overwriting whatever was found in the original pom.xml.
Is this really what we want to achieve? It should be possible to keep the parent-pom from the pom.xml in the archetype since it reduces the need for all developers to change their newly created pom.xml.

{code:java}
processTemplates
 if ( parentModel != null )
        {
            Parent parent = new Parent();
            parent.setGroupId( parentModel.getGroupId() );
            if ( parent.getGroupId() == null )
            {
                parent.setGroupId( parentModel.getParent().getGroupId() );
            }
            parent.setArtifactId( parentModel.getArtifactId() );
            parent.setVersion( parentModel.getVersion() );
            if ( parent.getVersion() == null )
            {
                parent.setVersion( parentModel.getParent().getVersion() );
            }
            generatedModel.setParent( parent );
{code}

Two alternative solutions:
 * If the parent-pom is specified in the archetype-pom, don't replace it
 * A parameter that we can supply that will leave the archetype-pom parent setting untouched.

I vote for solution number 1....

  was:
When creating a new archetype that I want to use for my projects I ran into some trouble with the created/copied pom.xml.

The archetype pom.xml (\src\main\resources\archetype-resources\pom.xml) looks like this:

 <project>
  <parent>
		<groupId>group</groupId>
		<artifactId>masterpom</artifactId>
		<version>1.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>group</groupId>
  <artifactId>${artifactId}</artifactId>
  <version>1.0</version>
</project>

When I run my archetype it creates a pom.xml that looks like:

<project>
  <parent>
  <artifactId>integration</artifactId>
    <groupId>group</groupId>
    <version>1.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>group</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
</project>

Where "integration" is the name of the pom in the folder that I'm running mvn archetype:create from.
Digging into the source we find in DefaultArchetype.java that processTemplate is indeed reading the parent pom and overwriting whatever was found in the original pom.xml.
Is this really what we want to achieve? It should be possible to keep the parent-pom from the pom.xml in the archetype since it reduces the need for all developers to change their newly created pom.xml.

<code>
processTemplates
 if ( parentModel != null )
        {
            Parent parent = new Parent();
            parent.setGroupId( parentModel.getGroupId() );
            if ( parent.getGroupId() == null )
            {
                parent.setGroupId( parentModel.getParent().getGroupId() );
            }
            parent.setArtifactId( parentModel.getArtifactId() );
            parent.setVersion( parentModel.getVersion() );
            if ( parent.getVersion() == null )
            {
                parent.setVersion( parentModel.getParent().getVersion() );
            }
            generatedModel.setParent( parent );
</code>

Two alternative solutions:
 * If the parent-pom is specified in the archetype-pom, don't replace it
 * A parameter that we can supply that will leave the archetype-pom parent setting untouched.

I vote for solution number 1....


> Maven archetype overwrites parent information
> ---------------------------------------------
>
>                 Key: ARCHETYPE-110
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-110
>             Project: Maven Archetype
>          Issue Type: Bug
>            Reporter: Peter Liljenberg
>            Priority: Critical
>             Fix For: 2.0-alpha-5
>
>         Attachments: ARCHETYPE-110.patch
>
>
> When creating a new archetype that I want to use for my projects I ran into some trouble with the created/copied pom.xml.
> The archetype pom.xml (\src\main\resources\archetype-resources\pom.xml) looks like this:
> {code:xml}
>  <project>
>   <parent>
> 		<groupId>group</groupId>
> 		<artifactId>masterpom</artifactId>
> 		<version>1.0</version>
>   </parent>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>group</groupId>
>   <artifactId>${artifactId}</artifactId>
>   <version>1.0</version>
> </project>{code}
> When I run my archetype it creates a pom.xml that looks like:
> {code:xml}
> <project>
>   <parent>
>   <artifactId>integration</artifactId>
>     <groupId>group</groupId>
>     <version>1.0</version>
>   </parent>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>group</groupId>
>   <artifactId>test</artifactId>
>   <version>1.0</version>
> </project>
> {code}
> Where "integration" is the name of the pom in the folder that I'm running mvn archetype:create from.
> Digging into the source we find in DefaultArchetype.java that processTemplate is indeed reading the parent pom and overwriting whatever was found in the original pom.xml.
> Is this really what we want to achieve? It should be possible to keep the parent-pom from the pom.xml in the archetype since it reduces the need for all developers to change their newly created pom.xml.
> {code:java}
> processTemplates
>  if ( parentModel != null )
>         {
>             Parent parent = new Parent();
>             parent.setGroupId( parentModel.getGroupId() );
>             if ( parent.getGroupId() == null )
>             {
>                 parent.setGroupId( parentModel.getParent().getGroupId() );
>             }
>             parent.setArtifactId( parentModel.getArtifactId() );
>             parent.setVersion( parentModel.getVersion() );
>             if ( parent.getVersion() == null )
>             {
>                 parent.setVersion( parentModel.getParent().getVersion() );
>             }
>             generatedModel.setParent( parent );
> {code}
> Two alternative solutions:
>  * If the parent-pom is specified in the archetype-pom, don't replace it
>  * A parameter that we can supply that will leave the archetype-pom parent setting untouched.
> I vote for solution number 1....

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira