aboutsummaryrefslogtreecommitdiffstats
path: root/taskdefs/testdata/test-build.xml
blob: 20f8ed3fc2aaa5d533316b87c524be84527958e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<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>