有人碰巧知道是否有办法将jar库的内容检索到一个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
与ivy和ant)我有一个缓存路径或缓存文件集)
答案 0 :(得分:1)
需要将常春藤与groovy插件结合使用。
<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-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>
答案 1 :(得分:0)
我实际上已经做出了这个决定
<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>
然后我们删除临时 - 瞧。
此外,也许你可以建议在eclipse中使用ivyDE和ant进行多个项目布局的smth?我问过这个问题,但没有人发布任何建议。伤心(