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

[ARCHETYPE-649] "[WARNING] CP Don't override file" when generating archetype with 3.2.1

Open jira-importer opened this issue 2 years ago • 3 comments

Wolfgang Knauf opened ARCHETYPE-649 and commented

I do some maintenance work on the "wildfly-jakartaee-ear-archetype". After updating "maven-archetype-plugin" to 3.2.1, there are two warnings printed when creating a project from the archetype.

[WARNING] Don't override file ...\multi\project\multi\web\src\test\java\foo\bar\multi [WARNING] CP Don't override file ...\multi\project\multi\web\src\main\webapp  

I think the problem depends on the archetype-plugin version that creates the archetype JAR. Attached are the jar files from my local repository. One is created with archetype-plugin 3.1.2, the other with 3.2.1.

[^wildfly-jakartaee-ear-archetype-30.0.0.Final-SNAPSHOT_321.jar]

[^wildfly-jakartaee-ear-archetype-30.0.0.Final-SNAPSHOT_312.jar]

Note the size difference of the two jar files.

When creating a project from the archetype, the message appears with both 3.1.2 and 3.2.1, if the archetype jar was created with 3.2.1. It does not appear when the archetype jar was created with the 3.1.2 plugin.

 

Debug logging during generating of the project from the archetype seems to point me to the reason: with 3.2.1, the jar file contains a lot of entries for the directories. With 3.1.2, there are only entries for "real" files.

This seems to cause duplicates with the fileSets in "archetype-metadata.xml"

 

Here is the log when the archetype jar was created with 3.1.2:

 

