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 f023ab680..b44934809 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 @@ -20,6 +20,7 @@ */ import java.io.File; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; @@ -304,21 +305,26 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result ReleaseUtils.buildReleaseDescriptor( performRequest.getReleaseDescriptorBuilder() ) .getActivateProfiles(); - ReleaseDescriptor releaseDescriptor = - loadReleaseDescriptor( performRequest.getReleaseDescriptorBuilder(), - performRequest.getReleaseManagerListener() ); + ReleaseDescriptorBuilder builder = + loadReleaseDescriptorBuilder( performRequest.getReleaseDescriptorBuilder(), + performRequest.getReleaseManagerListener() ); if ( specificProfiles != null && !specificProfiles.isEmpty() ) { + List allProfiles = new ArrayList<>(); + allProfiles.addAll( ReleaseUtils.buildReleaseDescriptor( builder ).getActivateProfiles() ); for ( String specificProfile : specificProfiles ) { - if ( !releaseDescriptor.getActivateProfiles().contains( specificProfile ) ) + if ( !allProfiles.contains( specificProfile ) ) { - releaseDescriptor.getActivateProfiles().add( specificProfile ); + allProfiles.add( specificProfile ); } } + builder.setActivateProfiles( allProfiles ); } + ReleaseDescriptor releaseDescriptor = ReleaseUtils.buildReleaseDescriptor( builder ); + Strategy releaseStrategy = getStrategy( releaseDescriptor.getReleaseStrategyId() ); List performPhases = getGoalPhases( releaseStrategy, "perform" ); @@ -521,13 +527,20 @@ protected File determineWorkingDirectory( File checkoutDirectory, String relativ private BuilderReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptorBuilder builder, ReleaseManagerListener listener ) throws ReleaseExecutionException + { + return ReleaseUtils.buildReleaseDescriptor( loadReleaseDescriptorBuilder( builder, listener ) ); + } + + private ReleaseDescriptorBuilder loadReleaseDescriptorBuilder( ReleaseDescriptorBuilder builder, + ReleaseManagerListener listener ) + throws ReleaseExecutionException { try { updateListener( listener, "verify-release-configuration", PHASE_START ); - BuilderReleaseDescriptor descriptor = ReleaseUtils.buildReleaseDescriptor( configStore.read( builder ) ); + ReleaseDescriptorBuilder result = configStore.read( builder ); updateListener( listener, "verify-release-configuration", PHASE_END ); - return descriptor; + return result; } catch ( ReleaseDescriptorStoreException e ) { @@ -537,7 +550,6 @@ private BuilderReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptorBuilder } } - protected void clean( AbstractReleaseRequest releaseRequest ) throws ReleaseFailureException { ReleaseCleanRequest cleanRequest = new ReleaseCleanRequest(); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java index 8e024d00a..bd11e2cc8 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java @@ -725,7 +725,7 @@ public void testKeepProfilesOnPerform() DefaultReleaseManager releaseManager = (DefaultReleaseManager) lookup( ReleaseManager.class, "test" ); ReleaseDescriptorBuilder secondBuilder = new ReleaseDescriptorBuilder(); - secondBuilder.setActivateProfiles( new ArrayList( Arrays.asList("aProfile", "bProfile") ) ); + secondBuilder.setActivateProfiles( Arrays.asList("aProfile", "bProfile") ); secondBuilder.setScmSourceUrl( "scm-url" ); ReleaseDescriptorStore configStoreMock = mock( ReleaseDescriptorStore.class ); when( configStoreMock.read( any( ReleaseDescriptorBuilder.class ) ) ).thenReturn( secondBuilder );