使用一些Maven插件重命名jar中的文件 [英] Rename files inside a jar using some maven plugin
本文介绍了使用一些Maven插件重命名jar中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个通过maven-shade-plugin构建的jar. 它包含带有几个文件的META-INF/services. 这些文件的名称错误(由于错误 https://issues.apache.org/jira /browse/MSHADE-182 ). 我想重命名这些文件.
I have a jar build by maven-shade-plugin. It contains META-INF/services with several files. These files have wrong names (because of the bug https://issues.apache.org/jira/browse/MSHADE-182). I'd like to rename these files.
用Maven做到这一点最简单的方法是什么?
What is the easiest way of doing this with maven?
推荐答案
肮脏的骇客,但对我有用
Dirty hack, but it works for me
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<configuration>
<target>
<echo message="unjar" />
<unzip src="${project.build.directory}/${artifactId}-${version}.jar" dest="${project.build.directory}/unpacked/" />
<echo message="rename service providers in META-INF/services" />
<move todir="${project.build.directory}/unpacked/META-INF/services" includeemptydirs="false">
<fileset dir="${project.build.directory}/unpacked/META-INF/services"/>
<mapper type="glob" from="*" to="${shade.package}.*"/>
</move>
<echo message="jar back" />
<jar destfile="${project.build.directory}/${artifactId}-${version}.jar" basedir="${project.build.directory}/unpacked" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
这篇关于使用一些Maven插件重命名jar中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文