This is an automated email from the ASF dual-hosted git repository. olamy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-release.git
The following commit(s) were added to refs/heads/master by this push: new 83deb62a [MRELEASE-1104] fix stage goal when having both arguments and stagingRepository 83deb62a is described below commit 83deb62a687495f1e70ee9229d45b12aa13f4248 Author: Olivier Lamy <ol...@apache.org> AuthorDate: Fri Sep 23 17:31:03 2022 +1000 [MRELEASE-1104] fix stage goal when having both arguments and stagingRepository Signed-off-by: Olivier Lamy <ol...@apache.org> --- .../shared/release/DefaultReleaseManager.java | 9 ++++++ .../shared/release/exec/ForkedMavenExecutor.java | 3 ++ .../shared/release/exec/InvokerMavenExecutor.java | 2 ++ maven-release-plugin/pom.xml | 1 + .../invoker.properties | 18 ++++++++++++ .../stage/MRELEASE-1104-both-parameters/pom.xml} | 32 +++++++++++++++------- .../MRELEASE-1104-both-parameters/verify.groovy | 26 ++++++++++++++++++ .../invoker.properties | 18 ++++++++++++ .../stage/MRELEASE-1104-stage-repo-only/pom.xml} | 31 ++++++++++++++------- .../MRELEASE-1104-stage-repo-only/verify.groovy | 26 ++++++++++++++++++ .../plugins/release/StageReleaseMojoTest.java | 10 +++++++ .../src/test/resources/mojos/stage/stage.xml | 3 +- 12 files changed, 158 insertions(+), 21 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java index 199dc7fd..3ad03bd7 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java @@ -322,6 +322,12 @@ public class DefaultReleaseManager private void perform( ReleasePerformRequest performRequest, ReleaseResult result ) throws ReleaseExecutionException, ReleaseFailureException { + + // https://issues.apache.org/jira/browse/MRELEASE-1104 because stageRepository is an additional arg + // and only adding at perform stage it's not available during prepare and so not save the not available + // when reloading. save this then change again after load + String additionalArguments = performRequest.getReleaseDescriptorBuilder().build().getAdditionalArguments(); + List<String> specificProfiles = ReleaseUtils.buildReleaseDescriptor( performRequest.getReleaseDescriptorBuilder() ) .getActivateProfiles(); @@ -330,6 +336,9 @@ public class DefaultReleaseManager loadReleaseDescriptorBuilder( performRequest.getReleaseDescriptorBuilder(), performRequest.getReleaseManagerListener() ); + + builder.setAdditionalArguments( additionalArguments ); + if ( specificProfiles != null && !specificProfiles.isEmpty() ) { List<String> allProfiles = diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java index 463486d3..1c5c3620 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java @@ -110,6 +110,9 @@ public class ForkedMavenExecutor cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + // FIX for MRELEASE-1105 + //cl.addEnvironment( "MAVEN_DEBUG_OPTS", "" ); + cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); if ( settingsFile != null ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java index 1eda2095..972cbc67 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java @@ -72,6 +72,8 @@ public class InvokerMavenExecutor InvocationRequest req = new DefaultInvocationRequest() .setDebug( getLogger().isDebugEnabled() ) .setBaseDirectory( workingDirectory ) + // fix for MRELEASE-1105 + //.addShellEnvironment( "MAVEN_DEBUG_OPTS", "" ) .setBatchMode( true ) .setOutputHandler( getLogger()::info ) .setErrorHandler( getLogger()::error ); diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml index 91a5f0ac..4d0cb159 100644 --- a/maven-release-plugin/pom.xml +++ b/maven-release-plugin/pom.xml @@ -223,6 +223,7 @@ <pomInclude>projects/branch/*/pom.xml</pomInclude> <pomInclude>projects/perform/*/pom.xml</pomInclude> <pomInclude>projects/update-versions/*/pom.xml</pomInclude> + <pomInclude>projects/stage/*/pom.xml</pomInclude> </pomIncludes> <pomExcludes> <pomExclude>projects/prepare/MRELEASE-966/pom.xml</pomExclude> diff --git a/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/invoker.properties b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/invoker.properties new file mode 100644 index 00000000..a5c864ac --- /dev/null +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = clean release:prepare release:stage -X \ No newline at end of file diff --git a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/pom.xml similarity index 51% copy from maven-release-plugin/src/test/resources/mojos/stage/stage.xml copy to maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/pom.xml index d1ac5835..0bbd4146 100644 --- a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/pom.xml @@ -17,22 +17,34 @@ ~ specific language governing permissions and limitations ~ under the License. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugin.release.its</groupId> + <artifactId>mrelease-1104-both-parameters</artifactId> + <version>1.0-SNAPSHOT</version> + + <scm> + <connection>scm:dummy|nul</connection> + <developerConnection>scm:dummy|nul</developerConnection> + </scm> -<project> <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> + <version>@project.version@</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.release</groupId> + <artifactId>maven-scm-provider-dummy</artifactId> + <version>1.0</version> + </dependency> + </dependencies> <configuration> - <settings implementation="org.apache.maven.settings.Settings"/> - <project implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/> - <reactorProjects> - <reactorProject implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/> - </reactorProjects> - <workingDirectory>${basedir}/target/checkout</workingDirectory> - <stagingRepository>staging</stagingRepository> - <goals>deploy site-deploy</goals> - <useReleaseProfile>true</useReleaseProfile> + <arguments>-DskipTests</arguments> + <stagingRepository>file://${project.build.directory}/dummy/staging</stagingRepository> </configuration> </plugin> </plugins> diff --git a/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/verify.groovy b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/verify.groovy new file mode 100644 index 00000000..d0950f13 --- /dev/null +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-both-parameters/verify.groovy @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +assert buildLog.text.contains( "with additional arguments: -DskipTests -DaltDeploymentRepository=\"file://" ) + + + diff --git a/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/invoker.properties b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/invoker.properties new file mode 100644 index 00000000..a5c864ac --- /dev/null +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = clean release:prepare release:stage -X \ No newline at end of file diff --git a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/pom.xml similarity index 52% copy from maven-release-plugin/src/test/resources/mojos/stage/stage.xml copy to maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/pom.xml index d1ac5835..812a62ed 100644 --- a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/pom.xml @@ -17,22 +17,33 @@ ~ specific language governing permissions and limitations ~ under the License. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugin.release.its</groupId> + <artifactId>mrelease-1104-stage-repo-only</artifactId> + <version>1.0-SNAPSHOT</version> + + <scm> + <connection>scm:dummy|nul</connection> + <developerConnection>scm:dummy|nul</developerConnection> + </scm> -<project> <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> + <version>@project.version@</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.release</groupId> + <artifactId>maven-scm-provider-dummy</artifactId> + <version>1.0</version> + </dependency> + </dependencies> <configuration> - <settings implementation="org.apache.maven.settings.Settings"/> - <project implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/> - <reactorProjects> - <reactorProject implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub"/> - </reactorProjects> - <workingDirectory>${basedir}/target/checkout</workingDirectory> - <stagingRepository>staging</stagingRepository> - <goals>deploy site-deploy</goals> - <useReleaseProfile>true</useReleaseProfile> + <stagingRepository>file://${project.build.directory}/dummy/staging</stagingRepository> </configuration> </plugin> </plugins> diff --git a/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/verify.groovy b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/verify.groovy new file mode 100644 index 00000000..930fef4a --- /dev/null +++ b/maven-release-plugin/src/it/projects/stage/MRELEASE-1104-stage-repo-only/verify.groovy @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +assert buildLog.text.contains( "with additional arguments: -DaltDeploymentRepository=\"file://" ) + + + diff --git a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java index a4c6ebbb..e16b5222 100644 --- a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java +++ b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java @@ -88,6 +88,16 @@ public class StageReleaseMojoTest assertEquals( "deploy site:stage-deploy", mojo.goals ); } + public void testCreateArguments() + throws Exception + { + StageReleaseMojo mojo = getMojoWithProjectSite( "stage.xml" ); + mojo.setDeploymentRepository(); + ReleaseDescriptorBuilder.BuilderReleaseDescriptor releaseDescriptor = mojo.createReleaseDescriptor().build(); + assertEquals( "-DskipTests -DaltDeploymentRepository=\"staging\"", releaseDescriptor.getAdditionalArguments() ); + } + + private StageReleaseMojo getMojoWithProjectSite( String fileName ) throws Exception { diff --git a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml b/maven-release-plugin/src/test/resources/mojos/stage/stage.xml index d1ac5835..ee865b24 100644 --- a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml +++ b/maven-release-plugin/src/test/resources/mojos/stage/stage.xml @@ -31,7 +31,8 @@ </reactorProjects> <workingDirectory>${basedir}/target/checkout</workingDirectory> <stagingRepository>staging</stagingRepository> - <goals>deploy site-deploy</goals> + <goals>deploy site-deploy</goals> + <arguments>-DskipTests</arguments> <useReleaseProfile>true</useReleaseProfile> </configuration> </plugin>