0

まず、私が直面している問題の背景を説明しましょう。

私は以下のようなディレクトリ構造を持っています。

c:\ myDirectory
c:\ myDirectory \ Project1
c:\ myDirectory \ Scripts

c:\ myDirectory \ Scriptsの下に、(svnから)ソースコードをダウンロードしてc:\ myDirectory\Project1ディレクトリを作成するスクリプトがあります。

c:\ myDirectory \ Project1にダウンロードされたantスクリプトbuild.xmlからProject1をコンパイルする別のantスクリプト(c:\ myDirectory \ Scripts ** compile-source.xml )があります。

c:\ myDirectory \ Scripts\compile-source.xmlのスニペット

<project name="compile" default="buildAll" basedir=".">
    <property file=".\build.properties">
    </property>
    .......
    <import file="${project.home.path}/${project.name}/build.xml"/>
     <target name="buildAll">
      <antcall target="jar-pack"/>
    </target>
</project>

c:\ myDirectory \ Project1\build.xmlのスニペット。

<project name="CommonFeatures" default="jar-pack" basedir=".">
        <description>
            A build file for the Common Features project
        </description>
        ....
    </project>

プロジェクトのbasedirは「。」に設定されていることに注意してください。上記の両方のantスクリプト。

c:\ myDirectory \ Scriptsディレクトリからスクリプトc:\ myDirectory \ Scripts \ compile-source.xmlを実行すると、c:\ myDirectory \ Project1\build.xmlにあるターゲット「jar-pack」が実行されます。

ただし、問題は、build.xml(basedir = "。")のbasedir属性が現在の作業ディレクトリであり、この場合はそのc:\ myDirectory\Scriptsであるということです。したがって、build.xmlのbasedirはc:\ myDirectory \ Project1であると予想されるため、スクリプトbuild.xmlはエラーになります。basedir = "の場合、build.xmlスクリプトは機能します。" 「c:\ myDirectory \ Project1」に設定されていましたが、残念ながらbuild.xmlファイルはダウンロードされたソースコードからのものであり、編集できません。

だからここに私の質問があります、次のいずれかを行うことは可能ですか?

  1. attribude basedir="の値を上書きします。" build.xmlでc:\ myDirectory \ Scripts \ compile-source.xmlで行われますか?

  2. スクリプトc:\ myDirectory \ Project1 \ build.xmlがディレクトリc:\ myDirectory \ Project1の下で実行されるように、build.xmlのbasedirを他のメカニズムで変更することは可能ですか?

  3. この問題を解決する他の方法はありますか?

この問題を克服するためのAntの専門家からの助けは大歓迎です。

4

3 に答える 3

0

このスタック オーバーフロー スレッドで説明されているビルド ファイルの場所を具体的に参照できます。これにより、ビルド ファイルが存在するディレクトリを参照ポイントとして取得して使用できるようになります。

于 2013-03-06T16:16:37.727 に答える
0

subantタスクを使用してbasedirを更新できます。この回答を確認してください

次のbuild.xmlファイルを作成します ( Z:/any/folderにあると仮定します)。

<?xml version="1.0" encoding="UTF-8"?>
<project name="project">
    <target name="mytarget">
        <subant target="debug">
            <property name="basedir" value="X:/any/dir/with/project"/>
            <fileset dir="Y:/any/folder/with" includes="build.xml"/>
        </subant>
    </target>
</project>

Z:/any/folderからant mytargetを実行できます

于 2013-04-30T09:56:51.173 に答える