複数の異なるNetBeansプロジェクトがリンクされています。コンパイル時ライブラリとしてSubProject
にリンクするMainProject
があります。NetBeans build.xmlファイルに設定されたAnt変数が表示されないサブプロジェクト
MainProject
のAntの変数を設定するためのAnt build.xml
スクリプトを変更しようとしています。私は正しくMainProject
でこの変数を設定して見ることができますが、SubProject
のAnt build.xml
スクリプトはこの変数を認識しません。私はMainProject
上clean and build
を実行したときに
マイbuild.xml
スクリプトMainProject
<?xml version="1.0" encoding="UTF-8"?>
<project name="MainProject" default="default" basedir=".">
<description>Builds, tests, and runs the project MainProject.</description>
<import file="nbproject/build-impl.xml"/>
<target name="-pre-init">
<echo>MainProject Pre Init</echo>
<echo>${ant.version}</echo>
<property name="test.test.test" value="isset" />
<echo>test.test.test=${test.test.test}</echo>
</target>
</project>
にSubProject
<?xml version="1.0" encoding="UTF-8"?>
<project name="SubProject" default="default" basedir=".">
<description>Builds, tests, and runs the project SubProject.</description>
<import file="nbproject/build-impl.xml"/>
<target name="-pre-init">
<echo>SubProject Pre Init</echo>
<echo>test.test.test=${test.test.test}</echo>
</target>
</project>
の私build.xml
スクリプトは、今、私は次のような出力が得られます。
ant -f C:\\sandbox\\MainProject -Dnb.internal.action.name=rebuild clean jar
MainProject Pre Init
Apache Ant(TM) version 1.9.7 compiled on April 9 2016
test.test.test=isset
init:
deps-clean:
Updating property file: C:\sandbox\MainProject\build\built-clean.properties
SubProject Pre Init
test.test.test=${test.test.test}
SubProject.init:
SubProject.deps-clean:
Updating property file: C:\sandbox\MainProject\build\built-clean.properties
Deleting directory C:\sandbox\SubProject\build
SubProject.clean:
Deleting directory C:\sandbox\MainProject\build
clean:
MainProject Pre Init
Apache Ant(TM) version 1.9.7 compiled on April 9 2016
test.test.test=isset
init:
deps-jar:
Created dir: C:\sandbox\MainProject\build
Updating property file: C:\sandbox\MainProject\build\built-jar.properties
SubProject Pre Init
test.test.test=${test.test.test}
SubProject.init:
SubProject.deps-jar:
Created dir: C:\sandbox\SubProject\build
Updating property file: C:\sandbox\MainProject\build\built-jar.properties
Created dir: C:\sandbox\SubProject\build\classes
Created dir: C:\sandbox\SubProject\build\empty
Created dir: C:\sandbox\SubProject\build\generated-sources\ap-source-output
Compiling 1 source file to C:\sandbox\SubProject\build\classes
SubProject.compile:
Created dir: C:\sandbox\SubProject\dist
Copying 1 file to C:\sandbox\SubProject\build
Nothing to copy.
Building jar: C:\sandbox\SubProject\dist\SubProject.jar
To run this application from the command line without Ant, try:
java -jar "C:\sandbox\SubProject\dist\SubProject.jar"
SubProject.jar:
Created dir: C:\sandbox\MainProject\build\classes
Created dir: C:\sandbox\MainProject\build\empty
Created dir: C:\sandbox\MainProject\build\generated-sources\ap-source-output
Compiling 1 source file to C:\sandbox\MainProject\build\classes
compile:
Created dir: C:\sandbox\MainProject\dist
Copying 1 file to C:\sandbox\MainProject\build
Copy libraries to C:\sandbox\MainProject\dist\lib.
Building jar: C:\sandbox\MainProject\dist\MainProject.jar
To run this application from the command line without Ant, try:
java -jar "C:\sandbox\MainProject\dist\MainProject.jar"
jar:
BUILD SUCCESSFUL (total time: 4 seconds)
MainProject
で設定されているように、SubProject
に${test.test.test}
変数の状態を表示させるにはどうすればよいですか?
編集 - 自分のプロジェクト用に自動生成されたNetBeans ant
を使用しています。 Netbeansはbuild-impl.xml
とbuild.xml
を作成します。 ant
プロセスを呼び出すと、build-impl.xml
のターゲットが呼び出されます。その後、build-impl.xml
は私のカスタムコードをbuild.xml
で呼び出します。たとえば、NetBeans IDEでclean and build
を実行すると、build-impl.xml
の適切なターゲットが呼び出され、build-impl.xml
はbuild.xml
のカスタムコードを呼び出します。私はbuild-impl.xml
のスクリプトを投稿することができますが、それらはNetbeans IDEによって生成されたものだけです。
メインとサブのターゲット '-pre-init'も表示されます。何らかの理由? – Rao
サブプロジェクトのターゲットはどのように呼び出されますか?再現可能なビルドスクリプトを投稿できますか?また、サブサント(https://ant.apache.org/manual/Tasks/subant.html – Rao
Rao)を使用できるかどうかを確認してください。返信いただきありがとうございます。ご質問にお答えするために、私はNetBeans IDEを使用しています。 NetBeansは 'build-impl.xml'と' build.xml'を作成します。私は私の 'build.xml'を私の追加コードで掲示しました。私は 'build-impl.xml'を投稿できますが、IDEによって自動生成されています。ビルドを実行すると 'build-impl.xml'のターゲットが呼び出され、' build.xml'のカスタムコードが引き出されます。 '-pre-init'ターゲットは' build-impl.xml'によって提供され、 'build-impl.xml'で' init'ターゲットを実行する前にカスタムコードを実行します。 'build-impl.xml'ファイルにsubantがありませんでした。 –