2011-12-07 46 views
0

是否有人碰巧知道是否有檢索罐子庫的內容轉換成一個單獨的JAR的方式 - 所以,這將是苛刻的震動和常春藤

jar 1 : 
    org 
     smth 
     new.class 

jar 2 : 
    org 
     smth 
     also.class 

jar 3 : 
    org 
     another 
     otheralso.class 

that single jar: 
     org 
      another 
      one.class 
      smth 
      two class 

result jar : 
     org 
      another 
      one.class 
      otheralso.class 
     smth 
      two class 
      also.class 
      new.class 

常春藤和螞蟻)我有一個cachepath或緩存文件集)

回答

1

需要將ivy與groovy插件結合使用。

的build.xml

<target name="resolve"> 
    <ivy:resolve/> 
    <ivy:cachepath pathid="build.path" conf="build"/> 
    <ivy:cachefileset setid="jarfiles" conf="jars"/> 
</target> 

<target name="combine-jars" depends="resolve"> 
    <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/> 

    <!-- 
    Iterate thru each file expanding content into a temp directory 
    used to create a new jar 
    --> 
    <groovy> 
    project.references.jarfiles.each { 
     ant.unzip(src: it, dest:"build/tmp") 
    } 
    ant.jar(destfile:"build/newjar.jar", basedir:"build/tmp") 
    </groovy> 
</target> 

的ivy.xml

使用ivy配置,下載分成構建依賴關係和文件的集合 到構建內再把它們組合起來。

<ivy-module version="2.0"> 
    <info organisation="org.myspotontheweb" module="demo"/> 
    <configurations> 
     <conf name="build" description="ANT tasks"/> 
     <conf name="jars" description="Files to be combined"/> 
    </configurations> 
    <dependencies> 
     <!-- build dependencies --> 
     <dependency org="org.codehaus.groovy" name="groovy-all" rev="1.8.2" conf="build->default"/> 

     <!-- jars dependencies --> 
     <dependency org="log4j" name="log4j" rev="1.2.16" conf="jars->default"/> 
     <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="jars->default"/> 
     .. 
     .. 
    </dependencies> 
</ivy-module> 
0

我actully來到這個決定

<target name="project.archive" depends="project.make, ivy-runtimecahe"> 
    <mkdir dir="${project.build}\temp" /> 
    <copy todir="${project.build}\temp"> 
         <archives> 
         <zips > 
          <restrict > 
          <path refid="classpath.Runtime" /> 
          <name name="*.jar" /> 

          </restrict> 

         </zips> 
         </archives> 

        </copy> 
      <jar jarfile="${project.build}\${project.archive.name}-${project.version}.jar" 
     manifest="${basedir}\${project.maifest}"> 
    <fileset dir="${project.build}\temp" includes="**\*.class" /> 
    <fileset dir="${project.classes}" includes="**\*.class" /> 
    <fileset dir="Btlserver" includes="**\*.xml" /> 

     </jar> 

那麼我們刪除臨時 - 瞧。

此外,也許你可以建議smth關於多個項目在日食與ivyDE和螞蟻佈局?我問了這個問題,但沒有人發佈任何建議。傷心(