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-module.html 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <html>
  2. <head>
  3. <title>AspectJ build module</title>
  4. </head>
  5. <body>
  6. <h1>AspectJ build</h1>
  7. This build module contains taskdefs and resources for doing builds
  8. and checking source licenses. This document describes our approach
  9. to builds and provides some notes for maintaining the build module
  10. and debugging builds.
  11. For information
  12. on running builds and doing testing for the AspectJ project, see
  13. <a href="readme-build-and-test-aspectj.html">
  14. readme-build-and-test-aspectj.html</a>.
  15. <h3>Approach</h3>
  16. The AspectJ project source files are broken into modules,
  17. the subdirectories of the modules directory.
  18. (To eclipse users, each module is a Java or AspectJ project.)
  19. The modules are compiled independently and may be assembled
  20. by the build script into the release jar files.
  21. All required libraries are checked into the <code>lib</code> module.
  22. We use Ant to drive the build, but the logic for building and
  23. assembling modules resides in the BuildModule taskdef,
  24. which reads module dependencies from the Eclipse .classpath files
  25. and assembles the product according to the templates in the
  26. product directory.
  27. This makes it easy to change dependencies and add modules,
  28. but could make it difficult to debug if something were to go wrong.
  29. <h3>Maintaining the build module</h3>
  30. Because the BuildModule taskdef extracts dependencies from the Eclipse
  31. <code>.classpath</code> file, there is no need to update build scripts when
  32. adding or removing modules or changing their dependencies, so long
  33. as they are all in the base modules directory (usually the base of
  34. the eclipse workspace).
  35. Likewise, updating a product assembly should be easy,
  36. since they are based on introspection of the product directories.
  37. Still, the taskdef workings are not obvious in the build script, so
  38. this section makes clear some of the implicit logic
  39. in case it's required when debugging build failures or
  40. to make changes.
  41. <h4>Build module code updates</h4>
  42. The build module produces taskdefs used to run the build.
  43. The scripts avoid bootstrapping by using a build library jar
  44. checked in to
  45. <code>lib/build/build.jar</code>.
  46. That means code updates in the build module are not reflected in
  47. the build process until the <code>build.jar</code> produced by
  48. building this <code>build</code> module replaces that found in
  49. <code>lib/build/build.jar</code>. Once the module update is
  50. confirmed, the new <code>lib/build/build.jar</code> must be checked in
  51. to propogate the changes to other users.
  52. The scripts support an Ant variable <code>check.build.jar</code>
  53. by warning when <code>lib/build/build.jar</code> is out of date.
  54. <h4>BuildModule task</h4>
  55. The
  56. <a href="src/org/aspectj/internal/tools/ant/taskdefs/BuildModule.java">
  57. BuildModule</a>
  58. taskdef implements an integrated module or product build.
  59. <p/><u>Module builds</u> are based on the Eclipse <code>.classpath</code>
  60. file, and can produce
  61. a jar with the module classes, with two variations:
  62. <ul>
  63. <li> include only the module classes,
  64. or assemble the jar complete with all antecedent modules and
  65. libraries;
  66. </li><li>compile the module(s) with or without any
  67. testing source or libraries
  68. </li>
  69. </ul>
  70. If there is a file {moduleName}.mf.txt
  71. in the module directory, it will be used as the manifest for the
  72. module jar file.
  73. <p/><u>Product builds</u> are defined by introspection of a
  74. <a href="products">products</a> subdirectory like
  75. <a href="products/tools">products/tools</a> for the AspectJ installer.
  76. These have an <code>install</code> directory for installer resources
  77. and a <code>dist</code> directory containing all files belonging in
  78. the distribution, including 0-length placeholders for the module build
  79. results (e.g., <a href="products/tools/dist/lib">products/tools/dist/lib</a>).
  80. These placeholder file names are mapped to the originating
  81. module by <code>Builder.moduleAliasFor(String)</code>
  82. using values in
  83. <a href="src/org/aspectj/internal/tools/build/Builder.properties">
  84. Builder.properties</a>.
  85. (The "-all" suffix in the source jars means that the module and all required
  86. modules are included.)
  87. <p/>
  88. <a name="version"></a>
  89. <h4>Version synchronization</h4>
  90. The version is expressed in the jar manifests, in the <code>Version</code> class,
  91. and in some documentation files. The build script
  92. ensures all version expressions
  93. are aligned. When not doing or testing release builds,
  94. developers use the default "DEVELOPMENT" version.
  95. <p/>The build version is set in
  96. <a href="build-properties.xml">build-properties.xml</a> and propogated
  97. using Ant copy filters out to
  98. the <a href="../aspectj5rt/aspectj5rt.mf.txt">aspectjrt.jar manifest</a>,
  99. the <a href="../ajbrowser/ajbrowser.mf.txt">aspectjtools.jar manifest</a>
  100. and to
  101. <a href="../bridge/src/org/aspectj/bridge/Version.java">
  102. ../bridge/src/org/aspectj/bridge/Version.java</a>
  103. which the <a href="build.xml">build.xml</a> <code>init-version</code> task
  104. generates from a template
  105. <a href="lib/BridgeVersion.java.txt">lib/BridgeVersion.java.txt</a>.
  106. To avoid updating <code>Version.java</code> whenever
  107. <code>build-properties.xml</code> changes, a task
  108. <a href="src/org/aspectj/internal/tools/ant/taskdefs/VersionUptodate.java">
  109. src/org/aspectj/internal/tools/ant/taskdefs/VersionUptodate.java</a>
  110. determines whether Version.java has the same version by scanning the source file.
  111. The scan is dim-witted; do not change the lines flagged in the template
  112. without also changing the scanning code in the task.
  113. <h4>Temporary aj-{name} and persistant aspectj-{name}</h4>
  114. <p/>
  115. Top-level temporary build directories are prefixed "aj-",
  116. so you can safely destroy any such directory or ignore it
  117. in CVS or the Eclipse package explorer. By default the build script
  118. puts them at the same level as other modules. In build scripts, property names
  119. follow a similar convention; those prefixed "aj-" may be deleted at will, while
  120. "aspectj-" names are source directories which should never be deleted.
  121. <h4>Building Java 5 sources</h4>
  122. <p/>
  123. Java 5 source is supported in <code>{module}/java5-src</code> directories.
  124. Under Ant, when building in a pre-Java-5 VM, this source will be ignored
  125. (hence, it must not be required to compile). Under Eclipse, developers
  126. not using Java 5 should close the corresponding modules.
  127. <h4>Builder.properties, resources, and tree audit tests</h4>
  128. <p/>
  129. In <a href="src/org/aspectj/internal/tools/build/Builder.properties">
  130. src/org/aspectj/internal/tools/build/Builder.properties</a>
  131. you can set up
  132. <ul>
  133. <li>product aliases for mapping module jars</li>
  134. <li>libraries to exclude for assembling module jars</li>
  135. <li>patterns for copying resources.</li>
  136. </ul>
  137. Regarding the patterns, if you add a resource with an unrecognized suffix to a
  138. source tree, the corresponding unit test in
  139. <a href="testsrc/BuildModuleTests.java">testsrc/BuildModuleTests.java</a>
  140. will fail. You'll need to update the <code>Builder.properties</code>
  141. file (and recreate the build.jar) to ensure that the new resource
  142. is copied to the assembled module jar.
  143. <h3>Debugging build problems</h3>
  144. <h4>Running under Eclipse</h4>
  145. When running Ant from eclipse,
  146. do not use the default Eclipse Ant classpath; remove those jars and
  147. add all the libraries in <a href="../lib/ant/lib">../lib/ant/lib</a>
  148. as well as in <a href="../lib/junit">../lib/junit</a>.
  149. If the build is failing under eclipse or Ant and the problem appears
  150. to be in the build module, you can run the build directly in eclipse
  151. (not using the Ant script) by running the skipped JUnit tests in
  152. <a href="testsrc/org/aspectj/internal/build/ModulesTests.java">
  153. testsrc/org/aspectj/internal/build/ModulesTests.java</a>.
  154. <p/>
  155. <h4>Why new or changed modules might not work</h4>
  156. The BuildModule taskdef makes some assumptions about the naming,
  157. position, and contents of module directories and files.
  158. Understand those (documented in
  159. <a href="src/org/aspectj/internal/tools/ant/taskdefs/BuildModule.java">
  160. BuildModule.java</a>) before using non-standard module directories.
  161. <h4>Silent classpath and build failures</h4>
  162. <u>warning</u>: When Ant runs compile processes, sometimes Jar files
  163. are not closed until the process quits. When running Ant under Eclipse,
  164. that means the jar files are not writable until eclipse quits.
  165. This affects build products (e.g., installers) which are run under eclipse
  166. (e.g., by opening with the "default system editor") and libraries used
  167. when compiling under Javac (if not zip products or input). This problem
  168. presents as files not being writable, i.e., deleted or modified.
  169. <p/>
  170. One workaround is to delete any existing build products
  171. before re-creating them. The problem with this is that Ant provides no
  172. notice of that deletes fail when deleting with quiet="on", but when not
  173. running in quiet mode, deletes will fail if the directory does not exist.
  174. The workaround-workaround would be to create any required directories
  175. before trying to deleting any files, with the result of creating unused
  176. empty directories.
  177. <p/>
  178. Currently BuildModule tasks forks the Javac command to try to work around
  179. this problem, but the Zip commands do not work around it.
  180. If under Eclipse, you get strange behavior with Ant builds, clear
  181. out everything and build from the command line. In some cases, you
  182. have to exit Eclipse before files can be deleted. (*sigh*)
  183. <p/>
  184. </body>
  185. </html>