You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2010/02/22 06:06:59 UTC

svn commit: r912483 - /tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml

Author: nash
Date: Mon Feb 22 05:06:59 2010
New Revision: 912483

URL: http://svn.apache.org/viewvc?rev=912483&view=rev
Log:
Refactor conditional logic for better consistency and readability

Modified:
    tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml

Modified: tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml?rev=912483&r1=912482&r2=912483&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml (original)
+++ tuscany/sca-java-1.x/trunk/tutorials/travelsample/antdefs.xml Mon Feb 22 05:06:59 2010
@@ -34,7 +34,7 @@
        been tested with JUnit version 4.5.
      JAXWS_HOME (only if using JDK 5) A directory containing the JAX-WS
        reference implementation.  This build file has been tested with
-       JAX-WS version 2.1.7.
+       the JAX-WS RI version 2.1.7.
 
    This file defines the following targets that can be used on the
    ant command that invokes the build.xml file:
@@ -64,16 +64,13 @@
         resource directory, unless the jar file is already up to date.
         If the build.xml file defines a path with id "package-path", this
         path is used for the Class-Path manifest entry.
-     "run" Runs the class specified by the "run-class" property in the
-        build.xml file if this property is defined.  If the build.xml file
-        contains a <path> element with id "run-path", the contents of this
-        path are added to the run classpath.
      "clean" Deletes all the files produced by the build.
 
    This file also defines the following targets for invocation by <antcall>
    from the build.xml file:
-     "wsimport" Generates Java code from a WSDL file (unless the Java
-       code is already up to date) by running the JDK wsimport command.
+     "wsimport" Generates Java code from a WSDL file (unless the Java code
+       is already up to date) by running the wsimport command (on JDK 6)
+       or by calling the equivalent class in the JAX-WS RI (on JDK 5).
        Requires the following parameters:
        . <package> the Java package to use for generated code
        . <wsdlfile> the filename of the WSDL file
@@ -92,8 +89,7 @@
            generated by running this target for this IDL file
 
    All other targets defined by this file (with names starting with "#")
-   are for internal use from within this file and are not intended to
-   be used externally.
+   are for internal use within this file and should not be used externally.
 -->
 
 <project name="antdefs">
@@ -131,15 +127,14 @@
         </condition>
     </target>
 
-    <!-- run the JDK wsimport command if required -->
+    <!-- run the wsimport command if required -->
     <target name="wsimport" depends="#wsdlcheck" unless="#wsdl-uptodate">
-        <antcall target="#wsimport-jdk"/>
-        <antcall target="#wsimport-jaxws"/>
+        <antcall target="#wsimport"/>
 	</target>
 
-    <!-- check whether the JDK wsimport command is available -->
-    <target name="#jdk-wsimport">
-        <condition property="#bin-wsimport">
+    <!-- check whether the wsimport command is available in the JDK -->
+    <target name="#is-jdk-wsimport">
+        <condition property="#jdk-wsimport">
             <or>
                 <available file="${java.home}/../bin/wsimport" type="file"/>
                 <available file="${java.home}/../bin/wsimport.exe" type="file"/>
@@ -148,7 +143,7 @@
     </target>
 
     <!-- run the JDK wsimport command if available -->
-    <target name="#wsimport-jdk" depends="#jdk-wsimport" if="#bin-wsimport">
+    <target name="#wsimport-jdk" if="#jdk-wsimport">
         <mkdir dir="target/jaxws-source"/>
         <exec executable="${java.home}/../bin/wsimport" dir="." failonerror="true">
             <arg line="-keep -s ./target/jaxws-source -p ${package} 
@@ -157,7 +152,7 @@
     </target>
 
     <!-- run the com.sun.tools.ws.WsImport class in jaxws-tools.jar if available -->
-    <target name="#wsimport-jaxws" depends="#jdk-wsimport" unless="#bin-wsimport">
+    <target name="#wsimport-jaxws" unless="#jdk-wsimport">
         <condition property="#jaxws-tools">
             <available file="${env.JAXWS_HOME}/lib/jaxws-tools.jar" type="file"/>
         </condition>
