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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. # How to release AspectJ
  2. AspectJ is built and released with Maven. As of writing this, there is a Maven wrapper in the project root folder,
  3. pointing to Maven 3.6.3, but we are going to use simple `mvn` commands instead of `./mvnw` here, assuming that there is
  4. a local Maven installation on your workstation. You can easily substitute one for the other command.
  5. When deploying final releases to Sonatype OSSRH, the build uses Nexus Staging Maven plugin instead of Maven Deploy
  6. plugin. This helps to create a staging repository for the release and later release it to Maven Central without having
  7. to log into the [Sonatype Nexus web UI](https://oss.sonatype.org/). Everything can be done from the command line.
  8. Snapshots do not need to be staged and released separately, Maven Deploy does the job in this case. so let us begin with
  9. the simple case:
  10. ## Snapshot releases
  11. To publish a snapshot, set up your credentials in `~/.m2/settings.xml` something like:
  12. ```xml
  13. <settings>
  14. <servers>
  15. <server>
  16. <id>ossrh</id>
  17. <username>USERNAME</username>
  18. <password>PASSWORD</password>
  19. </server>
  20. </servers>
  21. </settings>
  22. ```
  23. Assuming that you are currently working on version 1.9.7-SNAPSHOT, you simply call:
  24. ```shell
  25. mvn clean deploy
  26. # OR: If you ran tests locally before, or the CI workflow on GitHub did
  27. mvn -DskipTests=true clean deploy
  28. # OR: Speed it up some more, skipping documentation generation. Depending on
  29. # your shell, you might not have to escape the '!' character for deactivating
  30. # the 'create-docs' profile. On a (Git) Bash you have to, though.
  31. mvn -P \!create-docs -DskipTests=true clean deploy
  32. ```
  33. This only deploys the main artifacts
  34. - AspectJ runtime `aspectjrt-[VERSION].jar`,
  35. - AspectJ tools/compiler `aspecttools-[VERSION].jar`,
  36. - AspectJ weaver `aspectjweaver-[VERSION].jar`,
  37. - AspectJ matcher `aspectjmatcher-[VERSION].jar`.
  38. The AspectJ installer (`installer/target/aspectj-[VERSION].jar`) needs to be published separately, if you wish to make
  39. it available to the public for this snapshot.
  40. To consume an AspectJ snapshot published this way, use the OSSRH repository in the dependent project's POM:
  41. ```xml
  42. <repository>
  43. <id>ossrh</id>
  44. <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  45. </repository>
  46. ```
  47. ## Public releases (milestone, release candidate, final)
  48. The artifacts released are the same as for snapshots, the procedure needs a few more steps, though. I am explaining the
  49. manual versioning process without using Maven Release plugin. It might work using Maven Release too, i.e.
  50. - setting the release version in all POMs,
  51. - building a release,
  52. - running tests (can be skipped),
  53. - committing the release POMs,
  54. - tagging the release,
  55. - deploying the release,
  56. - setting the next snapshot version in all POMs,
  57. - committing the snapshot POMs,
  58. - pushing the previous commits and the release tag to the upstream Git repository.
  59. In order to show the details and give you more control over the process, you can do it step by step as follows:
  60. ```shell
  61. # Make sure we are on JDK 16, because javadoc generation is JDK version sensitive
  62. # and might throw unexpected errors on other versions
  63. java -version
  64. # java version "16" 2021-03-16 (...)
  65. # Verify that we are working on a clean working directory.
  66. # There should be no staged, unstaged or untracked files.
  67. git status
  68. # Set release version in all POMs
  69. mvn versions:set -DnewVersion=1.9.7.M2
  70. # Verify if the POM changes are OK, then remove the POM backup files
  71. mvn versions:commit
  72. # Set some environment variables needed by Nexus Staging Maven plugin on JDK 16,
  73. # until https://issues.sonatype.org/browse/OSSRH-66257 is resolved
  74. export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
  75. # Build and deploy the release to a Nexus staging repository.
  76. # The 'release' profile will activate:
  77. # - Maven GPG plugin for signing artifacts (stand by to enter your passpharase).
  78. # On Windows, a GUI password dialogue should pop up with a recent GnuPG version.
  79. # In case of error 'Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign',
  80. # try 'export GPG_TTY=$(tty)' before running the command.
  81. # - Maven Javadoc plugin
  82. # - Nexus Staging Maven plugin
  83. # Optionally, use '-DskipTests=true', if you ran all tests before.
  84. mvn -P release clean deploy
  85. ```
  86. If this command was successful, it means we have created a staging repository on Sonatype OSSRH, uploaded all artifacts
  87. and all pre-release checks on the Sonatype server passed, i.e. if the POMs contain all necessary information and if
  88. there are source and javadoc artifacts attached to the build. Now the only step left is to release the staging
  89. repository to Maven Central.
  90. Actually, Nexus Staging Maven plugin can also be configured deploy and release to Maven Central in a single command, but
  91. in order to give you a chance to manually download and verify the artifacts from the staging repository, the default
  92. plugin configuration in the parent POM is `<autoReleaseAfterClose>false</autoReleaseAfterClose>`. Switching the value to
  93. `true` would release straight to Maven Central, given all previous steps were successful.
  94. Before we release the staging repository though, we want to commit and tag the release, then set a new snapshot version:
  95. ```shell
  96. # Commit the release POMs to Git (better do this from your IDE, verifying the
  97. # changes before staging them for Git commit)
  98. git commit -am "Set version to 1.9.7.M2"
  99. # Tag release
  100. git tag V1_9_7_M2
  101. # Set new snapshot version, increasing the version number after a final release
  102. mvn versions:set -DnewVersion=1.9.7-SNAPSHOT
  103. # Verify if the POM changes are OK, then remove the POM backup files
  104. mvn versions:commit
  105. # Commit the snapshot POMs to Git
  106. git commit -am "Set version to 1.9.7-SNAPSHOT"
  107. # Push the previous commits to GitHub
  108. git push origin
  109. # Push the release tag to GitHub
  110. git push origin V1_9_7_M2
  111. ```
  112. OK, the Git house-keeping is done. Now finally, let us enjoy the fruits of our work and release the staging repository
  113. to Maven Central:
  114. ```shell
  115. # Probably we forgot to write down the staging repository ID before.
  116. # It was written somewhere in the Maven log:
  117. # [INFO] * Created staging repository with ID "orgaspectj-1106".
  118. # [INFO] * Staging repository at https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/orgaspectj-1106
  119. # ...
  120. # [INFO] * Uploading locally staged artifacts to profile org.aspectj
  121. # [INFO] * Upload of locally staged artifacts finished.
  122. # [INFO] * Closing staging repository with ID "orgaspectj-1106".
  123. #
  124. # But it is too far to scroll up. So let us just ask Nexus, which staging
  125. # repositories there are.
  126. mvn nexus-staging:rc-list
  127. # [INFO] ID State Description
  128. # [INFO] orgaspectj-1106 CLOSED org.aspectj:aspectjrt:1.9.7.M2
  129. # Use the ID of the corresponding CLOSED staging repository for releasing to
  130. # Maven Central
  131. mvn nexus-staging:rc-release -DstagingRepositoryId=orgaspectj-1106
  132. ```
  133. Tadaa! We have performed an AspectJ release. In a few minutes, the artifacts should appear on Maven Central somewhere
  134. under https://repo1.maven.org/maven2/org/aspectj/, e.g. AspectJ Tools 1.9.7.M2 would appear under
  135. https://repo1.maven.org/maven2/org/aspectj/aspectjtools/1.9.7.M2/. As soon as you see the artifacts there instead of
  136. "404 not found", you can announce release availability on the AspectJ mailing list and wherever else appropriate.
  137. Finally, you probably want to publish the AspectJ installer (`installer/target/aspectj-[VERSION].jar`), e.g. by creating a
  138. GitHub release and attaching artifacts and/or updating the Eclipse AspectJ website. You also want to update the AspectJ
  139. documentation, if there were any changes.
  140. ## Deploying the AspectJ installer to aspectj.dev
  141. An easy way to quickly publish the installer is to simply deploy it to the Maven repository aspectj.dev. In order to do
  142. that, you need to mount the target directory as a WebDAV share first (ask an AspectJ maintainer for credentials). This
  143. can be done on all operating systems, for this example let us assume we are working on Windows and already have mounted
  144. the share to drive letter M: (M like Maven). Command `net use` would show something like this (sorry, in German):
  145. ```text
  146. C:\Users\me>net use
  147. ...
  148. Status Lokal Remote Netzwerk
  149. -------------------------------------------------------------------------------
  150. OK M: \\s000b153.kasserver.com\s000b153
  151. Microsoft Windows Network
  152. ...
  153. ```
  154. Next, we need to tell Maven to
  155. - actually deploy the installer (remember, by default only the artifacts listed above are deployed),
  156. - override the default deployment repository (Sonatype OSSRH) by our WebDAV share.
  157. Before issuing the following command, make sure that you successfully built AspectJ before. Otherwise, Maven cannot find
  158. the artifacts it needs to create the installer JAR.
  159. ```shell
  160. mvn --projects installer -Dmaven.deploy.skip=false -DaltDeploymentRepository=aspectj-dev::default::file:///M: deploy
  161. ```