嗨,我的 ant build.xml 有问题,它可以工作,但有时不是第一次,或者在某些计算机上工作,而在其他计算机上不行
所以这里是:
<project name="My-java-api" default="dist-api" basedir=".">
<description>
Java API Buildfile
</description>
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="libs" location="libs"/>
<!--if we don't remove folders, when we call compile-api
and classes have already been built, it doesn't build again-->
<target name="-init-api" depends="clean"
description="Create folders libs and build">
<mkdir dir="${build}"/>
<mkdir dir="${libs}"/>
<mkdir dir="${dist}"/>
</target>
<!-- Here I call another buildfile of submodule located at the tree indicated I am
sure the other buildfile works perfect -->
<target name="-pre-build-api" depends="-init-api"
description="Create jelly jar and copy it to libs folder">
<ant dir="../Libraries/jelly/core/"
antfile="build.xml"
target="standalone-jar"/>
<copy todir="${libs}">
<fileset
dir="../Libraries/jelly/core/dist"
includes="jelly-standalone*.jar" />
</copy>
</target>
<!--so now I create this classpath to use for making jar-->
<path id="lib.classpath">
<fileset dir="${libs}" includes="**/*.jar"/>
</path>
<!--I compile source code including the jar that I have just copied to libs-->
<target name="compile-api" depends="-pre-build-api" >
<javac srcdir="${src}"
includeantruntime="false"
destdir="${build}"
classpathref="lib.classpath">
</javac>
</target>
<!-- here i make jar with the classes and using the jar from external project,
I want just one jar for everything -->
<target name="dist-api" depends="compile-api" >
<jar jarfile="${dist}/name-java-api-0.1.jar" basedir="${build}" >
<zipgroupfileset dir="${libs}" includes="**/*.jar" />
</jar>
</target>
<target name="clean"
description="clean up" >
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${libs}"/>
</target>
编辑: failonerror="false" 添加到所有删除行
我不习惯蚂蚁,我一直在尝试和尝试,但它并不完全奏效。我希望我可以只使用命令行,但不能。奇怪的是,大多数时候如果运行它 2 次它就可以工作,但第一次真的很奇怪的工作人员发生了:要么不编译,要么类被重复。可能是什么原因?多谢