maven-archetype
maven-archetype copied to clipboard
[ARCHETYPE-649] work around warning 'Don't override file...'
This pull request tries to work around a warning "Don't override file ..." or "CP Don't override file..." that appeared after switching from maven archetype plugin 3.1.2 to 3.2.1 - more details and a sample see https://issues.apache.org/jira/browse/ARCHETYPE-649
The warning seems to be caused by fileset declarations in "archetype-metadata.xml": with 3.2.1, the archetype jar file contains entries for all directories, but before there were only entries for the actual files in the zip. I could also verify this difference by analyzing the jar file with WinZip.
I could work around the warning by switching off "IncludeEmptyDirs" in two places in "JarMojo.execute".
My first thought was to pass the paths of the "archetype-metadata.xml" filesets to the second argument of "DefaultFileSet.includeExclude()", but this did not have any effect - but this might also be caused by me using wrong paths;-)
[DISCLAIMER] This is my first pull request to maven, I don't have knowledge of the internals - just trying to workaround an issue that I run into. Maybe the problem is also caused by me misusing the filesets in "archetype-metadata.xml". So please consider this more a start of a discussion that a "I have fixed something" statement ;-). If you have better suggestions to resolve this, please point me to them.
About empty directories: one could think that it could be feature in the new version that empty directories are also included in the jar file. But I tried to add empty folders in different places in the archetype source directory structure, and none of them was included in the archetype jar (using archetype plugin 3.2.1, which creates jar entries for all directories, but without my workaround). Several StackOverflow answers suggest to achieve this by using filesets.
Then I found this suggestion which does not work any more with my workaround: https://stackoverflow.com/questions/2786966/how-to-create-empty-folders-with-maven-archetype When adding the "maven-resources-plugin" with "includeEmptyDirs=true", then this will work with 3.2.1 as expected: all empty dirs are added. But my workaround breaks this code.
The only solution I could think of: parse "archetype-metadata.xml" and exclude all directories that are defined as root dirs of filesets. But how to do this and how to handle the excludes? As I wrote above, I did not manage to specify exclusions on "DefaultFileSet".
@elharo I attached a full sample project to https://issues.apache.org/jira/browse/ARCHETYPE-649. I probably could create a smaller sample (web app project instead of ear project with two modules). But you request a unit test as part of the archetype build process? How could I create such a test project?
I think this PR will break feature like https://issues.apache.org/jira/browse/ARCHETYPE-289
I hope you guys have a better solution for this, I know that this pull request is no good ;-).
The original issue might also be a problem in my own archetype, but I have no idea what could be improved.
Resolve #487
Resolve #897
Resolve #487
Resolve #897
Closing this one as it probably is not the correct fix, and I found a workaround to avoid the warning in my own archetype.