Skip to content

Commit

Permalink
[MRELEASE-1042] releaseProfiles get overriden by activeProfiles
Browse files Browse the repository at this point in the history
Signed-off-by: rfscholte <[email protected]>
  • Loading branch information
Benoit Guerin authored and rfscholte committed Apr 2, 2021
1 parent a9e30c6 commit a553e19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -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<String> 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<String> performPhases = getGoalPhases( releaseStrategy, "perform" );
Expand Down Expand Up @@ -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 )
{
Expand All @@ -537,7 +550,6 @@ private BuilderReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptorBuilder
}
}


protected void clean( AbstractReleaseRequest releaseRequest ) throws ReleaseFailureException
{
ReleaseCleanRequest cleanRequest = new ReleaseCleanRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit a553e19

Please sign in to comment.