aboutsummaryrefslogtreecommitdiffstats
path: root/bcel-builder/build.xml
blob: 1d78092673935718bf7f71545c22857be1c201c5 (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
<project default="packageAndPush" basedir=".">

  <!-- top-level -->
  <target name="extractAndPatchAndJar" depends="extractAndPatch,jar,srcjar" />

  <target name="extractAndPatch" depends="unzipSource,createPatchedSource" />
  
	<target name="packageAndPush" depends="buildTheJars,push"/>
	
  <target name="jar" depends="pack">
    <copy file="../lib/regexp/jakarta-regexp-1.2.jar"
        tofile="bcel/lib/Regex.jar" />
    <ant dir="bcel" target="jar" />
    <copy file="bcel/bin/bcel.jar" toDir="." />
  </target>
  
  <target name="srcjar" depends="pack">
    <zip basedir="bcel" destfile="bcel-src.zip" includes="*/**" excludes="bin/**,lib/**"/>
  </target>
  
  <target name="push">
    <copy file="bcel.jar" todir="../lib/bcel" />
    <copy file="bcel-src.zip" todir="../lib/bcel" />
  </target>
	
  <target name="buildTheJars">
  	<zip file="bcel.jar" basedir="bin" includes="**/*" excludes="**/tests/*.class"/>
  	<zip file="bcel-src.zip" basedir="src" includes="**/*"/>
  </target>
  
  <target name="diff" depends="transformFromAJ,pack">
  
    <!-- Wipe out some of the rubbish that can arise due to doing a 'ant jar' before doing the diff -->
    <delete dir="bcel/bin"/>
    <delete dir="bcel/lib"/>

    <exec dir="." executable="diff.exe" output="patch.txt">
      <arg line="-N"/> <!-- Treat absent files as empty -->
      <arg line="-a"/> <!-- Treat all files as text -->
      <arg line="-u"/> <!-- Output (default 3) lines of unified context -->
      <arg line="-r"/> <!-- Recursively compare any subdirectories found -->
      <arg line="-b"/> <!-- Ignore changes in the amount of white space -->
      <arg line="bcel-5.1" />
      <arg line="bcel" />
    </exec>
  </target>
 
  <target name="clean">
    <delete dir="bcel-5.1" />
    <delete dir="bcel" />
    <delete file="bcel.jar" />
    <delete file="bcel-src.zip" />
    <!--delete dir="src" /-->
    <mkdir dir="src" /> <!-- empty src dir -->
  </target>
 
  <!-- internals -->

  <target name="unzipSource">
    <delete dir="bcel-5.1" />
    <unzip src="bcel-5.1-src.zip" dest="." />
  </target>
  
  <target name="createPatchedSource" depends="patch,unpack,transformToAJ" />

  <target name="patch">
    <delete dir="bcel" />
    <copy todir="bcel">
      <fileset dir="bcel-5.1" />
    </copy>
    <patch patchfile="patch.txt" strip="1" dir="bcel" />
  </target>

  <target name="pack">
    <delete dir="bcel/src/java" />
    <copy toDir="bcel/src/java">
      <fileset dir="src" />
    </copy>
  </target>

  <target name="unpack">
    <delete dir="src" />
    <copy toDir="src">
      <fileset dir="bcel/src/java" >
      </fileset>
    </copy>
  </target>
	
	  <target name="transformFromAJ">
	    <delete dir="src-temp" />
	  	
	  	<echo message="Copying 'src' to 'src-temp' and modifying file names to remove aspectj"/>
	  	
	    <copy toDir="src-temp">
	      <fileset dir="src"/>
	      <mapper type="regexp" from="^(.*)aspectj\\apache(.*)$" to="\1apache\2"/>
	    </copy>
	  	
	  	<delete dir="src"/>
	  	
	  	<echo message="Modifying file contents to change refs from 'org.aspectj.apache.bcel' to 'org.apache.bcel'"/>
	  	<replaceregexp byline="true" flags="g">
	  		<regexp pattern="org.aspectj.apache.bcel"/>
			<substitution expression="org.apache.bcel"/>
			<fileset dir="src-temp">
	  			<include name="**/*"/>
	  		</fileset>			
	  	</replaceregexp>
	  	
	  	<echo message="Copying from 'src-temp' back to 'src'"/>
	  	<copy toDir="src">
		   <fileset dir="src-temp"/>
	  	</copy>
	  	<delete dir="src-temp"/>
	  </target>
	
	  <target name="transformToAJ">
	    <delete dir="src-temp" />
	  	
	  	<echo message="Copying 'src' to 'src-temp' and modifying file names to include aspectj"/>
	  	
	    <copy toDir="src-temp">
	      <fileset dir="src"/>
	      <mapper type="regexp" from="^(.*)apache(.*)$" to="\1aspectj\\apache\2"/>
	    </copy>
	  	
	  	<delete dir="src"/>
	  	
	  	<echo message="Modifying file contents to change refs from 'org.apache.bcel' to 'org.aspectj.apache.bcel'"/>
	  	<replaceregexp byline="true" flags="g">
	  		<regexp pattern="org.apache.bcel"/>
			<substitution expression="org.aspectj.apache.bcel"/>
			<fileset dir="src-temp">
	  			<include name="**/*"/>
	  		</fileset>			
	  	</replaceregexp>
	  	
	  	<echo message="Copying from 'src-temp' back to 'src'"/>
	  	<copy toDir="src">
		   <fileset dir="src-temp"/>
	  	</copy>
	  	<delete dir="src-temp"/>
	  </target>

</project>