You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.xml 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <project name="embed-test" default="main" basedir=".">
  2. <property name="ant.src" location="../.."/>
  3. <description>Test for embed proposal</description>
  4. <import file="build.xml"/>
  5. <!-- This is a tricky problem: import will append tasks at the
  6. end of the task list. That's a bug, it should replace the
  7. <import> task with the content. When fixed, this should show
  8. the real value. -->
  9. <echo message="Base.path from build.xml ( in top level ): ${base.path}"/>
  10. <target name="init">
  11. <property name="junit.jar" location="${base.path}/junit3.7/junit.jar"/>
  12. <echo>Base.path from build.xml ( in init ) : ${base.path}</echo>
  13. <path id="myJars" >
  14. <pathelement path="${junit.jar}" />
  15. <pathelement path="${jxpath.jar}" />
  16. <pathelement path="${velocity-dep.jar}" />
  17. <pathelement path="${velocity.jar}" />
  18. <pathelement path="${jexl.jar}" />
  19. <pathelement path="${commons-discovery.jar}" />
  20. <pathelement path="${commons-logging.jar}" />
  21. <pathelement path="${ant.home}/lib/ant-sax2.jar" />
  22. <pathelement location="/usr/share/java/xalan-j_2_3_1/bin/xercesImpl.jar"/>
  23. <pathelement location="${ant.home}/lib/xercesImpl.jar"/>
  24. <pathelement location="${ant.home}/lib/xml-apis.jar"/>
  25. <pathelement location="${ant.home}/lib/ant.jar"/>
  26. </path>
  27. <systemPath pathRef="myJars"/>
  28. </target>
  29. <target name="discovery" depends="init">
  30. <echo message="${commons-discovery.jar}"/>
  31. <systemPath pathRef="myJars"/>
  32. <taskdef classname="org.apache.tools.ant.taskdefs.ServiceDiscoveryTask"
  33. name="discovery" />
  34. <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath"
  35. name="jxpath" />
  36. <jxpath/>
  37. <discovery debug="1" id="myDiscovery"
  38. serviceName="META-INF/services/javax.xml.parsers.SAXParserFactory" />
  39. <echo message="Found ${jxpath:/references[@name='myDiscovery']}" />
  40. </target>
  41. <target name="systemPathTest" depends="init">
  42. <junit id="replacedJunit" />
  43. <echo message="Found JUNIT: ${toString:replacedJunit}" />
  44. </target>
  45. <target name="dynamicProperties" depends="init">
  46. <!-- This is Taksdef2.java - it'll use the systemPath as parent loader
  47. -->
  48. <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath"
  49. name="jxpath" />
  50. <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPathSet"
  51. name="jxpathSet" />
  52. <taskdef classname="org.apache.tools.ant.taskdefs.optional.VelocityProperties"
  53. name="velocityProperties" />
  54. <taskdef classname="org.apache.tools.ant.taskdefs.optional.JexlProperties"
  55. name="jexlProperties" />
  56. <!-- Init JxPath. '/' is the project -->
  57. <jxpath/>
  58. <velocityProperties/>
  59. <jexlProperties/>
  60. <echo id="foo" message="Starting dynamic props tests" />
  61. <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" />
  62. <jxpathSet path="/references[@name='jxpathTask']/foo" value="Test"/>
  63. <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" />
  64. <echo message="${jexl:ant.references.jxpathTask.foo=bar}" />
  65. <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" />
  66. <echo message="jexl /references/myJars: ${jexl:ant.references.myJars}" />
  67. <echo message="jxPath /targets[1]: ${jxpath:/targets[1]}" />
  68. <echo message="jxPath /references: ${jxpath:/references}" />
  69. <echo message="jxPath /references[@name='myJars']: ${jxpath:/references[@name='myJars']}" />
  70. <echo message="jxPath /references/myJars: ${jxpath:/references/myJars}" />
  71. <!-- This is XMLDOM.java - a datatype that holds an xml DOM -->
  72. <typedef name="xmldom" classname="org.apache.tools.ant.taskdefs.XMLDOM"/>
  73. <!-- Init XMLDOM. The DOM of file test.xml will be referenced via the id-->
  74. <xmldom id="test.xml" file="test.xml"/>
  75. <echo message="XMLDOM: ${jxpath:/references/test.xml/root/project/@name}" />
  76. </target>
  77. <target name="main" depends="init,dynamicProperties,systemPathTest,test-import">
  78. </target>
  79. <target name="test-import" >
  80. <antcall target="embed.main" />
  81. </target>
  82. </project>