Skip to content

[MDEP-628] Parameter fileMappers for unpack path rewriting #5

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

Merged
merged 2 commits into from
Nov 29, 2018

Conversation

mkarg
Copy link
Contributor

@mkarg mkarg commented Sep 19, 2018

Solving MDEP-628.

The new parameter fileMappers (default: null) can be set to an implementation of the org.codehaus.plexus.components.io.filemappers.FileMapper interface to rewrite the target path of each unpacked file.

This is useful in case prefixes of target files names within the target directory shall be added (using PrefixFileMapper), changed or omitted (using RegExpFileMapper).

@plamentotev
Copy link

What is the use case that this feature covers? I just wonder if you need complex and powerful way to organize files, isn't assembly plugin (with dir archive) more suitable?

@mkarg
Copy link
Contributor Author

mkarg commented Sep 22, 2018

Believe me, it was the perfectly correct choice to provide exactly this solution, and we really need this complete freedom of mapping! ;-)

First of all, the assembly plugin has the same problem: It cannot freely rewrite target paths, but this is what we actually solved. Second, as we do not want to create assemblies at all, it would simply be a misuse; what we actually want is to unpack dependencies, so the correct way is to dependency:unpack and nothing else.

In cour case, what we needed is to invoke external tools as part of our build process which expects a particular directory hierarchy. The source of the files in that hierarchy come from several external dependencies (ZIP files), i. e. their content is not under our control. The problem is: The tools expect a completely different hierarchy than the one found in the ZIPs. For example, each ZIP has some kinde of parent folders structure inside, but the tool wants a different parent structure:

Dependency ZIP A:
/a/b/C

Dependency ZIP B:
/d/e/F

Tool can only process *exactly this* folder structure:
/u/v/w/C
/x/y/z/F

The solution of extending the dependency plugin is clean and straightforward: We now can simply add the RegExMapper config within each <ArtifactItem> in the unpack config.

So to sum up: It was the perfectly correct way to fork and extend the dependecy plugin. Everything else would just be a bad hack. ;-)

@mkarg mkarg changed the title Parameter fileMapper for unpack path rewriting [MDEP-628] Parameter fileMapper for unpack path rewriting Sep 22, 2018
@plamentotev
Copy link

Yes, you're right that in such case it does make sense to use the dependency plugin instead of the assembly plugin.

@mkarg mkarg changed the title [MDEP-628] Parameter fileMapper for unpack path rewriting [MDEP-628] Parameter fileMappers for unpack path rewriting Sep 24, 2018
@mkarg
Copy link
Contributor Author

mkarg commented Sep 24, 2018

@plamentotev Review please. :-)

@plamentotev
Copy link

plamentotev commented Sep 27, 2018 via email

@mkarg
Copy link
Contributor Author

mkarg commented Sep 27, 2018

Could someone else review please? :-)

@plamentotev
Copy link

@mkarg Plexus Archiver 3.7.0 is now released so you can update the dependency.

@mkarg
Copy link
Contributor Author

mkarg commented Oct 16, 2018

@plamentotev Thanks for the info! I pushed 65e7ff7 so MDEP has no SNAPSHOT dependency now. :-)

@mkarg
Copy link
Contributor Author

mkarg commented Oct 16, 2018

@khmarbaise @hboutemy I would be happy if you could review this PR and consider for merging. :-)

The new parameter `fileMappers` (default: `null`) can be set to an
implementation of the
`org.codehaus.plexus.components.io.filemappers.FileMapper` interface to
rewrite the target path of each unpacked file.

This is useful in case prefixes of target files names within the target
directory shall be added (using `PrefixFileMapper`), changed or omitted
(using `RegExpFileMapper`).

Signed-off-by: Markus KARG <[email protected]>
@mkarg
Copy link
Contributor Author

mkarg commented Nov 27, 2018

@khmarbaise @hboutemy @rfscholte What do I have to do to make you review my implementation of MDEP-628? You are neither reviewing it nor answering to discussions in this tracker nor to emails. So what am I supposed to do to get it reviewed?

@rfscholte
Copy link
Contributor

A ping like this helps. I've had a look at the patch, but I am missing a test to confirm this feature. Probably easiest solved by providing an Integration Test under src/it/projects, executed with mvn verify -Prun-its

@mkarg
Copy link
Contributor Author

mkarg commented Nov 28, 2018

@rfscholte Amended existing integration test to verify mapping works well, see d47a4ab.

@rfscholte
Copy link
Contributor

Could you copy the unpack-dependencies instead of adjusting it? We need to ensure that the default 1:1 extraction keeps working as expected.

@mkarg
Copy link
Contributor Author

mkarg commented Nov 29, 2018

@rfscholte Done. :-)

@rfscholte rfscholte merged commit c09bee4 into apache:master Nov 29, 2018
@mkarg
Copy link
Contributor Author

mkarg commented Nov 29, 2018

@rfscholte Thanks! :-) 🎉

asfgit pushed a commit that referenced this pull request Sep 29, 2021
[MNGSITE-393] remove pre-Maven 3 workarounds
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.

4 participants