Skip to content

Commit

Permalink
[MRELEASE-1104] fix stage goal when having both arguments and staging…
Browse files Browse the repository at this point in the history
…Repository

Signed-off-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
olamy committed Oct 1, 2022
1 parent bce380b commit 83deb62
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 1 deletion.
Expand Up @@ -322,6 +322,12 @@ public void perform( ReleasePerformRequest performRequest )
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();
Expand All @@ -330,6 +336,9 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result
loadReleaseDescriptorBuilder( performRequest.getReleaseDescriptorBuilder(),
performRequest.getReleaseManagerListener() );


builder.setAdditionalArguments( additionalArguments );

if ( specificProfiles != null && !specificProfiles.isEmpty() )
{
List<String> allProfiles =
Expand Down
Expand Up @@ -110,6 +110,9 @@ public void executeGoals( File workingDirectory, List<String> goals, ReleaseEnvi

cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );

// FIX for MRELEASE-1105
//cl.addEnvironment( "MAVEN_DEBUG_OPTS", "" );

cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );

if ( settingsFile != null )
Expand Down
Expand Up @@ -72,6 +72,8 @@ public void executeGoals( File workingDirectory, List<String> goals, ReleaseEnvi
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 );
Expand Down
1 change: 1 addition & 0 deletions maven-release-plugin/pom.xml
Expand Up @@ -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>
Expand Down
@@ -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
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<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>

<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>
<arguments>-DskipTests</arguments>
<stagingRepository>file://${project.build.directory}/dummy/staging</stagingRepository>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -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://" )



@@ -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
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<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>

<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>
<stagingRepository>file://${project.build.directory}/dummy/staging</stagingRepository>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -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://" )



Expand Up @@ -88,6 +88,16 @@ public void testCreateGoals()
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
{
Expand Down
Expand Up @@ -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>
Expand Down

0 comments on commit 83deb62

Please sign in to comment.