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

[MNG-7417] Several classes do not set properties properly for building requests #306

Merged
merged 1 commit into from
Feb 21, 2022
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 @@ -570,6 +570,7 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact, MetadataR
configuration.setProcessPlugins( false );
configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT );
configuration.setSystemProperties( getSystemProperties() );
configuration.setUserProperties( new Properties() );
configuration.setRepositorySession( legacySupport.getRepositorySession() );

project = projectBuilder.build( pomArtifact, configuration ).getProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ protected MavenSession createMavenSession( File pom, Properties executionPropert
.setLocalRepository( request.getLocalRepository() )
.setRemoteRepositories( request.getRemoteRepositories() )
.setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
.setSystemProperties( executionProperties );
.setSystemProperties( executionProperties )
.setUserProperties( new Properties() );

List<MavenProject> projects = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void testValidationErrorUponNonUniqueDependencyManagementKeyInProfile()
public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode()
throws Exception
{
PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null );
PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null, null );
assertEquals( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() );
assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) );
}
Expand Down Expand Up @@ -1517,7 +1517,7 @@ public void testJdkActivation()
Properties props = new Properties();
props.put( "java.version", "1.5.0_15" );

PomTestWrapper pom = buildPom( "jdk-activation", props );
PomTestWrapper pom = buildPom( "jdk-activation", props, null );
assertEquals( 3, pom.getMavenProject().getActiveProfiles().size() );
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) );
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) );
Expand Down Expand Up @@ -1624,7 +1624,7 @@ public void testInterpolationWithSystemProperty()
{
Properties sysProps = new Properties();
sysProps.setProperty( "system.property", "PASSED" );
PomTestWrapper pom = buildPom( "system-property-interpolation", sysProps );
PomTestWrapper pom = buildPom( "system-property-interpolation", sysProps, null );
assertEquals( "PASSED", pom.getValue( "name" ) );
}

Expand Down Expand Up @@ -1764,7 +1764,7 @@ public void testCliPropsDominateProjectPropsDuringInterpolation()
{
Properties props = new Properties();
props.setProperty( "testProperty", "PASSED" );
PomTestWrapper pom = buildPom( "interpolation-cli-wins", props );
PomTestWrapper pom = buildPom( "interpolation-cli-wins", null, props );

assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) );
}
Expand Down Expand Up @@ -1918,17 +1918,17 @@ private void assertPathWithNormalizedFileSeparators( Object value )
private PomTestWrapper buildPom( String pomPath, String... profileIds )
throws Exception
{
return buildPom( pomPath, null, profileIds );
return buildPom( pomPath, null, null, profileIds );
}

private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds )
private PomTestWrapper buildPom( String pomPath, Properties systemProperties, Properties userProperties, String... profileIds )
throws Exception
{
return buildPom( pomPath, false, executionProperties, profileIds );
return buildPom( pomPath, false, systemProperties, userProperties, profileIds );
}

private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties,
String... profileIds )
private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties systemProperties,
Properties userProperties, String... profileIds )
throws Exception
{
File pomFile = new File( testDirectory, pomPath );
Expand All @@ -1944,8 +1944,8 @@ private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Prop
localRepoUrl = "file://" + localRepoUrl;
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) );
config.setActiveProfileIds( Arrays.asList( profileIds ) );
config.setSystemProperties( executionProperties );
config.setUserProperties( executionProperties );
config.setSystemProperties( systemProperties );
config.setUserProperties( userProperties );
config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
: ModelBuildingRequest.VALIDATION_LEVEL_STRICT );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
modelRequest.setProcessPlugins( false );
modelRequest.setTwoPhaseBuilding( false );
modelRequest.setSystemProperties( toProperties( session.getUserProperties(),
session.getSystemProperties() ) );
modelRequest.setSystemProperties( toProperties( session.getSystemProperties() ) );
modelRequest.setUserProperties( toProperties( session.getUserProperties() ) );
modelRequest.setModelCache( DefaultModelCache.newInstance( session ) );
modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ),
request.getRequestContext(), artifactResolver,
Expand Down Expand Up @@ -273,17 +273,10 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
}
}

private Properties toProperties( Map<String, String> dominant, Map<String, String> recessive )
private Properties toProperties( Map<String, String> map )
{
Properties props = new Properties();
if ( recessive != null )
{
props.putAll( recessive );
}
if ( dominant != null )
{
props.putAll( dominant );
}
props.putAll( map );
return props;
}

Expand Down