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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. # Maven build options
  2. AspectJ is based on a multi-module Maven build with several options influencing
  3. * what to build,
  4. * whether to run tests,
  5. * whether to created documentation for the AspectJ website,
  6. * whether to create source and javadoc artifacts,
  7. * whether to GPG-sign artifacts for a release.
  8. ## Typical build scenarios
  9. As a developer, which modules or artifacts you want to build depends on your situation. For example:
  10. * When building a stable, non-snapshot release (milestone, release candidate, final), your goal is to publish a full
  11. set of artifacts on Maven Central (MC). Because MC requires you to publish javadocs and source code together with
  12. the corresponding binaries and to sign all artifacts with GPG, this is the most complex and complete, but also the
  13. slowest build you are about to encounter. Probably, you also want to build the AspectJ documentation to be deployed
  14. to the website.
  15. * When building a snapshot, the requirements are less strict, even if you are planning to make the release publicly
  16. available in the Sonatype OSSRH snapshots repository. In this case, you can skip creating javadocs and source JARs
  17. and also do not need to sign the artifacts. You might want to decide to sign anyway or at least to publish source
  18. JARs (which modern IDEs can also use in order to display javadoc information). So even if you are not working with
  19. an active Maven release profile, you want to have control over those options by setting properties. Probably, you do
  20. not wish to generate the AspectJ documentation for the website, because presently there is not even a dedicated
  21. place to deploy snapshot versions of it on the Eclipse webserver.
  22. * When building during development without the need to publish it, you probably want to skip as many non-essential
  23. parts of the build as possible. Firstly, you do not need them. Secondly, you want your build and run development
  24. cycles to be as quick as possible. So in this case, definitely you are going to skip javadoc and source JARs,
  25. website documentation and GPG signatures - unless you are in the process of changing and/or testing those parts of
  26. the build.
  27. * Independently of the above scenarios, you want to have control over whether to run (or even compile) any tests, and
  28. if so, which one(s).
  29. ## How to customise the build process
  30. You can customise the Maven build process by using build profiles and/or set corresponding system properties for
  31. fine-tuning.
  32. ### Build profiles
  33. #### Main profiles
  34. The main profiles you are going to use are:
  35. * By default, when not specifying any profiles or properties, the build skips a few non-essential, time-consuming
  36. steps, but runs all tests: no javadocs, no source JARs, no GPG signatures, but generate documentation.
  37. * `release` - Run tests, create javadoc and source JARs, generate documentation, activate GPG artifact signing.
  38. Furthermore, each module creating one of the main build artifacts individually uses Nexus Staging Maven Plugin in
  39. order to take care of deploying non-snapshot artifacts to Sonatype OSSRH staging repositories and subsequently
  40. releasing them to Maven Central. See [How to release AspectJ](RELEASE.md) for more information. Snapshot artifacts
  41. are being deployed normally, using Maven Deploy Plugin. See description of
  42. [property `maven.deploy.skip`](#build-properties) below for more information.
  43. * `fast-build` - In a way, this is the opposite of the release profile, trying to build the product as quickly as
  44. possible by skipping all non-essential build steps: no tests (skipping even test compilation), no javadocs, no
  45. source JARs, no GPG signatures, no documentation.
  46. * `create-docs` - If you intend to run a build with all tests, but still wish to skip generating documentation,
  47. deactivate this profile by
  48. ```shell
  49. mvn -P !create-docs ...
  50. ```
  51. On UNIX-like shells like Bash (also Git Bash under Windows), you probably need to escape the "!":
  52. ```shell
  53. mvn -P \!create-docs ...
  54. ```
  55. You can also deactivate the profile using a system property instead:
  56. ```shell
  57. mvn -DcreateDocs=false ...
  58. ```
  59. #### Special profiles for `lib` module
  60. Defined in the `lib` module, there are two special profiles, helping to make the build more efficient:
  61. * `provision-libs` - Downloads and installs software used during tests, such as Apache Ant and several libraries. Some
  62. are downloaded from Maven Central, others directly from product download sites. Additionally, the build downloads
  63. several missing source packages, so developers can use them during development in order to access source code and
  64. javadoc. Because this build step is costly and should be performed only once after cloning the AspectJ repository
  65. or when other circumstances require re-provisioning at least one of those libraries, it is activated automatically,
  66. if marker file `lib/provisioned.marker` does not exist. After successful provisioning, the marker file is created,
  67. helping to avoid repeating this build step henceforth.
  68. * `clean-libs` - By default, `mvn clean` will not delete any of the libraries provisioned in profile `provision-libs`.
  69. This is intentional and one of the reasons why the libraries are not provisioned into the `target` directory but
  70. directly into `lib` subdirectories. If you wish to re-provision the libraries, simply run
  71. ```shell
  72. mvn -pl lib -P clean-libs clean
  73. ```
  74. Now you have a clean slate and during the next build, the libraries will be freshly downloaded and installed into
  75. their respective `lib` subdirectories.
  76. Please note: An additional build step using Maven Enforcer Plugin also verifies the existence of several key files which
  77. ought to exist after a successful download. This heuristic check runs independently of the two build profiles mentioned
  78. above. It helps to detect accidental corruption of the provisioned libs, e.g., due to manual deletion or a previously
  79. failed provisioning build step (network problems, manually interrupted build).
  80. #### Other profiles
  81. Other existing profiles, which developers are less likely to actively use because they are applied automatically, are:
  82. * `repeat-all-unit-tests` - Maven module `run-all-junit-tests` has the sole purpose of providing a convenient means of
  83. running all tests across modules from an IDE instead of from Maven, in order to get JUnit build reporting directly
  84. there instead of on the console. As a developer, you simply run test suite `RunTheseBeforeYouCommitTests`. This
  85. profile is inactive by default, because in the context of a Maven build it would cause all tests to be run twice
  86. (during module build and again when running the big suite), hence the profile name.
  87. * `jdk-8-to-15` - Activated automatically on JDKs 8-15, setting property `jvm.arg.addOpens` to an empty value, because
  88. it is only needed on JDK 16+, see next bullet point.
  89. * `jdk-16-to-xx` - Activated automatically on JDKs 16+, setting property `jvm.arg.addOpens` to value
  90. `--add-opens java.base/java.lang=ALL-UNNAMED`, which is needed in order to run LTW tests.
  91. ### Build properties
  92. The following properties and their default values in different profile are used in order to activate or skip Maven
  93. plugin executions:
  94. * `maven.deploy.skip` (default `true`) - By default, do not deploy artifacts, because only the main AspectJ artifacts
  95. are meant to be shared with the general public, i.e. deployed to Sonatype OSSRH Snapshots or Maven Central artifact
  96. repositories. The main AspectJ artifact modules override the default, setting the value to `false`. This property is
  97. used independently of build profiles, it simply has a global default and module-specific overrides.
  98. * `maven.gpg.skip` (default: `true`) - By default, do not GPG-sign artifacts, because only the main AspectJ artifacts
  99. need to be signed before publishing them on Maven Central. The main AspectJ artifact modules override the default,
  100. setting the value to `false`. This property is used independently of build profiles, it simply has a global default
  101. and module-specific overrides. Given the additional fact that Maven GPG Plugin is only active in the `release`
  102. profile, it also means that the build globally skips signing if that profile is inactive. So if you wish to sign
  103. snapshot artifacts, you need to activate the `release` profile (also activating all the other build steps that
  104. profile has).
  105. * `maven.javadoc.skip` (default: `true`) - By default, do not create javadoc. Overridden in the `release` profile.
  106. When javadoc generation is skipped while producing the uber JAR assemblies for the main AspectJ artifacts, also
  107. unzipping of source uber JARs is skipped, because that step is only needed in order to create uber JAR javadocs in
  108. the first place. (Do not worry too much, if you do not fully understand what I just wrote.)
  109. * `maven.source.skip` (default: `true`) - By default, do not create source JARs. Overridden in the `release` profile.
  110. Actually, this property is meant to be used in order to skip execution of Maven Source Plugin, but currently the
  111. AspectJ build does not even use that plugin, because the build does not create source JARs for individual modules.
  112. That might change in the future, though, so we use this property to also influence Maven Assembly Plugin, which is
  113. responsible for creating source uber JARs for the main AspectJ artifacts.
  114. * `skipTests` (default: `false`) - By default, execute tests. Profile `fast-build` overrides this property.
  115. * `maven.test.skip` (default: `false`) - By default, compile and execute tests. Profile `fast-build` overrides this
  116. property. Actually, activating this property also implies `skipTests`, but `fast-build` sets both of them in order
  117. to be explicit about its intentions.
  118. * `createDocs` (default: `true`) - By default, create user documentation for the AspectJ website. Profile `fast-build`
  119. overrides this property.
  120. ### Examples
  121. In addition to the examples above, concerning how to skip website documentation generation in the `docs` module and how
  122. to clean downloaded libraries in the `lib` module, here are a few more:
  123. * Run a clean default build including tests and generating Aspect documentation:
  124. ```shell
  125. mvn clean verify
  126. ```
  127. If you wish to install all artifacts in the local Maven repository, because subsquently maybe you want to run builds
  128. for submodules you are working on and which need to find other artifacts in the repository for a successful build,
  129. you rather use:
  130. ```shell
  131. mvn clean install
  132. ```
  133. * Run a fast build, no test compilation and execution, no AspectJ documentation, no javadoc, no source JARs
  134. ```shell
  135. mvn -P fast-build package
  136. ```
  137. * Run a release build incl. tests, GPG artifact signing and deployment:
  138. ```shell
  139. mvn -P release clean deploy
  140. ```
  141. * Run a release build incl. deployment, but without compiling and running tests because you ran all tests before
  142. successfully already:
  143. ```shell
  144. mvn -P release,fast-build clean deploy
  145. ```
  146. This is effectively the same as:
  147. ```shell
  148. mvn -P release -Dmaven.test.skip=true clean deploy
  149. ```
  150. In a UNIX shell, you probably have to double-quote when using properties containing dots:
  151. ```shell
  152. mvn -P release "-Dmaven.test.skip=true" clean deploy
  153. ```
  154. In general, you should not combine profiles setting the same properties in contradictory ways. If you need a very
  155. specific build configuration, you might want to use a profile matching your needs most closely and override specific
  156. properties. However, I am not going to share examples for this approach, because generally it is not necessary and also
  157. both error-prone and sensitive to even small changes in Maven POMs.