@@ -172,6 +167,9 @@
         </java>
     </target>
 
+    <!-- run the wsimport command in JDK 6 or use jaxws-tools.jar on JDK 5 -->
+    <target name="#wsimport" depends="#is-jdk-wsimport, #wsimport-jdk, #wsimport-jaxws"/>
+
     <!-- run the SDO XSD2JavaGenerator if required, then compile the generated Java source -->
     <target name="sdojavagen" depends="#wsdlcheck" unless="#wsdl-uptodate">
         <mkdir dir="target/sdo-source"/>
@@ -247,6 +245,11 @@
         </condition>
     </target>
 
+    <!-- compile the Java source files -->
+    <target name="#src-compile" depends="#find-javafiles" if="#javafiles">
+        <antcall target="#run-compile"/>
+    </target>
+
     <!-- check whether a dependency path for the Java compiler was specified -->
     <target name="#check-compile-path">
         <condition property="#compile-path">
@@ -255,19 +258,22 @@
     </target>
 
     <!-- set classpath for Java compiler to include specified additional path -->
-    <target name="#set-classpath" depends="#check-compile-path" if="#compile-path">
+    <target name="#set-compile-path" if="#compile-path">
         <path id="#javac-classpath">
             <path refid="compile-path"/>
         </path>
     </target>
 
     <!-- set default classpath for Java compiler if no additional path specified -->
-    <target name="#default-classpath" depends="#check-compile-path" unless="#compile-path">
+    <target name="#default-compile-path" unless="#compile-path">
         <path id="#javac-classpath"/>
     </target>
 
+    <!-- set the Java compiler classpath -->
+    <target name="#set-javac-classpath" depends="#check-compile-path, #set-compile-path, #default-compile-path"/>
+
     <!-- compile the Java source files -->
-    <target name="#compile-src" depends="#find-javafiles, #set-classpath, #default-classpath" if="#javafiles">
+    <target name="#run-compile" depends="#set-javac-classpath">
         <javac destdir="target/classes" debug="true" source="1.5" target="1.5">
             <src path="src/main/java"/>
             <classpath>
@@ -344,19 +350,35 @@
     </target>
 
     <!-- set classpath for unit tests to include specified additional path -->
-    <target name="#set-test-classpath" depends="#check-test-path" if="#test-path">
+    <target name="#set-test-path" if="#test-path">
         <path id="#test-classpath">
             <path refid="test-path"/>
         </path>
     </target>
 
     <!-- set default classpath for unit tests if no additional path specified -->
-    <target name="#default-test-classpath" depends="#check-test-path" unless="#test-path">
+    <target name="#default-test-path" unless="#test-path">
         <path id="#test-classpath"/>
     </target>
 
+    <!-- set the Java compiler test classpath -->
+    <target name="#set-test-classpath" depends="#check-test-path, #set-test-path, #default-test-path"/>
+
+    <!-- compile the test classes -->
+    <target name="#test-compile" depends="#set-test-classpath">
+        <javac destdir="target/test-classes" debug="true" source="1.5" target="1.5">
+            <src path="src/test/java"/>
+            <classpath>
+                <pathelement location="target/classes"/>
+                <path refid="#test-classpath"/>
+                <pathelement location="${env.TUSCANY_HOME}/lib/tuscany-sca-manifest.jar"/>
+                <pathelement location="${env.JUNIT_JAR}"/>
+            </classpath>
+        </javac>
+    </target>
+
     <!-- run the junit task -->
-    <target name="#run-junit" depends="#set-test-classpath, #default-test-classpath, #set-classpath, #default-classpath">
+    <target name="#run-junit" depends="#set-test-classpath, #set-javac-classpath">
         <junit printsummary="no" dir="." fork="true" forkmode="once" haltonfailure="true">
             <classpath>
                 <pathelement location="target/test-classes"/>
