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.3KB

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