如果我想使用jar实用程序创建一个没有META-INF废话的jar文件,我可以传递-M开关,它将:
-M do not create a manifest file for the entries
Run Code Online (Sandbox Code Playgroud)
请注意,这是jar实用程序的一项功能.如果我使用它,我将得到一个没有META-INF文件夹并包含MANIFEST的jar,基本上只是jar类型的存档,包含我放入的任何文件/目录.
如何使用maven-jar-plugin执行此操作?我需要这样做以符合另一个过程.(他们期望一个具有非常特定的文件/文件夹布局的jar,我不能在jar文件的根目录下有一个META-INF文件夹.)
我有配置来正确创建jar文件,我不想搞乱另一个插件......
小智 8
在maven-jar-plugin中没有禁用创建清单文件夹的选项,但您可以禁用maven描述符目录,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果您想要删除META-INF文件夹,可以使用maven-shade-plugin,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
可以使用maven-shade-plugin
来达到想要的效果:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
配置过滤掉 META-INF 目录,只包含当前项目,这样就不会附加依赖项。
归档时间: |
|
查看次数: |
4620 次 |
最近记录: |