Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARCHETYPE-649] work around warning 'Don't override file...' #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WolfgangHG
Copy link

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.

@WolfgangHG
Copy link
Author

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".

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a test

@WolfgangHG
Copy link
Author

@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?

@slawekjaranowski slawekjaranowski changed the title [ARCHETYPE-64] work around warning 'Don't override file...' [ARCHETYPE-649] work around warning 'Don't override file...' Sep 14, 2024
@slawekjaranowski
Copy link
Member

I think this PR will break feature like https://issues.apache.org/jira/browse/ARCHETYPE-289

@WolfgangHG
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants