【问题标题】:Maven jar with classpath in manifest清单中带有类路径的 Maven jar
【发布时间】:2015-01-18 09:22:57
【问题描述】:

我正在制作一个包含项目 jar 和所有依赖项的额外 jar,作为我的 maven 构建的一部分(使用 maven-assembly-plugin):

在汇编 XML 文件中:

    <dependencySet>
        <unpack>false</unpack>
        <scope>runtime</scope>
        <useProjectArtifact>false</useProjectArtifact>
        <outputDirectory>lib</outputDirectory>
    </dependencySet>

在 POM 中:

<archive>
  <manifest>
     <mainClass>dk.intelligentsystems.platform.deploy.Deployer</mainClass>
     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
     <addClasspath>true</addClasspath>
     <classpathPrefix>lib/</classpathPrefix>
   </manifest>
 </archive>

jar 包含正确的文件,但未将依赖项添加到 manufest Classpath 属性中。我怎样才能做到这一点?

【问题讨论】:

    标签: maven jar manifest.mf


    【解决方案1】:

    为了相同的目的,我将maven-shade-pluginmaven-jar-plugin 结合使用,而不是 maven-assembly-plugin。

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                        <exclude>.settings/**</exclude>
                                        <exclude>*.classpath</exclude>
                                        <exclude>*.project</exclude>
                                        <exclude>*.txt</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    【讨论】:

    • 看起来不像这样,我正在寻找什么。但这可能是一个有用的 B 计划。
    猜你喜欢
    • 2019-08-27
    • 2018-04-10
    • 2016-09-21
    • 2023-03-04
    • 1970-01-01
    • 2017-08-25
    • 1970-01-01
    • 2012-06-11
    • 2013-12-15
    相关资源
    最近更新 更多