mirror of https://github.com/apache/maven.git
[MNG-7417] Several classes do not set properties properly for building requests
This closes #306
This commit is contained in:
parent
a5acd3ec60
commit
395411fe31
|
@ -587,6 +587,7 @@ public class MavenMetadataSource
|
|||
configuration.setProcessPlugins( false );
|
||||
configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT );
|
||||
configuration.setSystemProperties( getSystemProperties() );
|
||||
configuration.setUserProperties( new Properties() );
|
||||
configuration.setRepositorySession( legacySupport.getRepositorySession() );
|
||||
|
||||
project = getProjectBuilder().build( pomArtifact, configuration ).getProject();
|
||||
|
|
|
@ -143,7 +143,8 @@ public abstract class AbstractCoreMavenComponentTestCase
|
|||
.setLocalRepository( request.getLocalRepository() )
|
||||
.setRemoteRepositories( request.getRemoteRepositories() )
|
||||
.setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
|
||||
.setSystemProperties( executionProperties );
|
||||
.setSystemProperties( executionProperties )
|
||||
.setUserProperties( new Properties() );
|
||||
|
||||
List<MavenProject> projects = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ public class PomConstructionTest
|
|||
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" ) );
|
||||
}
|
||||
|
@ -1437,7 +1437,7 @@ public class PomConstructionTest
|
|||
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" ) );
|
||||
|
@ -1534,7 +1534,7 @@ public class PomConstructionTest
|
|||
{
|
||||
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" ) );
|
||||
}
|
||||
|
||||
|
@ -1681,7 +1681,7 @@ public class PomConstructionTest
|
|||
{
|
||||
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" ) );
|
||||
}
|
||||
|
@ -1838,17 +1838,17 @@ public class PomConstructionTest
|
|||
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 );
|
||||
|
@ -1864,8 +1864,8 @@ public class PomConstructionTest
|
|||
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 );
|
||||
|
||||
|
|
|
@ -274,8 +274,8 @@ public class DefaultArtifactDescriptorReader
|
|||
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,
|
||||
|
@ -328,17 +328,10 @@ public class DefaultArtifactDescriptorReader
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue