Maven Shade插件不包括依赖资源

时间:2013-05-13 10:45:13

标签: maven resources dependencies maven-shade-plugin

我正在使用Maven Shade插件在包阶段包含所有依赖项。 这适用于类,但不包括依赖资源。

以下是依赖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

这是树荫插件配置:

  <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 个答案:

答案 0 :(得分:2)

这很令人尴尬,但是依赖版本中有一个拼写错误,而且该版本没有该文件。