Hi all,
We are starting to apply the build-cache maven extension in our local and CI
environment, and we have seen strange behavior in several maven projects, when
using the release plugin in conjunction with build-cache, which we have been
able to reproduce both locally and in CI.
Our usual release plugin configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<arguments>-DskipEnforceSnapshots -DskipITs -DskipTests
-DskipUTs</arguments>
<goals>deploy</goals>
<projectVersionPolicyId>SemVerVersionPolicy</projectVersionPolicyId>
<releaseStrategyId>GithubReleaseStrategy</releaseStrategyId>
<scmReleaseCommitComment>@{prefix} Prepare release
@{releaseLabel}</scmReleaseCommitComment>
<scmDevelopmentCommitComment>@{prefix} Prepare for next development
iteration</scmDevelopmentCommitComment>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
When we add the build-cache extension to the project, and execute the release
with: mvn release:prepare release:perform -DreleaseVersion=x.y.z we can observe
a strange behavior when maven is launching the release:perform goal, we see
that the deploy goal is executed 2 times for each artifact (in fact it seems
that the maven lifecycle restarts, once it reaches the deploy and begins to
execute the validate again) and when it reaches the 2nd execution of deploy, it
fails (since the user we use do not have permissions to overwrite artifacts).
Below I show an extract from the log:
...
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Reactor Build Order:
[INFO] [INFO]
[INFO] [INFO] temp.mectagcore:mectagcore [pom]
[INFO] [INFO] temp.mectagcore:mectagcore-domain [jar]
[INFO] [INFO] temp.mectagcore:mectagcore-boot [jar]
[INFO] [INFO] temp.mectagcore:jacoco-report-aggregate [pom]
[INFO] [INFO]
[INFO] [INFO] -----------------< temp.mectagcore:mectagcore >-----------------
[INFO] [INFO] Building temp.mectagcore:mectagcore 1.0.0 [1/9]
[INFO] [INFO] from pom.xml
[INFO] [INFO] --------------------------------[ pom
]---------------------------------
[INFO] [INFO] Going to calculate checksum for project [groupId=temp.mectagcore,
artifactId=mectagcore]
[INFO] [INFO] Project inputs calculated in 12 ms. SHA-256 checksum
[16534757c14aae9b1ff1961664995f0e7e9396fb88309d207a8a23c080c7f661] calculated
in 4 ms.
[INFO] [INFO] Attempting to restore project temp.mectagcore:mectagcore from
build cache
[INFO] [INFO] Local build found by checksum
16534757c14aae9b1ff1961664995f0e7e9396fb88309d207a8a23c080c7f661
[INFO] [INFO] Found cached build, restoring temp.mectagcore:mectagcore from
cache by checksum
16534757c14aae9b1ff1961664995f0e7e9396fb88309d207a8a23c080c7f661
[INFO] [INFO] Project temp.mectagcore:mectagcore restored partially. Highest
cached goal: verify, requested: deploy
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugin.failsafe.IntegrationTestMojo', role hint:
'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0:integration-test'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugin.failsafe.VerifyMojo', role hint:
'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0:verify'
[INFO] ---
[INFO] [INFO] Skipping plugin execution (cached): enforcer:enforce
[INFO] [INFO] Skipping plugin execution (cached): enforcer:enforce
[INFO] [INFO] Skipping plugin execution (cached): build-helper:add-source
[INFO] [INFO] Mojo execution is forced by project property:
amiga-assembly:amiga-assembly
[INFO] [INFO]
[INFO] [INFO] --- amiga-assembly:5.5.0:amiga-assembly
(amiga-assembly-execution) @ mectagcore ---
[INFO] [INFO] Mojo execution is forced by project property: source:jar-no-fork
[INFO] [INFO]
[INFO] [INFO] --- source:3.2.1:jar-no-fork (attach-sources) @ mectagcore ---
[INFO] [INFO] Skipping plugin execution (cached): failsafe:integration-test
[INFO] [INFO] Skipping plugin execution (cached): failsafe:verify
[INFO] [INFO]
[INFO] [INFO] --- install:3.1.1:install (default-install) @ mectagcore ---
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.install.InstallMojo', role hint:
'org.apache.maven.plugins:maven-install-plugin:3.1.1:install'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.install.InstallFileMojo', role hint:
'org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file'
[INFO] ---
[INFO] [INFO] Installing /tmp/mic-mectagcore/code/target/checkout/code/pom.xml
to
/home/alambike/.m2/repository/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom
[INFO] [INFO]
[INFO] [INFO] --- deploy:3.1.1:deploy (default-deploy) @ mectagcore ---
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.deploy.DeployFileMojo', role hint:
'org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.maven_deploy_plugin.HelpMojo', role hint:
'org.apache.maven.plugins:maven-deploy-plugin:3.1.1:help'
[INFO] ---
[INFO] [INFO] Uploading to maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8Mt7bFjM$
[INFO] [INFO] Uploaded to maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8Mt7bFjM$
(7.4 kB at 14 kB/s)
[INFO] [INFO] Downloading from maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8kkLcXkg$
[INFO] [INFO] Downloaded from maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8kkLcXkg$
(772 B at 16 kB/s)
[INFO] [INFO] Uploading to maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8kkLcXkg$
[INFO] [INFO] Uploaded to maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8kkLcXkg$
(724 B at 1.6 kB/s)
[INFO] [INFO]
[INFO] [INFO] --- enforcer:3.3.0:enforce (enforce-banned-dependencies) @
mectagcore ---
[INFO] [INFO] Rule 0:
org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO] [INFO]
[INFO] [INFO] --- enforcer:3.3.0:enforce (enforce-build-tools-versions) @
mectagcore ---
[INFO] [INFO] Rule 0:
org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO] [INFO] Rule 1:
org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO] [INFO]
[INFO] [INFO] --- build-helper:3.3.0:add-source (add-classes) @ mectagcore ---
[INFO] [INFO] Source directory:
/tmp/mic-mectagcore/code/target/checkout/code/target/generated-sources/annotations
added.
[INFO] [INFO] Source directory:
/tmp/mic-mectagcore/code/target/checkout/code/target/generated-sources/event
added.
[INFO] [INFO]
[INFO] [INFO] --- amiga-assembly:5.5.0:amiga-assembly
(amiga-assembly-execution) @ mectagcore ---
[INFO] [INFO]
[INFO] [INFO] --- source:3.2.1:jar-no-fork (attach-sources) @ mectagcore ---
[INFO] [INFO]
[INFO] [INFO] --- failsafe:3.0.0:integration-test (default) @ mectagcore ---
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugin.failsafe.IntegrationTestMojo', role hint:
'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0:integration-test'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugin.failsafe.VerifyMojo', role hint:
'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0:verify'
[INFO] ---
[INFO] [INFO] Tests are skipped.
[INFO] [INFO] Tests are skipped.
[INFO] [INFO]
[INFO] [INFO] --- install:3.1.1:install (default-install) @ mectagcore ---
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.install.InstallMojo', role hint:
'org.apache.maven.plugins:maven-install-plugin:3.1.1:install'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.install.InstallFileMojo', role hint:
'org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file'
[INFO] ---
[INFO] [INFO] Installing /tmp/mic-mectagcore/code/target/checkout/code/pom.xml
to
/home/alambike/.m2/repository/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom
[INFO] [INFO]
[INFO] [INFO] --- deploy:3.1.1:deploy (default-deploy) @ mectagcore ---
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.deploy.DeployFileMojo', role hint:
'org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file'
[INFO] role: 'org.apache.maven.plugin.Mojo', implementation:
'org.apache.maven.plugins.maven_deploy_plugin.HelpMojo', role hint:
'org.apache.maven.plugins:maven-deploy-plugin:3.1.1:help'
[INFO] ---
[INFO] [INFO] Uploading to maven-artifacts:
https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8Mt7bFjM$
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary for temp.mectagcore:mectagcore 1.0.0:
[INFO] [INFO]
[INFO] [INFO] temp.mectagcore:mectagcore ................. FAILURE [ 2.809 s]
...
[INFO] [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy (default-deploy) on
project mectagcore: Failed to deploy artifacts: Could not transfer artifact
temp.mectagcore:mectagcore:pom:1.0.0 from/to maven-artifacts
(https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8a4HSylo$
): status code: 403, reason phrase: (403) -> [Help 1]
[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy
(default-deploy) on project mectagcore: Failed to deploy artifacts: Could not
transfer artifact temp.mectagcore:mectagcore:pom:1.0.0 from/to maven-artifacts
(https://urldefense.com/v3/__https://xxx.jfrog.io/artifactory/maven-artifacts__;!!BvtVhh717i4!63DMjrS0PyOoxOiAK8-v6n7Rh7DyGBcylINSrX5-Jckc1tGQeBIERrx5Tm2kjx9xpm9YS1Z8a4HSylo$
): status code: 403, reason phrase: (403)
If we disable the build-cache during release targets, we see that this does not
happen and we only have one deploy run that completes successfully:
<configuration>
<arguments>-DskipEnforceSnapshots -DskipITs -DskipTests -DskipUTs
-Dmaven.build.cache.enabled=false</arguments>
<goals>deploy</goals>
...
Somehow, by having the build-cache extension active during release goals, we
have a double execution of the maven lifecycle, which causes the release to
fail, (as we do not allow the user who publishes the artifacts overwrite these
artifacts). We have reproduced this with:
maven 3.9.4 y maven 3.9.6
openjdk 17
maven-release-plugin: 3.0.0
build-cache extension 1.1.0 (our build cache config file is attached to the
message)
I am writing to you in case anyone can shed some light on this case. In any
case, we understand that the most appropriate thing is to disable the build
cache extension in the configuration of the release plugin goals, and maybe it
should be documented. Thanks in advance.
--
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org