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 7.4KB

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