Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1042] - releaseProfiles get overriden by activeProfiles #50

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,25 @@ public void perform( ReleasePerformRequest performRequest )
private void perform( ReleasePerformRequest performRequest, ReleaseResult result )
throws ReleaseExecutionException, ReleaseFailureException
{
List<String> specificProfiles =
ReleaseUtils.buildReleaseDescriptor( performRequest.getReleaseDescriptorBuilder() )
.getActivateProfiles();

ReleaseDescriptor releaseDescriptor =
loadReleaseDescriptor( performRequest.getReleaseDescriptorBuilder(),
performRequest.getReleaseManagerListener() );

if ( specificProfiles != null && !specificProfiles.isEmpty() )
{
for ( String specificProfile : specificProfiles )
{
if ( !releaseDescriptor.getActivateProfiles().contains( specificProfile ) )
{
releaseDescriptor.getActivateProfiles().add( specificProfile );
}
}
}

Strategy releaseStrategy = getStrategy( releaseDescriptor.getReleaseStrategyId() );

List<String> performPhases = getGoalPhases( releaseStrategy, "perform" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
Expand All @@ -50,9 +52,11 @@
import org.apache.maven.shared.release.config.ReleaseDescriptorStore;
import org.apache.maven.shared.release.config.ReleaseDescriptorStoreException;
import org.apache.maven.shared.release.config.ReleaseDescriptorStoreStub;
import org.apache.maven.shared.release.config.ReleaseUtils;
import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
import org.apache.maven.shared.release.phase.ReleasePhase;
import org.apache.maven.shared.release.phase.ReleasePhaseStub;
import org.apache.maven.shared.release.phase.RunPerformGoalsPhase;
import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
Expand Down Expand Up @@ -702,6 +706,38 @@ public void testScmResultFailure()
}
}

// MRELEASE-1042
public void testKeepProfilesOnPerform()
throws Exception
{
// prepare
ReleasePerformRequest performRequest = new ReleasePerformRequest();
performRequest.setDryRun( true );

ReleaseManagerListener managerListener = mock( ReleaseManagerListener.class );
performRequest.setReleaseManagerListener( managerListener );

ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder();
builder.setActivateProfiles( Arrays.asList("aProfile", "anotherOne") );
builder.setWorkingDirectory( getTestFile( "target/working-directory" ).getAbsolutePath() );
performRequest.setReleaseDescriptorBuilder( builder );

DefaultReleaseManager releaseManager = (DefaultReleaseManager) lookup( ReleaseManager.class, "test" );

ReleaseDescriptorBuilder secondBuilder = new ReleaseDescriptorBuilder();
secondBuilder.setActivateProfiles( new ArrayList( Arrays.asList("aProfile", "bProfile") ) );
secondBuilder.setScmSourceUrl( "scm-url" );
ReleaseDescriptorStore configStoreMock = mock( ReleaseDescriptorStore.class );
when( configStoreMock.read( any( ReleaseDescriptorBuilder.class ) ) ).thenReturn( secondBuilder );
releaseManager.setConfigStore( configStoreMock );

// test
ReleaseResult result = releaseManager.performWithResult( performRequest );

// verify
assertTrue( result.getOutput().contains( "-P aProfile,bProfile,anotherOne" ) );
}

public void testDetermineWorkingDirectory()
throws Exception
{
Expand Down