javamonkey79
javamonkey79

Reputation: 17775

maven shade plugin custom transformer

Given maven shade plugin resource transformers, how can we create custom ones?

I've tried adding the shade plugin to my pom:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.2</version>
</dependency>

And creating a class that implements ResourceTransformer. But when I run it, I get:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.1:shade (default) on project foo: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.4.1:shade for parameter transformers: Cannot load implementation hint 'test.transformer.TestTransformer' -> [Help 1]

The transformer is on the same classpath as the project I'm running the build on, which, I'm guessing is the problem. Is there a way to add in an extension that brings in other transformers?

Upvotes: 6

Views: 4086

Answers (1)

Tassos Bassoukos
Tassos Bassoukos

Reputation: 16142

See in the next section of the instructions:

  • create a maven project that contains test.transformer.TestTransformer with the appropriate dependencies in its pom.xml.
  • in the original project project's pom.xml in project.build.plugins.plugin[.id='maven-shade-plugin'] add the above maven project as a dependency.

Upvotes: 7

Related Questions