2011-12-11 6 views
8

Jar Jar LinksのAntタスクを使用して、サードパーティのjarファイル(objenesis)のクラスを配布可能なjarファイル(example.jar)に埋め込みます。 Jar Jarは、元のパッケージ(org.objenesis)のクラスを自分が選択したクラスに変換します。空のディレクトリをJar Jarで除外するリンク

これは動作しますが、配布可能なjarに空のディレクトリが残ります。ここ

は、簡略化のbuild.xmlある:

<target name="jar" depends="compile"> 
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" 
     classpath="lib/jarjar-1.1.jar"/> 

    <jarjar jarfile="dist/example.jar" excludes="org.objenesis.**"> 
     <fileset dir="build/classes/main"/> 
     <zipfileset src="lib/objenesis-1.2.jar"/> 
     <rule pattern="org.objenesis.**" result="[email protected]"/> 
    </jarjar> 
</target> 

(予想通り)example.jarの内容のサンプルが含まれています:

org/thirdparty/Objenesis.class 
org/thirdparty/ObjenesisBase.class 

だけでなく、これらの空のディレクトリ(望ましくないe):

org/objenesis/ 
org/objenesis/instantiator/ 
org/objenesis/instantiator/basic/ 

質問:私はこれらの空のディレクトリをどのように除外しますか?

「ザップ」オプション(listed in the doc)を試しましたが、うまくいかなかった。

答えて

7

これは彼らの問題追跡に記載されたジャー・ジャーの既知の問題であると表示されます。http://code.google.com/p/jarjar/issues/detail?q=empty&id=32

これは、ほぼ3年前に上昇させ、任意の牽引力を持っているように見えないことを考えると、私はあなたのオプションを想定修正を提供すること、または回避することです。コピーに空のディレクトリを削除するためのAntのサポートを活用して、それを回避するために

例Antターゲット、次のようになります。

<target name="unpolluted-jarjar" description="JarJars without empty directories"> 
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${location.lib}/build/jarjar-1.2.jar"/> 
    <jarjar basedir="${location.classes}" destfile="${location.dist.binaries}/my-app.jar"> 
     <zipfileset src="${location.lib}/shipped/dependency.jar"/> 
     <rule pattern="com.example.dependency.**" result="[email protected]"/> 
    </jarjar> 
    <mkdir dir="${location.dist.binaries}/exploded"/> 
    <unzip src="${location.dist.binaries}/my-app.jar" dest="${location.dist.binaries}/exploded/my-app.jar"/> 
    <copy includeemptydirs="false" todir="${location.dist.binaries}/unpolluted/my-app.jar"> 
     <fileset dir="${location.dist.binaries}/exploded/my-app.jar"/> 
    </copy> 
    <jar destfile="${location.dist.binaries}/my-app-unpolluted.jar"> 
     <fileset dir="${location.dist.binaries}/unpolluted/my-app.jar"/> 
    </jar> 
</target> 

それは少し汚れたのですが、それはあなたが望むものを達成し。

+0

これは私にとってはうまくいくようでした(私はGradle構文に変換しなければならなかった)。 –

関連する問題