[DEBUG] getFilesetArchetypeResources( "C:\Users\USERNAME\.m2\repository\org\wildfly\archetype\wildfly-jakartaee-ear-archetype\30.0.0.Final-SNAPSHOT\wildfly-jakartaee-ear-archetype-30.0.0.Final-SNAPSHOT.jar" ) [DEBUG]   - found resource (archetype-resources/)ear/pom.xml [DEBUG]   - found resource (archetype-resources/)ejb/pom.xml [DEBUG]   - found resource (archetype-resources/)ejb/src/main/resources/META-INF/persistence.xml [DEBUG]   - found resource (archetype-resources/)ejb/src/test/resources/arquillian.xml [DEBUG]   - found resource (archetype-resources/)pom.xml [DEBUG]   - found resource (archetype-resources/)README.txt [DEBUG]   - found resource (archetype-resources/)web/pom.xml [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/WEB-INF/beans.xml [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/WEB-INF/faces-config.xml [DEBUG]   - found resource (archetype-resources/)web/src/test/java/test/SampleIT.java [DEBUG]   - found resource (archetype-resources/)web/src/test/resources/arquillian.xml [DEBUG]   - ignored resource META-INF/maven/archetype-metadata.xml [DEBUG] Processing complete archetype wildfly-jakartaee-webapp-ear-archetype

 

And this is the output for an archetype created with 3.2.1:

 

[DEBUG] getFilesetArchetypeResources( "C:\Users\USERNAME\.m2\repository\org\wildfly\archetype\wildfly-jakartaee-ear-archetype\30.0.0.Final-SNAPSHOT\wildfly-jakartaee-ear-archetype-30.0.0.Final-SNAPSHOT.jar" ) [DEBUG]   - ignored resource META-INF/MANIFEST.MF [DEBUG]   - ignored resource META-INF/ [DEBUG]   - found resource (archetype-resources/) [DEBUG]   - found resource (archetype-resources/)ear/ [DEBUG]   - found resource (archetype-resources/)ejb/ [DEBUG]   - found resource (archetype-resources/)ejb/src/ [DEBUG]   - found resource (archetype-resources/)ejb/src/main/ [DEBUG]   - found resource (archetype-resources/)ejb/src/main/resources/ [DEBUG]   - found resource (archetype-resources/)ejb/src/main/resources/META-INF/ [DEBUG]   - found resource (archetype-resources/)ejb/src/test/ [DEBUG]   - found resource (archetype-resources/)ejb/src/test/resources/ [DEBUG]   - found resource (archetype-resources/)web/ [DEBUG]   - found resource (archetype-resources/)web/src/ [DEBUG]   - found resource (archetype-resources/)web/src/main/ [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/ [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/WEB-INF/ [DEBUG]   - found resource (archetype-resources/)web/src/test/ [DEBUG]   - found resource (archetype-resources/)web/src/test/java/ [DEBUG]   - found resource (archetype-resources/)web/src/test/java/test/ [DEBUG]   - found resource (archetype-resources/)web/src/test/resources/ [DEBUG]   - ignored resource META-INF/maven/ [DEBUG]   - ignored resource META-INF/maven/org.wildfly.archetype/ [DEBUG]   - ignored resource META-INF/maven/org.wildfly.archetype/wildfly-jakartaee-ear-archetype/ [DEBUG]   - found resource (archetype-resources/)ear/pom.xml [DEBUG]   - found resource (archetype-resources/)ejb/pom.xml [DEBUG]   - found resource (archetype-resources/)ejb/src/main/resources/META-INF/persistence.xml [DEBUG]   - found resource (archetype-resources/)ejb/src/test/resources/arquillian.xml [DEBUG]   - found resource (archetype-resources/)pom.xml [DEBUG]   - found resource (archetype-resources/)README.txt [DEBUG]   - found resource (archetype-resources/)web/pom.xml [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/WEB-INF/beans.xml [DEBUG]   - found resource (archetype-resources/)web/src/main/webapp/WEB-INF/faces-config.xml [DEBUG]   - found resource (archetype-resources/)web/src/test/java/test/SampleIT.java [DEBUG]   - found resource (archetype-resources/)web/src/test/resources/arquillian.xml [DEBUG]   - ignored resource META-INF/maven/archetype-metadata.xml [DEBUG]   - ignored resource META-INF/maven/org.wildfly.archetype/wildfly-jakartaee-ear-archetype/pom.xml [DEBUG]   - ignored resource META-INF/maven/org.wildfly.archetype/wildfly-jakartaee-ear-archetype/pom.properties

 

Unfortunately, I don't have an easy to reproduce sample - the "wildfly-jakartaee-ear-archetype" contains some additional stuff.

 

For completeness, I attached[^archetype-metadata.xml] with several "fileSet" definitions.


Affects: 3.2.1

Attachments:

Remote Links:

jira-importer avatar Oct 04 '23 20:10 jira-importer

Wolfgang Knauf commented

Here is the slighly simplified source project, which reproduces the problem:

[^wildfly-jakartaee-ear-archetype_ARCHETYPE-649.zip]

 

In "pom.xml", there is a section where the archetype-plugin version can be defined:

        <pluginManagement>             <plugins>                 <plugin>                     <groupId>org.apache.maven.plugins</groupId>                     <artifactId>maven-archetype-plugin</artifactId>                     <version>3.2.1</version>                     <!--<version>3.1.2</version>-->                     <extensions>true</extensions>                 </plugin>             </plugins>         </pluginManagement>

 

Currently, it is "3.2.1", which reproduces the warning. If you build the archetype with "mvn clean install", you will see the warning already when a sample project is generated during the test.

Otherwise, you can create a project later with this command:

mvn archetype:generate -DarchetypeCatalog=local -DgroupId=foo.bar -DartifactId=multi -Dversion=0.1-SNAPSHOT -Dpackage=foo.bar.multi -DarchetypeGroupId=org.wildfly.archetype -DarchetypeArtifactId=wildfly-jakartaee-ear-archetype_ARCHETYPE-649 -DarchetypeVersion=30.0.0.Final-SNAPSHOT

Change the version to "3.1.2" and rebuild it, and there is no warning.

The warning seems to be caused by the fact that the project has modules. In a simpler archetype without modules, the problem does not happen.

jira-importer avatar Oct 05 '23 15:10 jira-importer

Wolfgang Knauf commented

Sent a pull request, though I don't know whether this is a good solution ;): https://github.com/apache/maven-archetype/pull/160

jira-importer avatar Dec 01 '23 06:12 jira-importer

Slawomir Jaranowski commented

When we skip empty directory - we will break ARCHETYPE-289

jira-importer avatar Sep 14 '24 11:09 jira-importer

I think I found a workaround to avoid the warnings:

In "archetype-metadata.xml" I had defined fileSets for e.g. "src/test/java" or "src/main/webapp", and those directories also contained java files files or deployment descriptors:

        <module id="web" dir="web" name="web">
            <fileSets>
                ...
                <fileSet encoding="UTF-8" packaged="true" filtered="true">
                    <directory>src/test/java</directory>
                </fileSet>
                <fileSet encoding="UTF-8">
                    <directory>src/main/webapp</directory>
                </fileSet>
                ...
            </fileSets>
        </module>

This caused the warnings.

My workaround: I added a "includes" filter for all those directories:

        <module id="web" dir="web" name="web">
            <fileSets>
                ..
                <fileSet encoding="UTF-8" packaged="true" filtered="true">
                    <directory>src/test/java</directory>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </fileSet>
                <fileSet encoding="UTF-8">
                    <directory>src/main/webapp</directory>
                    <includes>
                        <include>**/*.xml</include>
                    </includes>
                </fileSet>
                ...
            </fileSets>
        </module>

Now the warning is gone.

Hope that my workaround is reasonable ;-)

I would like to keep this issue open though my problem seems to be resolved, because I still think there is some validation bug in the archetype plugin.

WolfgangHG avatar Oct 13 '25 19:10 WolfgangHG