6

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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
javamonkey79
  • 17,443
  • 36
  • 114
  • 172

1 Answers1

7

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.
Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40