2015-11-20 23 views
2

我有一個由maven-shade-plugin構建的jar。它包含幾個文件的META-INF /服務。 這些文件名稱錯誤(因爲缺陷https://issues.apache.org/jira/browse/MSHADE-182)。 我想重命名這些文件。使用一些maven插件重命名jar文件內的文件

用maven做這件事最簡單的方法是什麼?

+0

最好你會告訴你已經嘗試做的,解決這個問題是什麼。這可能就是爲什麼你的問題被低估了。 –

+0

您鏈接到一個錯誤。這個bug有一個補丁,爲什麼不安裝它?由於存在一個錯誤,除了「存在錯誤」之外,我沒有看到您期望的答案。 – Tunaki

+0

@Tunaki我不是Apache提交者。因此,我有兩種可能的方式 - 1)等待新版本的插件; 2)應用一些臨時解決方案。 – long

回答

1

骯髒的黑客,但它爲我工作

 <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>