【问题标题】:Maven Shade Plugin not including resources of dependencyMaven Shade 插件不包括依赖资源
【发布时间】:2013-05-07 09:03:22
【问题描述】:

我正在使用 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>

【问题讨论】:

  • 您是否尝试过使用最新版本的maven-shade-plugin 并且没有任何配置。
  • 我已经用一个简单的多模块项目和 1.6 和 2.0 版的阴影插件对此进行了测试,我的属性文件被复制了。您能否尝试添加 junit:junit:4.11 (编译范围)作为依赖项并查看是否复制了 Licence.txt ?如果它仍然不起作用,请添加您的项目布局和完整的 pom.xml 文件。谢谢。
  • 是的,已复制 License.txt。我会添加更多信息。
  • 挺尴尬的,但是依赖的版本有错别字,而且那个版本没有那个文件:-/要不要删除这个问题?

标签: maven resources dependencies maven-shade-plugin


【解决方案1】:

很尴尬,但是依赖的版本有错别字,而且那个版本没有文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2015-09-27
    • 2013-08-08
    • 1970-01-01
    • 2014-07-23
    相关资源
    最近更新 更多