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.

RELEASE.md 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.8-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.8.M2
  70. # Verify if the POM changes are OK, then remove the POM backup files
  71. mvn versions:commit
  72. # Build and deploy the release to a Nexus staging repository.
  73. # The 'release' profile will activate:
  74. # - Maven GPG plugin for signing artifacts (stand by to enter your passpharase).
  75. # On Windows, a GUI password dialogue should pop up with a recent GnuPG version.
  76. # In case of error 'Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign',
  77. # try 'export GPG_TTY=$(tty)' before running the command.
  78. # - Maven Javadoc plugin
  79. # - Nexus Staging Maven plugin
  80. # The 'create-docs profile will make sure to generate AspectJ docs to be included in the installer.
  81. # Optionally, use '-DskipTests=true', if you ran all tests before.
  82. mvn -P release,create-docs clean deploy
  83. ```
  84. If this command was successful, it means we have created a staging repository on Sonatype OSSRH, uploaded all artifacts
  85. and all pre-release checks on the Sonatype server passed, i.e. if the POMs contain all necessary information and if
  86. there are source and javadoc artifacts attached to the build. Now the only step left is to release the staging
  87. repository to Maven Central.
  88. Actually, Nexus Staging Maven plugin can also be configured deploy and release to Maven Central in a single command, but
  89. in order to give you a chance to manually download and verify the artifacts from the staging repository, the default
  90. plugin configuration in the parent POM is `<autoReleaseAfterClose>false</autoReleaseAfterClose>`. Switching the value to
  91. `true` would release straight to Maven Central, given all previous steps were successful.
  92. Before we release the staging repository though, we want to commit and tag the release, then set a new snapshot version:
  93. ```shell
  94. # Commit the release POMs to Git (better do this from your IDE, verifying the
  95. # changes before staging them for Git commit)
  96. git commit -am "Set version to 1.9.8.M2"
  97. # Tag release
  98. git tag V1_9_8_M2
  99. # Set new snapshot version, increasing the version number after a final release
  100. mvn versions:set -DnewVersion=1.9.8-SNAPSHOT
  101. # Verify if the POM changes are OK, then remove the POM backup files
  102. mvn versions:commit
  103. # Commit the snapshot POMs to Git
  104. git commit -am "Set version to 1.9.8-SNAPSHOT"
  105. # Push the previous commits to GitHub
  106. git push origin
  107. # Push the release tag to GitHub
  108. git push origin V1_9_8_M2
  109. ```
  110. OK, the Git house-keeping is done. Now finally, let us enjoy the fruits of our work and release the staging repository
  111. to Maven Central:
  112. ```shell
  113. # Probably we forgot to write down the staging repository ID before.
  114. # It was written somewhere in the Maven log:
  115. # [INFO] * Created staging repository with ID "orgaspectj-1106".
  116. # [INFO] * Staging repository at https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/orgaspectj-1106
  117. # ...
  118. # [INFO] * Uploading locally staged artifacts to profile org.aspectj
  119. # [INFO] * Upload of locally staged artifacts finished.
  120. # [INFO] * Closing staging repository with ID "orgaspectj-1106".
  121. #
  122. # But it is too far to scroll up. So let us just ask Nexus, which staging
  123. # repositories there are.
  124. mvn nexus-staging:rc-list
  125. # [INFO] ID State Description
  126. # [INFO] orgaspectj-1106 CLOSED org.aspectj:aspectjrt:1.9.8.M2
  127. # Because of problems in Nexus Staging Maven Plugin with more recent JDKs,
  128. # we might need this first
  129. 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"
  130. # Use the ID of the corresponding CLOSED staging repository for releasing to
  131. # Maven Central
  132. mvn nexus-staging:rc-release -DstagingRepositoryId=orgaspectj-1106
  133. ```
  134. Tadaa! We have performed an AspectJ release. In a few minutes, the artifacts should appear on Maven Central somewhere
  135. under https://repo1.maven.org/maven2/org/aspectj/, e.g. AspectJ Tools 1.9.8.M2 would appear under
  136. https://repo1.maven.org/maven2/org/aspectj/aspectjtools/1.9.8.M2/. As soon as you see the artifacts there instead of
  137. "404 not found", you can announce release availability on the AspectJ mailing list and wherever else appropriate.
  138. Finally, you probably want to publish the AspectJ installer (`installer/target/aspectj-[VERSION].jar`), e.g. by creating a
  139. GitHub release and attaching artifacts and/or updating the Eclipse AspectJ website. You also want to update the AspectJ
  140. documentation, if there were any changes.
  141. ## Deploying the AspectJ installer to aspectj.dev
  142. An easy way to quickly publish the installer is to simply deploy it to the Maven repository aspectj.dev. In order to do
  143. that, you need to mount the target directory as a WebDAV share first (ask an AspectJ maintainer for credentials). This
  144. can be done on all operating systems, for this example let us assume we are working on Windows and already have mounted
  145. the share to drive letter M: (M like Maven). Command `net use` would show something like this (sorry, in German):
  146. ```text
  147. C:\Users\me>net use
  148. ...
  149. Status Lokal Remote Netzwerk
  150. -------------------------------------------------------------------------------
  151. OK M: \\s000b153.kasserver.com\s000b153
  152. Microsoft Windows Network
  153. ...
  154. ```
  155. Next, we need to tell Maven to
  156. - actually deploy the installer (remember, by default only the artifacts listed above are deployed),
  157. - override the default deployment repository (Sonatype OSSRH) by our WebDAV share.
  158. Before issuing the following command, make sure that you successfully built AspectJ before. Otherwise, Maven cannot find
  159. the artifacts it needs to create the installer JAR.
  160. ```shell
  161. mvn --projects installer -Dmaven.deploy.skip=false -DaltDeploymentRepository=aspectj-dev::default::file:///M: deploy
  162. ```