You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme-build-and-test-aspectj.html 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <html>
  2. <title>Build and Test AspectJ</title>
  3. <body>
  4. <h1>Build and Test AspectJ</h1>
  5. This describes how to build and test AspectJ
  6. for developers working on source code for AspectJ.
  7. It covers building with Ant or Eclipse and testing with
  8. JUnit and the harness used for compiler tests.
  9. For information on how the build works and how to
  10. debug failed builds, see
  11. <a href="readme-build-module.html">
  12. readme-build-module.html</a>.
  13. <ol>
  14. <li>Quick start</li>
  15. <li>Requirements</li>
  16. <li>Standard builds</li>
  17. <ol>
  18. <li>Building using Ant</li>
  19. <li>Building with Eclipse</li>
  20. <li>Running the Ant build scripts from Eclipse</li>
  21. <li>Using Eclipse to compile but Ant to assemble</li>
  22. </ol>
  23. <li>Running build products
  24. <ol>
  25. <li>Running the compiler, browser, or harness from the command-line</li>
  26. <li>Running the compiler, browser, or harness from Eclipse</li>
  27. <li>Running Ant-built jars from Eclipse</li>
  28. </ol>
  29. </li>
  30. <li>Testing AspectJ
  31. <ol>
  32. <li>Running JUnit tests in Eclipse</li>
  33. <li>Running JUnit tests from the command-line without Eclipse</li>
  34. <li>Running JUnit tests from Ant without Eclipse</li>
  35. <li>Using the test harness to run compiler tests</li>
  36. </ol>
  37. </li>
  38. <li>Releases
  39. <ol>
  40. <li>Release builds</li>
  41. <li>Release preconditions and testing</li>
  42. <li>Release completion</li>
  43. </ol>
  44. </li>
  45. <li>Build Problems</li>
  46. </ol>
  47. <h3>Quick start</h3>
  48. This is a minimal introduction to building and testing AspectJ.
  49. <p>Command-line users use CVS to check out something like this:
  50. <pre>
  51. export CVS_ROOT=":pserver:anonymous@dev.eclipse.org:/home/technology"
  52. cvs co org.aspectj/modules</pre>
  53. If using Eclipse, check out the subdirectories of
  54. <code>org.aspectj/modules</code> as Java projects.
  55. Skip modules <code>aspectj-attic</code> and (unless running
  56. compiler tests) <code>tests</code> and most <code>testing*</code>
  57. modules. Do not skip <code>testing-utils</code>,
  58. which is used by other modules.
  59. <p>Build an AspectJ distribution:
  60. <pre>
  61. cd org.aspectj/modules/build
  62. ../lib/ant/bin/ant -f build.xml</pre>
  63. To speed the build, Eclipse users can adopt the Eclipse-produced .class files:
  64. <pre> ../lib/ant/bin/ant -f build.xml -Dbuild.config=useEclipseCompiles</pre>
  65. Install the distribution (e.g., into build/../aspectj-install):
  66. <pre> java -jar ../aj-build/dist/aspectj-DEVELOPMENT.jar</pre>
  67. You can skip the GUI by specifying an existing, empty writable
  68. target directory using <code>-to {targDir}</code>:
  69. <pre> java -jar ../aj-build/dist/aspectj-DEVELOPMENT.jar -to .</pre>
  70. Test it by running the build script in the examples directory:
  71. <pre> cd ../aspectj-install/doc/examples
  72. ../../ant/bin/ant</pre>
  73. This should build and run the spacewar example.
  74. <h3>Requirements</h3>
  75. To build requires only the AspectJ project modules.
  76. All necessary libraries and tools are in the
  77. <a href="../lib/">lib</a> directory. For command-line users,
  78. that usually means checking out the modules directory:
  79. <pre>
  80. export CVS_ROOT=":pserver:anonymous@dev.eclipse.org:/home/technology"
  81. cvs co org.aspectj/modules
  82. </pre>
  83. Eclipse users should check out subdirectories of
  84. <code>org.aspectj/modules</code> as a Java project.
  85. <p>Not all modules are required.
  86. The <code>aspectj-attic</code> module only has old code,
  87. and the <code>tests</code> and <code>testing-*</code> modules
  88. are only needed to run tests.
  89. <h3>Standard builds</h3>
  90. <h4>Building using Ant</h4>
  91. To do a build, use Ant to run <a href="build.xml">build.xml</a>
  92. from this <a href=".">build</a> directory.
  93. To run Ant, use the project's <a href="../lib/ant">../lib/ant</a>
  94. scripts and libraries, not your own.
  95. The default target builds the AspectJ distribution;
  96. see the <a href="build.xml">build.xml</a> for other targets.
  97. Consider defining the following flag properties:
  98. <p>
  99. <table cellpadding="1" border="1">
  100. <tr><th>Property</th><th>Meaning</th>
  101. </tr>
  102. <tr><td>module.name
  103. </td><td>To build any module (esp. those not directly supported
  104. by a target), use the "any-module" target and define
  105. the module name.
  106. </td></tr>
  107. <tr><td>check.build.jar
  108. </td><td>any value cause build to fail if
  109. <code>lib/build/build.jar</code> is out of date. (This is a
  110. built archive of the build module to avoid bootstrapping.)
  111. </td></tr>
  112. <tr><td>build.config
  113. </td><td>override default configuration in build.xml.
  114. Significant values include "verbose" for more output
  115. and "useEclipseCompiles" to assume that Eclipse has
  116. compiled modules into their bin directories, and just
  117. assemble those classes.
  118. </td></tr>
  119. </table>
  120. <p>
  121. For example, to build everything into a release bundle,
  122. with verbose logging
  123. <pre>
  124. cd modules/build
  125. ../lib/ant/bin/ant
  126. </pre>
  127. To build only the asm module (and any modules it requires):
  128. <pre>
  129. cd modules/build
  130. ../lib/ant/bin/ant -f build.xml any-module -Dmodule.name=asm
  131. </pre>
  132. To build the test harness into
  133. <code>../aj-build/jars/testing-drivers-all.jar</code>:
  134. <pre>
  135. cd modules/build
  136. ../lib/ant/bin/ant -f build.xml build-testing-drivers
  137. </pre>
  138. <h4>Building with Eclipse</h4>
  139. As mentioned above, the modules are Eclipse Java projects, so
  140. once checked out, they should build as-is. That will enable you
  141. to run the compiler or test harness from within Eclipse (see below),
  142. but it will not build the AspectJ release as Ant does.
  143. <h4>Running the Ant build scripts from Eclipse</h4>
  144. When running Ant from Eclipse, be sure to replace the Eclipse Ant
  145. libraries with ours. In the Ant configuration, remove all jars
  146. specified by Eclipse and add all the libraries in
  147. <a href="../lib/ant/lib">../lib/ant/lib</a>
  148. as well as in <a href="../lib/junit">../lib/junit</a>.
  149. (Do not add <code>../lib/build/build.jar</code>, which is
  150. added via a taskdef declaration.)
  151. <p>
  152. If you find on rebuilding that the build products are not
  153. being regenerated, you may need to manually delete them
  154. or restart eclipse (the files are not being closed); see
  155. <a href="readme-build-module.html">readme-build-module.html</a>
  156. for more information.
  157. <h4>Using Eclipse to compile but Ant to assemble</h4>
  158. Assuming Eclipse is compiling the AspectJ modules successfully,
  159. you can use Ant to assemble the eclipse-build .class files into a
  160. product by including <code>useEclipseCompiles</code> in the
  161. <code>build.config</code>
  162. variable as described above. That reduces the build process
  163. to product assembly, which can be completed in a couple minutes.
  164. (And of course you can run Ant from Eclipse as described above.)
  165. <h4>Running the compiler, browser, or harness from the command-line</h4>
  166. The build produces jar files in
  167. <a href="../aj-build/jars/">../aj-build/jars/</a>,
  168. some of which have manifests specifying the main class, so they
  169. can be run using <code>java -jar {file} {arguments}</code>.
  170. <p>To run the compiler from the command-line, use the <code>ajbrowser</code> jar file:
  171. <pre>
  172. java -jar aj-build/jars/ajbrowser-all.jar {compile arguments}
  173. </pre>
  174. This will run <code>ajbrowser</code> if you provide no arguments or
  175. only (unflagged) .lst file arguments. To run the test harness,
  176. use the <code>testing-drivers</code> jar file:
  177. <pre>
  178. java -jar aj-build/jars/testing-drivers-all.jar tests/ajcTests.xml ...
  179. </pre>
  180. <h4>Running the compiler, browser, or harness from Eclipse</h4>
  181. To run things within Eclipse, create a run configuration from the
  182. defining module using the main class:
  183. <p>
  184. <table border="1" cellpadding="1">
  185. <tr><th>Program</th><th>Module</th><th>Main</th></tr>
  186. <tr><td>AspectJ compiler</td><td>org.aspectj.ajdt.core</td><td>org.aspectj.tools.ajc.Main</td></tr>
  187. <tr><td>AspectJ browser</td><td>ajbrowser</td><td>org.aspectj.tools.ajbrowser.Main</td></tr>
  188. <tr><td>Test harness</td><td>testing-drivers</td><td>org.aspectj.testing.drivers.Harness</td></tr>
  189. </table>
  190. <h4>Running Ant-built jars from Eclipse</h4>
  191. You can run build products (built jars) from Eclipse in two ways:
  192. <ul>
  193. <li>Put them on the classpath of some run configuration</li>
  194. <li>Select the jar files and right-click to "open with default editor"
  195. (assuming your system is configured to run .jar files)</li>
  196. </ul>
  197. You might do this to run the installer or test the browser as built.
  198. However, doing so might prevent those jar files from being recreated
  199. in the next build.
  200. It appears that sometimes these jar files are not close during the
  201. Eclipse session, which means they cannot be overwritten in new builds,
  202. even those run from a different Ant process.
  203. If you find that builds are silently failing, try deleting the
  204. build products.
  205. <h3>Testing AspectJ</h3>
  206. Each module has a tree of JUnit tests in the <code>testsrc</code> directory.
  207. These parallel the <code>src</code> directories and contain roll-up suites
  208. for each package
  209. (<code>{module}/testsrc/{packagePath}/{package}Tests.java</code>) and
  210. for the module as a whole
  211. (<code>{module}/testsrc/{module}ModuleTests.java</code>).
  212. <p>The AspectJ project also has <i>additional</i> custom tests in the
  213. <a href="../tests">tests module</a>,
  214. mainly the compiler tests run by the harness in
  215. <a href="../tests/ajcTests.xml">ajcTests.xml</a>. <u>It is important
  216. to run these additional compiler tests (not covered by the JUnit
  217. suite) before and after any change to the compiler.</u>
  218. </p>
  219. <h4>Running JUnit tests in Eclipse</h4>
  220. JUnit tests may be run under eclipse by selecting any JUnit source file
  221. and creating a run configuration for it.
  222. To run all the JUnit tests, use Ant to "build"
  223. <a href="../tests/junitModules.xml">../tests/junitModules.xml</a>.
  224. This file uses the eclipse module bin directories as its classpath,
  225. so it will not work for someone not compiling with Eclipse.
  226. <h4>Running JUnit tests from the command-line without Eclipse</h4>
  227. The AspectJ project committers do not do this, but it should work fine.
  228. The trick is to build the modules with their associated test code
  229. (which happens by default)
  230. and put the resulting jars on the classpath with the JUnit harness.
  231. <h4>Running JUnit tests from Ant without Eclipse</h4>
  232. This entails editing
  233. <a href="../tests/junitModules.xml">../tests/junitModules.xml</a>
  234. to use a classpath containing the built module jars as described above.
  235. [todo: update junitModules.xml with non-eclipse variant]
  236. <h4>Using the test harness to run compiler tests</h4>
  237. The <code>build-testing-drivers</code> target builds a single jar with
  238. the AspectJ binaries and a test harness as the main class.
  239. It reads test suite files like
  240. <a href="../tests/ajcTests.xml">../tests/ajcTests.xml</a>;
  241. use the -help flag to see available options.
  242. For more information, see
  243. <a href="../tests/readme-tests-module.html">
  244. ../tests/readme-tests-module.html</a>.
  245. <p>
  246. <hr>
  247. <h3><a name="releases"></a>Releases</h3>
  248. <h4>Release builds</h4>
  249. Committers do official release builds to create the distribution
  250. released in binary form from the web site.
  251. Release builds differ only in running
  252. from a clean, up-to-date tree and with correct build version values
  253. in <a href="build-properties.xml">build-properties.xml</a>, which
  254. will update <code>org.aspectj.bridge.Version</code>.
  255. Do not run using the <code>build.config</code> value
  256. <code>useEclipseCompiles</code>,
  257. because this will include testing classes in the release libraries.
  258. See <a href="#version">Version synchronization</a> below
  259. for more details on how the version is updated.
  260. <h4>Release preconditions and testing</h4>
  261. <p>
  262. Normally, we do releases only after fixing all high-priority
  263. (P1 and P2) bugs in the bug database
  264. (<a href="http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&priority=P1&priority=P2">
  265. All open AspectJ bugs with P1 and P2</a>).
  266. For bug fixes, associated tests in
  267. <code>tests/ajcTestsFailing.xml</code> are fixed and moved to
  268. <code>tests/ajcTests.xml</code>.
  269. <p>Before a release, run the release tests as described in
  270. <a href="../tests/readme-release-tests.html">
  271. ../tests/readme-release-tests.html</a>
  272. (deprecated? using:
  273. <a href="../build/release-checklist.txt">
  274. ../build/release-checklist.txt</a>).
  275. <h4>Release completion</h4>
  276. When the release build is accepted,
  277. tag the tree with the release version
  278. so others can do diffs or create patches
  279. based on the release code. E.g., from the command line:
  280. <pre>
  281. cd org.aspectj/
  282. cvs tag -R -c v1_1_0
  283. </pre>
  284. <p>
  285. Pushing the release out to the web involves manually updating
  286. <code>aspectj-home/</code> with the release files
  287. (and documentation, if it is not a preview release),
  288. verifying the downloads and pages,
  289. and sending any release notifications.
  290. Save the release installer, test results, and any notes
  291. about deferred bugs or tests in
  292. <code>org.aspectj/releases/aspectj-{version}/</code>.
  293. <p>
  294. <hr>
  295. <h3>Build problems</h3>
  296. Some build problems and fixes encountered in the past:
  297. <ul>
  298. <li>If your compiles fail because Ant cannot find <code>javac</code>,
  299. put the JDK bin directory on your PATH and/or define
  300. the JAVA_HOME environment variable.
  301. Ant requires the path to the <code>javac</code> executable
  302. when the <code>BuildModule</code> taskdef runs. I think it either
  303. gets it from <code>$JAVA_HOME</code> or if the <code>bin</code>
  304. directory is on the <code>PATH</code>.
  305. </li>
  306. <li>If using an IBM JDK at version 1.4 or higher within Eclipse,
  307. then the default value of JRE_LIB will point to the jar file
  308. "core.jar." Unlike the Sun JDK, IBM does not package the full
  309. runtime into a single jar ("rt.jar"), but instead has multiple
  310. jar files. Since core.jar does not contain the graphics libraries,
  311. several of the AspectJ projects will fail to build as checked out
  312. of CVS - there are missing dependencies on AWT and swing. The
  313. solution is to add graphics.jar to the project classpaths... BUT
  314. if this is added as an ordinary (external jar), then the main
  315. ant build script will pick up the contents of graphics.jar and
  316. include it in the aspectj distribution (obvious clue, the size of
  317. the built aspectjtools.jar doubles to about 10MB). Instead, from the
  318. Java Build Path properties page of the project, select "Add Library"
  319. and add the JDK library. You now have to remove the JRE_LIB entry
  320. from the project or Eclipse complains about duplicate jar files
  321. in the path.
  322. </li>
  323. <ul>
  324. </body>
  325. </html>