@@ -387,7 +409,7 @@
     </target>
 
     <!-- build a war file if there are files in the webapp directory -->
-    <target name="#package-war" depends="#check-webapp" if="#webapp">
+    <target name="#package-war" if="#webapp">
         <fileset id="#tuscanyjars" dir="${env.TUSCANY_HOME}/modules">
             <include name="tuscany-node-api-*.jar"/>
             <include name="tuscany-node-launcher-*.jar"/>
@@ -402,12 +424,12 @@
     </target>
 
     <!-- build a jar file if there are no files in the webapp directory -->
-    <target name="#package-jar" depends="#check-webapp" unless="#webapp">
+    <target name="#package-jar" unless="#webapp">
         <antcall target="#create-jar"/>
     </target>
 
-    <!-- create a jar file with or without a Class-Path attribute -->
-    <target name="#create-jar" depends="#create-jar-path, #create-jar-nopath"/>
+    <!-- build a packaged jar file or war file -->
+    <target name="#build-package" depends="#check-webapp, #package-war, #package-jar"/>
 
     <!-- check whether a dependency path for the package target was specified -->
     <target name="#check-package-path">
@@ -417,7 +439,7 @@
     </target>
 
     <!-- create a jar file with a Class-Path attribute -->
-    <target name="#create-jar-path" depends="#check-package-path" if="#package-path">
+    <target name="#create-jar-path" if="#package-path">
         <property name="#parentdir" location=".."/>
         <pathconvert property="#package-classpath" refid="package-path" pathsep=" " dirsep="/">
             <map from="${#parentdir}" to="../.."/>
@@ -430,35 +452,30 @@
     </target>
 
     <!-- create a jar file without a Class-Path attribute -->
-    <target name="#create-jar-nopath" depends="#check-package-path" unless="#package-path">
+    <target name="#create-jar-nopath" unless="#package-path">
         <jar destfile="target/${ant.project.name}.jar" basedir="target/classes"/>
     </target>
 
+    <!-- create a jar file with or without a Class-Path attribute -->
+    <target name="#create-jar" depends="#check-package-path, #create-jar-path, #create-jar-nopath"/>
+
     <!-- for external use on the ant command line -->
     <target name="compile">
         <echo message="Compiling project ${ant.project.name}"/>
         <mkdir dir="target/classes"/>
         <antcall target="#call-wsdljava"/>
         <antcall target="#call-idljava"/>
-        <antcall target="#compile-src"/>
+        <antcall target="#src-compile"/>
         <antcall target="#copy-resources"/>
         <antcall target="#call-test"/>
         <antcall target="package"/>
     </target>
 
     <!-- for external use on the ant command line -->
-    <target name="test" depends="#find-testjava, #set-test-classpath, #default-test-classpath" if="#testjava">
+    <target name="test" depends="#find-testjava" if="#testjava">
         <echo message="Testing project ${ant.project.name}"/>
         <mkdir dir="target/test-classes"/>
-        <javac destdir="target/test-classes" debug="true" source="1.5" target="1.5">
-            <src path="src/test/java"/>
-            <classpath>
-                <pathelement location="target/classes"/>
-                <path refid="#test-classpath"/>
-                <pathelement location="${env.TUSCANY_HOME}/lib/tuscany-sca-manifest.jar"/>
-                <pathelement location="${env.JUNIT_JAR}"/>
-            </classpath>
-        </javac>
+        <antcall target="#test-compile"/>
         <antcall target="#copy-testresources"/>
         <antcall target="#test-setup"/>
         <antcall target="#run-junit"/>
@@ -467,8 +484,7 @@
     <!-- for external use on the ant command line -->
     <target name="package">
         <echo message="Packaging project ${ant.project.name}"/>
-        <antcall target="#package-war"/>
-        <antcall target="#package-jar"/>
+        <antcall target="#build-package"/>
     </target>
 
     <!-- for external use on the ant command line -->