2012-10-26 78 views
2

我有一個build.xml文件,其中包含一個定義了一些refid值的common.xml文件。但是,我的任務無法看到refid值。我一直無法在網上找到解決方案,並且正在尋求一些幫助。Ant構建腳本沒有看到refid

我在build.xml文件中調用genbeans目標。它在xmlbean taskdef上失敗,並且找不到消息引用my_classpath_jars。

的build.xml

---------------------------- 
[includes common.xml] 


**my_classpath_jars fails to be seen at this point - defined in common.xml** 

    <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean"> 
     <classpath refid="my_classpath_jars"/> 
    </taskdef> 

    <!-- Generate the XMLBeans java code from our source XSD file(s) --> 
    <target name="genbeans" description="Generate XML Bean files" depends="build_my_jar_cpath"> 
     <mkdir dir="${lib}"/> 
     <xmlbean destfile="${lib}/${appname}Beans.jar" failonerror="true"> 
      <classpath refid="my_classpath_jars"/> 
      <fileset dir="src/XSD Files" includes="*.xsd, *.wsdl"/> 
     </xmlbean> 
    </target> 


common.xml 
----------------------------- 
    <target name="build_my_jar_cpath"> 
    <path id="my_classpath_jars"> 
     <fileset dir="${jardir}" includes="**/*.jar" /> 
    </path> 
    <pathconvert pathsep="${path.separator}" property="myjar.clpath" refid="my_classpath_jars"/> 
    </target> 
+0

在調用您的目標之前,嘗試查看您的refids是否已定義您可以使用將屬性設置爲該引用id。順便說一下,當你設置id和'refid ='時,你通常使用'id ='。 –

回答

1

有疑問時,調用你的目標時,使用ant -d開關。你會看到很多輸出。將其保存到一個文件並通過它解析。

做到這一點,您在輸出中首先要注意的是,它定義了taskdef之前您已定義了my_classpath_jarsmy_classpath_jars refid只有在您致電greenbeans目標時纔會設置。您的<taskdef>在您的任何目標被調用之前執行。

要麼將​​my_classpath_jars的定義從目標greenbeans中刪除,要麼將<taskdef>放在那裏。