maven-archetype icon indicating copy to clipboard operation
maven-archetype copied to clipboard

[ARCHETYPE-552] Erroneous Inheritance Cycle Generated By Archetype Plugin

Open jira-importer opened this issue 7 years ago • 1 comments

Scott MacDonald opened ARCHETYPE-552 and commented

When developing a multi module archetype with a root level aggregator pom which inherits from a sibling parent within the project,  the archetype generated project will incorrectly add the aggregator pom as a parent in the sibling parent pom file, causing an inheritance cycle in the generated project.

Attached is a zip file containing a minimal archetype project that demonstrates the behavior.

After running mvn install,   you can inspect target/test-classes/projects/it-basic/project/example-project/example-project-parent/pom.xml  and see that the generated project incorrectly adds the top-level aggregate pom  as a parent in the parent pom causing an inheritance cycle, even though such a parent designation is  not specified in the archetype resources.

 

The exact element that is incorrectly added to target/test-classes/projects/it-basic/project/example-project/example-project-parent/pom.xml is below..

    <parent>     <artifactId>example-project-aggregator</artifactId>     <groupId>com.foo</groupId>     <version>0.0.0</version>   </parent>

 

After the failure, removing the  incorrect parent pom element from the  target/test-classes/projects/it-basic/project/example-project/example-project-parent/pom.xml results in a working  maven project. 

 

 


Affects: 3.0.1

Attachments:

jira-importer avatar Jul 25 '18 18:07 jira-importer

Scott MacDonald commented

Just ran into this exact  issue on maven 3.6.2 with the  bundled archetype plugin, and it also occurs  on latest 3.2.1 archetype  plugin.  Came here to log a bug and and submit a minimal reproducible case, but low and behold, somebody already did...me!! hah! over a year ago!!  Well that saves me little time (not as much as if I remembered I did that 2 hours ago...ha) .

 

Anyway, sure hope somebody can fix this cuz  using a sibling parent with an aggregator pom that inherits from it is a pretty nice pattern. Many people separate aggregation and inheritance this way. I've use this pattern on hundreds of projects and it work well.   I just can't generate working templated projects for them with the archetype plugin.  

A none ideal workaround is to break the inheritance from the aggregator to the parent, and then  specify  version in the aggregator, which isn't ideal  cuz DRY....and I also have call versions:set twice to change them (once on aggregator, once on parent).   Not a huge deal, but it would be wonderful if it archetype didn;t  erroneously add the inheritance  cycle in the first place.

 

 

jira-importer avatar Oct 02 '19 22:10 jira-importer