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

[MASSEMBLY-617] add ability to give a fileSuffix to a AbstractPlexusI… #13

Closed
wants to merge 1 commit into from

Conversation

tcollignon
Copy link
Contributor

…oResourceCollection

HI

I switch this PR sonatype/plexus-io#7 here.

Hi

In order to fix https://issues.apache.org/jira/browse/MASSEMBLY-617, I need to add a capability to PlexusIoFileResourceCollection, to add file suffix when it package files.
This PR add this feature.

Tell me if something goes wrong

Thx

@plamentotev
Copy link
Member

Hi, thanks for the contribution. Having more flexibility in regards to the file naming seems to be one of the popular feature request for the Maven Assembly plugin. Glad to see some work on it :). I have a couple of comments:

  • If you want to modify the resource file name please use FileMapper. You can implement your logic by extending AbstractFileMapper and then add it to the file mappers array instead of adding additional setSuffix method. I know there is setPreffix (and it may sound logical to have setSuffix as well), but this name is a bit misleading. It is actually used by the Assembly plugin to add path prefix to the resource so the output directory could be changed. Using FileMapper is a lot more flexible - you can set additional option that control the behavior (for example should dot files get a suffix or not).
  • There is a RegExpFileMapper (for some reason missing from the documentation) that can be used to achieve the same functionality. The following mapper will add -suffix before the first dot and after the file name if there isn't one.
RegExpFileMapper regExpFileMapper = new RegExpFileMapper();
regExpFileMapper.setPattern("^(.*?)(\\..*)?$");
regExpFileMapper.setReplacement("$1-suffix$2");

This is just FYI. If you want to implement a file suffix mapper that will make the build more readable - I don't find the above regex intuitive one.

@plamentotev
Copy link
Member

Closing in favour of #14

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

Successfully merging this pull request may close these issues.

2 participants