0

こんにちは、私は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 回実行すると動作しますが、最初は本当に奇妙なスタッフが発生します。どちらかがコンパイルされず、どちらかのクラスが複製されます。その理由は何ですか?どうもありがとう

4

2 に答える 2

0

初めて実行したときのように、ディレクトリがそこにない場合は文句を言うと思います。削除タスクに failonerror="false" 属性を追加することをお勧めします。

今後の参考として、Java の構築に ant はあまり使用されなくなりました。ほとんどの人は maven に移行しています。

于 2013-07-10T16:18:27.007 に答える