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

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