Maven Shade Plugin
  1. Maven Shade Plugin
  2. MSHADE-91

Allow using external Shader implementation

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.6
    • Labels:
      None
    • Environment:
      N/A
    • Number of attachments :
      1

      Description

      Currently if multiple shaded artifacts contain the same fully-qualified class name, the plugin issues a warning on the console like this:

      [WARNING] We have a duplicate foo.bar.Baz.class in <path-to-jar-in-local-repo>

      In many cases such duplicates are a serious problem, e.g. when they are not the same version of that class.

      It would therefore be useful if the plugin (specifically the DefaultShader class) provided the option of failing the build if any duplicates are detected. This would be particularly useful in a continuous integration environment where there's no human operator to check the console output for warnings.

        Issue Links

          Activity

          Hide
          Andrew Swan added a comment -

          One workaround would be to use a custom Shader implementation; is this possible? The Shader field in the ShaderMojo is declared thus:

          Shader.java
          /**
           * @component
           * @required
           * @readonly
           */
          private Shader shader;

          From what little I know about Plexus, this seems to indicate that the Shader is not pluggable?

          Show
          Andrew Swan added a comment - One workaround would be to use a custom Shader implementation; is this possible? The Shader field in the ShaderMojo is declared thus: Shader.java /** * @component * @required * @readonly */ private Shader shader; From what little I know about Plexus, this seems to indicate that the Shader is not pluggable?
          Hide
          Andrew Swan added a comment -

          Here's a patch that adds a boolean configuration property called "duplicatesAreFatal", defaulting to "false" to preserve the current behaviour. When set to "true", a "BUILD FAILURE" message is shown, listing all duplications detected by the Shader.

          Show
          Andrew Swan added a comment - Here's a patch that adds a boolean configuration property called "duplicatesAreFatal", defaulting to "false" to preserve the current behaviour. When set to "true", a "BUILD FAILURE" message is shown, listing all duplications detected by the Shader.
          Hide
          Benson Margulies added a comment -

          How about an integration test to go with this?

          Show
          Benson Margulies added a comment - How about an integration test to go with this?
          Hide
          Robert Burrell Donkin added a comment -

          Factoring out a ResourceMerger would allow both feature requests to be addressed in a flexible way.

          Show
          Robert Burrell Donkin added a comment - Factoring out a ResourceMerger would allow both feature requests to be addressed in a flexible way.
          Hide
          Olivier Lamy added a comment -

          fixed. with 1.6 you will be able to use your own Shader implementation.

          Show
          Olivier Lamy added a comment - fixed. with 1.6 you will be able to use your own Shader implementation.
          Hide
          Scott Carey added a comment -

          How does this solve the ask:

          It would therefore be useful if the plugin (specifically the DefaultShader class) provided the option of failing the build if any duplicates are detected. This would be particularly useful in a continuous integration environment where there's no human operator to check the console output for warnings.

          How do I configure the shade plugin to fail when there is a duplicate class detected while shading? (I don't see anything on http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html)

          If there are duplicate classes, a java application on android will fail to run. The VM on Android is very strict.

          Show
          Scott Carey added a comment - How does this solve the ask: It would therefore be useful if the plugin (specifically the DefaultShader class) provided the option of failing the build if any duplicates are detected. This would be particularly useful in a continuous integration environment where there's no human operator to check the console output for warnings. How do I configure the shade plugin to fail when there is a duplicate class detected while shading? (I don't see anything on http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html ) If there are duplicate classes, a java application on android will fail to run. The VM on Android is very strict.

            People

            • Assignee:
              Olivier Lamy
              Reporter:
              Andrew Swan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: