]> source.dussan.org Git - aspectj.git/commitdiff
tests for fixes for bugs disclosed by fixes for 40807
authorwisberg <wisberg>
Wed, 1 Oct 2003 05:25:04 +0000 (05:25 +0000)
committerwisberg <wisberg>
Wed, 1 Oct 2003 05:25:04 +0000 (05:25 +0000)
taskdefs/testdata/aspectsrc/SampleAspect.java [new file with mode: 0644]
taskdefs/testdata/aspectsrc/aspects.lst [new file with mode: 0644]
taskdefs/testdata/test-build.xml

diff --git a/taskdefs/testdata/aspectsrc/SampleAspect.java b/taskdefs/testdata/aspectsrc/SampleAspect.java
new file mode 100644 (file)
index 0000000..6ed9aab
--- /dev/null
@@ -0,0 +1,7 @@
+
+public aspect SampleAspect {
+    before () : staticinitialization(!SampleAspect) {
+        System.out.println("initializing class " + 
+            thisJoinPointStaticPart.getSignature().getDeclaringType());
+    }
+}
\ No newline at end of file
diff --git a/taskdefs/testdata/aspectsrc/aspects.lst b/taskdefs/testdata/aspectsrc/aspects.lst
new file mode 100644 (file)
index 0000000..41210a4
--- /dev/null
@@ -0,0 +1 @@
+SampleAspect.java
index cb66c09b9c3cfe42ecc27f5e16d878e346ac5eb7..20f8ed3fc2aaa5d533316b87c524be84527958e3 100644 (file)
@@ -1,9 +1,120 @@
 
-<project default="default">
-  <target name="default">
-       <taskdef properties="src/org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
-    <iajc>
-      <fileset dir="testdata" includes="Default.j*"/>
-    </iajc>
-  </target>
+<project name="aspectj-examples" default="both" basedir=".">
+
+    <target name="info" >
+      <echo>
+  This script tests the Ajc11CompilerAdapter by compiling
+  with Javac alone and then with Javac set up to use ajc.
+  This must be run with aspectjtools.jar on the Ant classpath,
+  so put it in the ant lib directory.
+  
+  It mainly tests that both work when the destination directory
+  is not specified, and that the ajc compile picks up the extra
+  arguments.  Much more could be tested.
+      </echo>
+    </target>
+
+    <!-- ============================================================= -->
+    <!-- setup and cleanup targets                                     -->
+    <!-- ============================================================= -->
+
+    <target name="clean" depends="init"
+     description="clean and create classes/jar dir, .ajesym files">
+      <delete quiet="on">
+        <fileset dir="${sourceroot.dir}" 
+               includes="**/*.ajesym,**/*.class"/>
+      </delete>
+    </target>
+
+    <target name="init"  depends="init.variables,init.taskdefs"/>
+
+    <target name="init.variables" 
+     description="init variables">
+     
+      <!-- build.compiler value to pick up our CompilerAdapter for javac -->
+      <property name="ajc.adapter"
+                  value="org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter"/>
+
+      <!-- required directories - run from examples or predefine -->
+      <property name="temp.dir"
+            location="${basedir}/temp"/> 
+      <property name="sourceroot.dir"
+            location="${basedir}/sourceroot"/> 
+      <property name="aspect.dir"
+            location="${basedir}/aspectsrc"/> 
+      <property name="aspectj.lib.dir"
+            location="${ASPECTJ_HOME}/lib"/> 
+
+      <!-- required libraries - install or predefine -->
+      <property name="aspectjrt.jar"
+            location="${aspectj.lib.dir}/aspectjrt.jar"/> 
+      <property name="aspectjtools.jar"
+            location="${aspectj.lib.dir}/aspectjtools.jar"/> 
+            
+      <!-- checking required libraries -->
+      <available file="${aspectjtools.jar}"
+             property="aspectjtools.jar.available"/>
+      <available file="${aspectjrt.jar}"
+             property="aspectjrt.jar.available"/>
+
+    </target>
+
+    <target name="init.taskdefs" depends="init.variables, 
+         aspectjtools.jar.available,
+         aspectjrt.jar.available"
+         unless="taskdefs.init">
+      <!-- sets name of new task to iajc, old task to ajc -->
+      <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
+         <property name="taskdefs.init" value="true"/>
+    </target>
+
+    <target name="aspectjrt.jar.available" depends="init.variables" 
+          unless="aspectjrt.jar.available" >
+      <fail message="expecting aspectjrt.jar at ${aspectjrt.jar}"/>
+    </target>
+
+    <target name="aspectjtools.jar.available" depends="init.variables" 
+          unless="aspectjtools.jar.available" >
+      <fail message="expecting aspectjtools.jar at ${aspectjtools.jar}"/>
+    </target>
+
+    <!-- ..................................................... -->
+       <target name="both">
+               <antcall target="compile-and-run"/>
+               <antcall target="compile-and-run-ajc"/>
+       </target>
+
+    <target name="compile-and-run-ajc" depends="init">
+               <antcall target="compile-and-run">
+                       <param name="build.compiler" value="${ajc.adapter}"/> 
+               </antcall>
+       </target>
+
+    <target name="compile-and-run" depends="init">
+       <antcall target="clean" />
+       <javac verbose="true">
+         <src path="${sourceroot.dir}"/>
+         <include name="**/*.java"/>
+         
+                <compilerarg 
+                       compiler="${ajc.adapter}" 
+                       value="-argfile"/>
+                <compilerarg 
+                       compiler="${ajc.adapter}" 
+                       file="${aspect.dir}/aspects.lst"/>
+                <compilerarg compiler="${ajc.adapter}" 
+                       value="-classpath"/>
+                <compilerarg compiler="${ajc.adapter}" 
+                       value="${aspectjrt.jar}"/>
+       </javac>        
+       <java classname="Default">
+               <classpath>
+                       <pathelement path="${aspectjrt.jar}"/>
+                       <pathelement path="${sourceroot.dir}"/>
+                       <pathelement path="${aspect.dir}"/>
+                       </classpath>
+               </java>   
+       <antcall target="clean" />
+    </target>
+       
 </project>