mirror of
https://github.com/apache/maven.git
synced 2025-03-09 11:26:28 +00:00
[MNG-7244] Remove deprecated WARNING for usage of pom.X placeholders
This closes #678
This commit is contained in:
parent
2798ee9196
commit
b2a21f12f8
@ -21,8 +21,8 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -52,7 +52,7 @@
|
||||
public abstract class AbstractStringBasedModelInterpolator
|
||||
implements ModelInterpolator
|
||||
{
|
||||
private static final List<String> PROJECT_PREFIXES = Arrays.asList( "pom.", "project." );
|
||||
private static final List<String> PROJECT_PREFIXES = Collections.singletonList( "project." );
|
||||
|
||||
private static final Collection<String> TRANSLATED_PATH_EXPRESSIONS;
|
||||
|
||||
@ -95,16 +95,12 @@ protected List<ValueSource> createValueSources( final Model model, final File pr
|
||||
{
|
||||
Properties modelProperties = model.getProperties();
|
||||
|
||||
ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
|
||||
ValueSource projectPrefixValueSource = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
|
||||
ValueSource prefixlessObjectBasedValueSource = new ObjectBasedValueSource( model );
|
||||
if ( config.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
||||
{
|
||||
modelValueSource1 = new ProblemDetectingValueSource( modelValueSource1, "pom.", "project.", problems );
|
||||
}
|
||||
|
||||
ValueSource modelValueSource2 = new ObjectBasedValueSource( model );
|
||||
if ( config.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
||||
{
|
||||
modelValueSource2 = new ProblemDetectingValueSource( modelValueSource2, "", "project.", problems );
|
||||
prefixlessObjectBasedValueSource =
|
||||
new ProblemDetectingValueSource( prefixlessObjectBasedValueSource, "", "project.", problems );
|
||||
}
|
||||
|
||||
// NOTE: Order counts here!
|
||||
@ -142,7 +138,7 @@ public Object getValue( String expression )
|
||||
valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), modelProperties ) );
|
||||
}
|
||||
|
||||
valueSources.add( modelValueSource1 );
|
||||
valueSources.add( projectPrefixValueSource );
|
||||
|
||||
valueSources.add( new MapBasedValueSource( config.getUserProperties() ) );
|
||||
|
||||
@ -163,7 +159,7 @@ public Object getValue( String expression )
|
||||
}
|
||||
} );
|
||||
|
||||
valueSources.add( modelValueSource2 );
|
||||
valueSources.add( prefixlessObjectBasedValueSource );
|
||||
|
||||
return valueSources;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws E
|
||||
|
||||
final SimpleProblemCollector collector = new SimpleProblemCollector();
|
||||
interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
|
||||
assertCollectorState( 0, 1, 0, collector );
|
||||
assertCollectorState( 0, 1, 0, collector );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -208,7 +208,7 @@ public void shouldInterpolateOrganizationNameCorrectly() throws Exception
|
||||
String orgName = "MyCo";
|
||||
|
||||
Model model = new Model();
|
||||
model.setName( "${pom.organization.name} Tools" );
|
||||
model.setName( "${project.organization.name} Tools" );
|
||||
|
||||
Organization org = new Organization();
|
||||
org.setName( orgName );
|
||||
@ -427,22 +427,17 @@ public void shouldInterpolateSourceDirectoryReferencedFromResourceDirectoryCorre
|
||||
build.addResource( res );
|
||||
|
||||
Resource res2 = new Resource();
|
||||
res2.setDirectory( "${pom.build.sourceDirectory}" );
|
||||
res2.setDirectory( "${build.sourceDirectory}" );
|
||||
|
||||
build.addResource( res2 );
|
||||
|
||||
Resource res3 = new Resource();
|
||||
res3.setDirectory( "${build.sourceDirectory}" );
|
||||
|
||||
build.addResource( res3 );
|
||||
|
||||
model.setBuild( build );
|
||||
|
||||
ModelInterpolator interpolator = createInterpolator();
|
||||
|
||||
final SimpleProblemCollector collector = new SimpleProblemCollector();
|
||||
Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
|
||||
assertCollectorState( 0, 0, 2, collector );
|
||||
assertCollectorState( 0, 0, 1, collector );
|
||||
|
||||
|
||||
List<Resource> outResources = out.getBuild().getResources();
|
||||
@ -450,7 +445,6 @@ public void shouldInterpolateSourceDirectoryReferencedFromResourceDirectoryCorre
|
||||
|
||||
assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() );
|
||||
assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() );
|
||||
assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -517,6 +511,29 @@ public void testRecursiveExpressionCycleBaseDir() throws Exception
|
||||
collector.getErrors().get( 0 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldIgnorePropertiesWithPomPrefix() throws Exception
|
||||
{
|
||||
final String orgName = "MyCo";
|
||||
final String expectedName = "${pom.organization.name} Tools";
|
||||
|
||||
Model model = new Model();
|
||||
model.setName( expectedName );
|
||||
|
||||
Organization org = new Organization();
|
||||
org.setName( orgName );
|
||||
|
||||
model.setOrganization( org );
|
||||
|
||||
ModelInterpolator interpolator = createInterpolator();
|
||||
SimpleProblemCollector collector = new SimpleProblemCollector();
|
||||
Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ),
|
||||
collector );
|
||||
|
||||
assertCollectorState( 0, 0, 0, collector );
|
||||
assertEquals( out.getName(), expectedName );
|
||||
}
|
||||
|
||||
protected abstract ModelInterpolator createInterpolator() throws Exception;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user