aboutsummaryrefslogtreecommitdiffstats
path: root/tests/product/build-aspectj/build.xml
blob: de7e7ba99716255c7115aea0d6dd5baaf10f2e20 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!-- ========================================================================= -->
<!-- Copyright (c) 2003 Contributors.                                          -->
<!-- All rights reserved.                                                      -->
<!-- This program and the accompanying materials are made available            -->
<!-- under the terms of the Eclipse Public License v1.0                        -->
<!-- which accompanies this distribution and is available at                   -->
<!-- http://www.eclipse.org/legal/epl-v10.html                                 -->
<!--                                                                           -->
<!-- Contributors:                                                             -->
<!--     Isberg     initial implementation                                 -->
<!-- ========================================================================= -->

<project name="build-aspectj-using-aspectj" default="all" basedir=".">

    <target name="info" >
      <echo>
  This script tests the AspectJ tools and runtime
  by building the AspectJ sources.  When run, this should
  finish by emitting the ajc help message.

  Relevant targets:
     all             build and test runtime and tools
     tools           build output/aspectjtools.jar
     runtime         build output/aspectjrt.jar
     build-tools-javac build using javac to output

  Setup:

  Variables ASPECTJ_HOME and ASPECTJ_MODULES refer to the 
  base of an AspectJ install and the modules directory 
  of the AspectJ source tree.  By default they are
  
    ASPECTJ_MODULES:  $${basedir}/../..
    ASPECTJ_HOME: $${basedir}/../../aj-build/dist/tools
  
  which assumes the tools dist is built and this
  runs from modules/tests/product/build-aspectj.
  
  To disable verbose mode, set iajc.verbose to false.
       
  You can also define the properties to run on any
  distribution from anywhere:
       
    ant -DASPECTJ_HOME=dev/tools/aj -DASPECTJ_MODULES=ec

      </echo>
    </target>

    <!-- ============================================================= -->
    <!-- setup and cleanup targets                                     -->
    <!-- ============================================================= -->

    <target name="clean" depends="init"
     description="clean and create output dir">
      <delete quiet="on" dir="${output.dir}"/>
      <mkdir dir="${output.dir}"/>
    </target>

    <target name="init"  depends="init.variables,init.taskdefs"/>

    <target name="init.variables" 
     description="init variables">
     
	  <property name="iajc.verbose" value="true"/>

      <!-- 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="ASPECTJ_MODULES"
            location="${basedir}/../../.."/> 

      <property name="ASPECTJ_HOME"
            location="${basedir}/../../../aj-build/dist/tools"/> 

      <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"/> 

      <!-- created directories -->
      <property name="output.dir"
            location="${basedir}/output"/> 
      <mkdir dir="${output.dir}"/>

      <!-- checking required libraries -->
      <available file="${aspectjtools.jar}"
             property="aspectjtools.jar.available"/>
      <available file="${aspectjrt.jar}"
             property="aspectjrt.jar.available"/>

	  <property name="aspectj.src"
  	  	    location="${ASPECTJ_MODULES}"/>

	  <property name="output.aspectjtools"
	  	location="${output.dir}/aspectjtools.jar"/>
	  	
	  <property name="output.aspectjrt"
	  	location="${output.dir}/aspectjrt.jar"/>

      <available file="${aspectj.src}"
               property="aspectj.src.available"/>
	  	
	 	<path id="runtime.roots">
	 		<pathelement path="${aspectj.src}/runtime/src"/>
	 	</path>
	 	
	 	<path id="tools.roots">
	 		<pathelement path="${aspectj.src}/ajbrowser/src"/>
	 		<pathelement path="${aspectj.src}/ajde/src"/>
	 		<pathelement path="${aspectj.src}/asm/src"/>
	 		<pathelement path="${aspectj.src}/bridge/src"/>
	 		<pathelement path="${aspectj.src}/org.aspectj.ajdt.core/src"/>
	 		<pathelement path="${aspectj.src}/taskdefs/src"/>
	 		<pathelement path="${aspectj.src}/util/src"/>
	 		<pathelement path="${aspectj.src}/weaver/src"/>
	 	</path>
	 	
	 	<path id="tools.libs">
	 		<pathelement path="${aspectj.src}/lib/ant/lib/ant.jar"/>
	 		<pathelement path="${aspectj.src}/lib/bcel/bcel.jar"/>
	 		<pathelement path="${aspectj.src}/org.eclipse.jdt.core/jdtcore-for-aspectj.jar"/>
	 	</path>
    </target>

    <target name="init.taskdefs" depends="init.variables, 
         aspectjtools.jar.available,
         aspectjrt.jar.available,
         aspectj.src.available"
         unless="taskdefs.init">
      <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
          <classpath> 
            <pathelement path="${aspectjtools.jar}"/> 
          </classpath>
      </taskdef>
	  <property name="taskdefs.init" value="true"/>
    </target>

    <!-- targets to fail unless required libraries available -->

    <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="aspectj.src.available" depends="init.variables" 
          unless="aspectj.src.available" >
      <fail message="expecting aspectj sources at ${aspectj.src}"/>
    </target>
	
    <target name="all">
		<antcall target="clean" />
		<antcall target="runtime"/>
		<antcall target="tools"/>
    </target>
    
    <target name="runtime">
		<antcall target="build-runtime"/>
		<antcall target="test-runtime"/>
    </target>
    
    <target name="tools">
		<antcall target="build-tools"/>
		<antcall target="test-tools"/>
    </target>

    <target name="build-runtime" depends="init">
       <iajc outjar="${output.aspectjrt}"
          classpath="${aspectjrt.jar}"
          verbose="${iajc.verbose}"
          sourcerootsref="runtime.roots"/>
    </target>
    
    <target name="test-runtime" depends="init">
		<echo message="test-runtime not implemented"/>
    </target>
    
    <target name="build-tools" depends="init">
       <iajc outjar="${output.aspectjtools}"
       		verbose="${iajc.verbose}"
			sourcerootsref="tools.roots"
			sourcerootcopyfilter="**/CVS/*,**/*.java,**/*.aj">
			<classpath>
				<pathelement path="${aspectjrt.jar}"/> <!-- bootstrap problem... -->
				<path refid="tools.libs"/>
			</classpath>       
       </iajc>
    </target>

    <target name="test-tools" depends="init">
       <java classname="org.aspectj.tools.ajc.Main"
       	failonerror="true">
         <classpath>
          	<path refid="tools.libs"/>
            <pathelement path="${output.aspectjtools}"/> 
         </classpath>
         <arg value="-help"/>
         <arg value="-noExit"/>
       </java>
    </target>

    <target name="build-tools-javac" depends="init">
       <javac verbose="${verbose}" includes="**/*.java"
       	destdir="${output.dir}">
       	<src>
       		<path refid="tools.roots"/>
       	</src>
		<classpath>
			<pathelement path="${aspectjrt.jar}"/> 
			<path refid="tools.libs"/>
		</classpath>       
       </javac>
    </target>
</project>