Maven Shade Plugin not including resources of dependency

僤鯓⒐⒋嵵緔 提交于 2019-12-11 10:44:17

问题


I'm using the Maven Shade Plugin to include all dependencies during package phase. That works fine for classes, but dependent resources aren't included.

Here's the layout of the dependent jar:

./config.properties <-- this is the missing resource
./META-INF
./META-INF/MANIFEST.MF
./META-INF/maven
./META-INF/maven/com.example
./META-INF/maven/com.example/bar
./META-INF/maven/com.example/bar/pom.properties
./META-INF/maven/com.example/bar/pom.xml

Here's the shade plugin configuration:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.6</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer
              implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <manifestEntries>
                <Main-Class>com.example.foo.Foo</Main-Class>
                <!-- <X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>.
                  <X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK> -->
              </manifestEntries>
            </transformer>
          </transformers>
          <filters>
            <filter>
              <!--
                Exclude files that sign a jar
                (one or multiple of the dependencies).
                One may not repack a signed jar without
                this, or you will get a
                SecurityException at program start.
              -->
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.RSA</exclude>
                <exclude>META-INF/*.INF</exclude> <!-- This one may not be required -->
              </excludes>
            </filter>
          </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>

回答1:


It's embarrasing, but there was a typo in the version of the dependency and that version didn't have the file.



来源:https://stackoverflow.com/questions/16520195/maven-shade-plugin-not-including-resources-of-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!