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.setProcessPlugins( false );
|
||||||
configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT );
|
configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT );
|
||||||
configuration.setSystemProperties( getSystemProperties() );
|
configuration.setSystemProperties( getSystemProperties() );
|
||||||
|
configuration.setUserProperties( new Properties() );
|
||||||
configuration.setRepositorySession( legacySupport.getRepositorySession() );
|
configuration.setRepositorySession( legacySupport.getRepositorySession() );
|
||||||
|
|
||||||
project = getProjectBuilder().build( pomArtifact, configuration ).getProject();
|
project = getProjectBuilder().build( pomArtifact, configuration ).getProject();
|
||||||
|
|
|
@ -143,7 +143,8 @@ public abstract class AbstractCoreMavenComponentTestCase
|
||||||
.setLocalRepository( request.getLocalRepository() )
|
.setLocalRepository( request.getLocalRepository() )
|
||||||
.setRemoteRepositories( request.getRemoteRepositories() )
|
.setRemoteRepositories( request.getRemoteRepositories() )
|
||||||
.setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
|
.setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
|
||||||
.setSystemProperties( executionProperties );
|
.setSystemProperties( executionProperties )
|
||||||
|
.setUserProperties( new Properties() );
|
||||||
|
|
||||||
List<MavenProject> projects = new ArrayList<>();
|
List<MavenProject> projects = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ public class PomConstructionTest
|
||||||
public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode()
|
public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode()
|
||||||
throws Exception
|
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( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() );
|
||||||
assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) );
|
assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) );
|
||||||
}
|
}
|
||||||
|
@ -1437,7 +1437,7 @@ public class PomConstructionTest
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put( "java.version", "1.5.0_15" );
|
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( 3, pom.getMavenProject().getActiveProfiles().size() );
|
||||||
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) );
|
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) );
|
||||||
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) );
|
assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) );
|
||||||
|
@ -1534,7 +1534,7 @@ public class PomConstructionTest
|
||||||
{
|
{
|
||||||
Properties sysProps = new Properties();
|
Properties sysProps = new Properties();
|
||||||
sysProps.setProperty( "system.property", "PASSED" );
|
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" ) );
|
assertEquals( "PASSED", pom.getValue( "name" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1681,7 +1681,7 @@ public class PomConstructionTest
|
||||||
{
|
{
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty( "testProperty", "PASSED" );
|
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" ) );
|
assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) );
|
||||||
}
|
}
|
||||||
|
@ -1838,17 +1838,17 @@ public class PomConstructionTest
|
||||||
private PomTestWrapper buildPom( String pomPath, String... profileIds )
|
private PomTestWrapper buildPom( String pomPath, String... profileIds )
|
||||||
throws Exception
|
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
|
throws Exception
|
||||||
{
|
{
|
||||||
return buildPom( pomPath, false, executionProperties, profileIds );
|
return buildPom( pomPath, false, systemProperties, userProperties, profileIds );
|
||||||
}
|
}
|
||||||
|
|
||||||
private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties,
|
private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties systemProperties,
|
||||||
String... profileIds )
|
Properties userProperties, String... profileIds )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
File pomFile = new File( testDirectory, pomPath );
|
File pomFile = new File( testDirectory, pomPath );
|
||||||
|
@ -1864,8 +1864,8 @@ public class PomConstructionTest
|
||||||
localRepoUrl = "file://" + localRepoUrl;
|
localRepoUrl = "file://" + localRepoUrl;
|
||||||
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) );
|
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) );
|
||||||
config.setActiveProfileIds( Arrays.asList( profileIds ) );
|
config.setActiveProfileIds( Arrays.asList( profileIds ) );
|
||||||
config.setSystemProperties( executionProperties );
|
config.setSystemProperties( systemProperties );
|
||||||
config.setUserProperties( executionProperties );
|
config.setUserProperties( userProperties );
|
||||||
config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
|
config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
|
||||||
: ModelBuildingRequest.VALIDATION_LEVEL_STRICT );
|
: ModelBuildingRequest.VALIDATION_LEVEL_STRICT );
|
||||||
|
|
||||||
|
|
|
@ -274,8 +274,8 @@ public class DefaultArtifactDescriptorReader
|
||||||
modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||||
modelRequest.setProcessPlugins( false );
|
modelRequest.setProcessPlugins( false );
|
||||||
modelRequest.setTwoPhaseBuilding( false );
|
modelRequest.setTwoPhaseBuilding( false );
|
||||||
modelRequest.setSystemProperties( toProperties( session.getUserProperties(),
|
modelRequest.setSystemProperties( toProperties( session.getSystemProperties() ) );
|
||||||
session.getSystemProperties() ) );
|
modelRequest.setUserProperties( toProperties( session.getUserProperties() ) );
|
||||||
modelRequest.setModelCache( DefaultModelCache.newInstance( session ) );
|
modelRequest.setModelCache( DefaultModelCache.newInstance( session ) );
|
||||||
modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ),
|
modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ),
|
||||||
request.getRequestContext(), artifactResolver,
|
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();
|
Properties props = new Properties();
|
||||||
if ( recessive != null )
|
props.putAll( map );
|
||||||
{
|
|
||||||
props.putAll( recessive );
|
|
||||||
}
|
|
||||||
if ( dominant != null )
|
|
||||||
{
|
|
||||||
props.putAll( dominant );
|
|
||||||
}
|
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue