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.zwe 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://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom
[INFO] [INFO] Uploaded to maven-artifacts:
https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom
(7.4 kB at 14 kB/s)
[INFO] [INFO] Downloading from maven-artifacts:
https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml
[INFO] [INFO] Downloaded from maven-artifacts:
https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml
(772 B at 16 kB/s)
[INFO] [INFO] Uploading to maven-artifacts:
https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml
[INFO] [INFO] Uploaded to maven-artifacts:
https://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/maven-metadata.xml
(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://xxx.jfrog.io/artifactory/maven-artifacts/temp/mectagcore/mectagcore/1.0.0/mectagcore-1.0.0.pom
[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://xxx.jfrog.io/artifactory/maven-artifacts):
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://xxx.jfrog.io/artifactory/maven-artifacts):
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.
--
<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd">
<configuration>
<enabled>true</enabled>
<hashAlgorithm>SHA-256</hashAlgorithm>
<validateXml>true</validateXml>
<local>
<maxBuildsCached>10</maxBuildsCached>
</local>
<projectVersioning adjustMetaInf="true" />
<attachedOutputs>
<dirNames>
<dirName>.</dirName>
</dirNames>
</attachedOutputs>
</configuration>
<input>
<global>
<glob>{*.java,*.groovy,*.yml,*.yaml,*.svcd,*.proto,*assembly.xml,assembly*.xml,*logback.xml,*.vm,*.ini,*.jks,*.properties,*.sh,*.bat,*.wsdl,*.json}</glob>
<includes>
<include>src/</include>
</includes>
<excludes>
<exclude>pom.xml</exclude>
</excludes>
</global>
<plugins>
<plugin groupId="org.apache.maven.plugins" artifactId="maven-surefire-plugin">
<effectivePom>
<excludeProperties>
<excludeProperty>systemPropertyVariables</excludeProperty>
</excludeProperties>
</effectivePom>
</plugin>
</plugins>
</input>
<executionControl>
<runAlways>
<plugins>
<plugin artifactId="jacoco-maven-plugin" />
</plugins>
<goalsLists>
<goalsList artifactId="amiga-assembly-maven-plugin">
<goals>
<goal>amiga-assembly</goal>
</goals>
</goalsList>
<goalsList artifactId="maven-install-plugin">
<goals>
<goal>install</goal>
</goals>
</goalsList>
<goalsList artifactId="maven-deploy-plugin">
<goals>
<goal>deploy</goal>
</goals>
</goalsList>
<goalsList artifactId="maven-source-plugin">
<goals>
<goal>jar-no-fork</goal>
</goals>
</goalsList>
</goalsLists>
</runAlways>
<reconcile logAllProperties="true">
<plugins>
<plugin artifactId="maven-surefire-plugin" goal="test">
<reconciles>
<reconcile propertyName="skip" skipValue="true" />
<reconcile propertyName="skipExec" skipValue="true" />
<reconcile propertyName="skipTests" skipValue="true" />
<reconcile propertyName="testFailureIgnore" skipValue="true" />
</reconciles>
<nologs>
<nolog propertyName="systemPropertyVariables"/>
</nologs>
</plugin>
<plugin artifactId="maven-failsafe-plugin" goal="integration-test">
<reconciles>
<reconcile propertyName="skip" skipValue="true" />
<reconcile propertyName="skipExec" skipValue="true" />
<reconcile propertyName="skipITs" skipValue="true" />
<reconcile propertyName="skipTests" skipValue="true" />
</reconciles>
</plugin>
<plugin artifactId="maven-failsafe-plugin" goal="verify">
<reconciles>
<reconcile propertyName="skip" skipValue="true" />
<reconcile propertyName="skipExec" skipValue="true" />
<reconcile propertyName="skipITs" skipValue="true" />
<reconcile propertyName="skipTests" skipValue="true" />
<reconcile propertyName="testFailureIgnore" skipValue="true" />
</reconciles>
</plugin>
<plugin artifactId="maven-compiler-plugin" goal="compile">
<reconciles>
<reconcile propertyName="source" />
<reconcile propertyName="target" />
<reconcile propertyName="debug" />
<reconcile propertyName="debuglevel" />
</reconciles>
<logs>
<log propertyName="includes" />
<log propertyName="excludes" />
<log propertyName="argLine" />
</logs>
</plugin>
<plugin artifactId="maven-compiler-plugin" goal="testCompile">
<reconciles>
<reconcile propertyName="source" />
<reconcile propertyName="target" />
<reconcile propertyName="debug" />
<reconcile propertyName="debuglevel" />
</reconciles>
<logs>
<log propertyName="includes" />
<log propertyName="excludes" />
<log propertyName="argLine" />
</logs>
</plugin>
<plugin artifactId="maven-enforcer-plugin" goal="enforce">
<reconciles>
<reconcile propertyName="skip" skipValue="true" />
</reconciles>
<nologs>
<nolog propertyName="commandLineRules"/>
</nologs>
</plugin>
</plugins>
</reconcile>
</executionControl>
</cache>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org