diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
index a96583d64a..3b2d63aae0 100644
--- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
@@ -736,40 +736,6 @@ public class PomConstructionTest
}
}
- @Test
- public void testInterpolationOfLegacyExpressionsThatDontIncludeTheProjectPrefix()
- throws Exception
- {
- PomTestWrapper pom = buildPom( "unprefixed-expression-interpolation/child" );
-
- assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/projectDir" ).toString() ) );
-
- assertEquals( "org.apache.maven.its.mng3831.child", pom.getValue( "properties/projectGroupId" ) );
- assertEquals( "child", pom.getValue( "properties/projectArtifactId" ) );
- assertEquals( "2.0-alpha-1", pom.getValue( "properties/projectVersion" ) );
- assertEquals( "jar", pom.getValue( "properties/projectPackaging" ) );
-
- assertEquals( "child-name", pom.getValue( "properties/projectName" ) );
- assertEquals( "child-desc", pom.getValue( "properties/projectDesc" ) );
- assertEquals( "https://child.org/", pom.getValue( "properties/projectUrl" ) );
- assertEquals( "2008", pom.getValue( "properties/projectYear" ) );
- assertEquals( "child-org-name", pom.getValue( "properties/projectOrgName" ) );
-
- assertEquals( "2.0.0", pom.getValue( "properties/projectPrereqMvn" ) );
- assertEquals( "https://scm.org/", pom.getValue( "properties/projectScmUrl" ) );
- assertEquals( "https://issue.org/", pom.getValue( "properties/projectIssueUrl" ) );
- assertEquals( "https://ci.org/", pom.getValue( "properties/projectCiUrl" ) );
- assertEquals( "child-dist-repo", pom.getValue( "properties/projectDistRepoName" ) );
- assertEquals( "https://dist.org/", pom.getValue( "properties/projectDistRepoUrl" ) );
- assertEquals( "https://site.org/", pom.getValue( "properties/projectDistSiteUrl" ) );
-
- assertEquals( "org.apache.maven.its.mng3831", pom.getValue( "properties/parentGroupId" ) );
- assertEquals( "parent", pom.getValue( "properties/parentArtifactId" ) );
- assertEquals( "1.0", pom.getValue( "properties/parentVersion" ) );
-
- assertThat( pom.getValue( "properties/projectBuildOut" ).toString(), endsWith( "bin" ) );
- assertThat( pom.getValue( "properties/projectSiteOut" ).toString(), endsWith( "doc" ) );
- }
@Test
public void testInterpolationWithBasedirAlignedDirectories()
diff --git a/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/child/pom.xml b/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/child/pom.xml
deleted file mode 100644
index f6470289e0..0000000000
--- a/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/child/pom.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- 4.0.0
-
-
- org.apache.maven.its.mng3831
- parent
- 1.0
-
-
- org.apache.maven.its.mng3831.child
- child
- 2.0-alpha-1
- jar
-
- child-name
- child-desc
- https://child.org/
- 2008
-
- child-org-name
-
-
-
- 2.0.0
-
-
-
- https://scm.org/
-
-
- https://issue.org/
-
-
- https://ci.org/
-
-
-
- maven-core-it
- child-dist-repo
- https://dist.org/
-
-
- maven-core-it
- child-site
- https://site.org/
-
-
-
-
-
- ${basedir}
- ${groupId}
- ${artifactId}
- ${version}
- ${packaging}
- ${name}
- ${description}
- ${url}
- ${inceptionYear}
- ${organization.name}
- ${prerequisites.maven}
- ${scm.url}
- ${issueManagement.url}
- ${ciManagement.url}
- ${distributionManagement.repository.name}
- ${distributionManagement.repository.url}
- ${distributionManagement.site.url}
- ${build.outputDirectory}
- ${reporting.outputDirectory}
- ${parent.groupId}
- ${parent.artifactId}
- ${parent.version}
-
-
-
- target/bin
-
-
-
- target/doc
-
-
-
diff --git a/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/pom.xml b/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/pom.xml
deleted file mode 100644
index 28e0458e4e..0000000000
--- a/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.its.mng3831
- parent
- 1.0
- pom
-
- Maven Integration Test :: MNG-3831
- Test POM interpolation with expressions of the form $ { * } (ugly but real)
-
-
- parent/child
-
-
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
index 50a78be761..e42e6e3b63 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
@@ -31,13 +31,11 @@ import javax.inject.Inject;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelBuildingRequest;
-import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.path.PathTranslator;
import org.apache.maven.model.path.UrlNormalizer;
import org.codehaus.plexus.interpolation.AbstractValueSource;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.MapBasedValueSource;
-import org.codehaus.plexus.interpolation.ObjectBasedValueSource;
import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper;
@@ -90,21 +88,14 @@ public abstract class AbstractStringBasedModelInterpolator
}
protected List createValueSources( final Model model, final File projectDir,
- final ModelBuildingRequest config,
- final ModelProblemCollector problems )
+ final ModelBuildingRequest config )
{
Properties modelProperties = model.getProperties();
ValueSource projectPrefixValueSource = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
- ValueSource prefixlessObjectBasedValueSource = new ObjectBasedValueSource( model );
- if ( config.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
- {
- prefixlessObjectBasedValueSource =
- new ProblemDetectingValueSource( prefixlessObjectBasedValueSource, "", "project.", problems );
- }
// NOTE: Order counts here!
- List valueSources = new ArrayList<>( 9 );
+ List valueSources = new ArrayList<>( 8 );
if ( projectDir != null )
{
@@ -159,8 +150,6 @@ public abstract class AbstractStringBasedModelInterpolator
}
} );
- valueSources.add( prefixlessObjectBasedValueSource );
-
return valueSources;
}
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java
deleted file mode 100644
index 0b29f20e71..0000000000
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.apache.maven.model.interpolation;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-import org.apache.maven.model.building.ModelProblemCollector;
-import org.apache.maven.model.building.ModelProblem.Severity;
-import org.apache.maven.model.building.ModelProblem.Version;
-import org.apache.maven.model.building.ModelProblemCollectorRequest;
-import org.codehaus.plexus.interpolation.ValueSource;
-
-/**
- * Wraps another value source and intercepts interpolated expressions, checking for problems.
- *
- * @author Benjamin Bentmann
- */
-class ProblemDetectingValueSource
- implements ValueSource
-{
-
- private final ValueSource valueSource;
-
- private final String bannedPrefix;
-
- private final String newPrefix;
-
- private final ModelProblemCollector problems;
-
- ProblemDetectingValueSource( ValueSource valueSource, String bannedPrefix, String newPrefix,
- ModelProblemCollector problems )
- {
- this.valueSource = valueSource;
- this.bannedPrefix = bannedPrefix;
- this.newPrefix = newPrefix;
- this.problems = problems;
- }
-
- @Override
- public Object getValue( String expression )
- {
- Object value = valueSource.getValue( expression );
-
- if ( value != null && expression.startsWith( bannedPrefix ) )
- {
- String msg = "The expression ${" + expression + "} is deprecated.";
- if ( newPrefix != null && newPrefix.length() > 0 )
- {
- msg += " Please use ${" + newPrefix + expression.substring( bannedPrefix.length() ) + "} instead.";
- }
- problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg ) );
- }
-
- return value;
- }
-
- @Override
- public List getFeedback()
- {
- return valueSource.getFeedback();
- }
-
- @Override
- public void clearFeedback()
- {
- valueSource.clearFeedback();
- }
-
-}
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
index 99f55bd70c..d996097232 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
@@ -85,7 +85,7 @@ public class StringSearchModelInterpolator
void interpolateObject( Object obj, Model model, File projectDir, ModelBuildingRequest config,
ModelProblemCollector problems )
{
- List extends ValueSource> valueSources = createValueSources( model, projectDir, config, problems );
+ List extends ValueSource> valueSources = createValueSources( model, projectDir, config );
List extends InterpolationPostProcessor> postProcessors = createPostProcessors( model, projectDir, config );
InnerInterpolator innerInterpolator = createInterpolator( valueSources, postProcessors, problems );
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolator.java
index e2438d540a..3ba48ecc50 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolator.java
@@ -107,7 +107,7 @@ public class StringVisitorModelInterpolator
public Model interpolateModel( Model model, File projectDir, ModelBuildingRequest config,
ModelProblemCollector problems )
{
- List extends ValueSource> valueSources = createValueSources( model, projectDir, config, problems );
+ List extends ValueSource> valueSources = createValueSources( model, projectDir, config );
List extends InterpolationPostProcessor> postProcessors =
createPostProcessors( model, projectDir, config );
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java
index e4a7af3fd8..ca9d28edd5 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java
@@ -230,7 +230,7 @@ public abstract class AbstractModelInterpolatorTest
model.setVersion( "3.8.1" );
Dependency dep = new Dependency();
- dep.setVersion( "${version}" );
+ dep.setVersion( "${project.version}" );
model.addDependency( dep );
@@ -239,7 +239,7 @@ public abstract class AbstractModelInterpolatorTest
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ),
collector );
- assertCollectorState( 0, 0, 1, collector );
+ assertCollectorState( 0, 0, 0, collector );
assertEquals( "3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() );
}
@@ -288,7 +288,7 @@ public abstract class AbstractModelInterpolatorTest
model.setArtifactId( "foo" );
Dependency dep = new Dependency();
- dep.setVersion( "${artifactId}-${version}" );
+ dep.setVersion( "${project.artifactId}-${project.version}" );
model.addDependency( dep );
@@ -297,7 +297,7 @@ public abstract class AbstractModelInterpolatorTest
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ),
collector );
- assertCollectorState( 0, 0, 2, collector );
+ assertCollectorState( 0, 0, 0, collector );
assertEquals( "foo-3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() );
}
@@ -426,25 +426,19 @@ public abstract class AbstractModelInterpolatorTest
build.addResource( res );
- Resource res2 = new Resource();
- res2.setDirectory( "${build.sourceDirectory}" );
-
- build.addResource( res2 );
-
model.setBuild( build );
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
- assertCollectorState( 0, 0, 1, collector );
+ assertCollectorState( 0, 0, 0, collector );
List outResources = out.getBuild().getResources();
Iterator resIt = outResources.iterator();
assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() );
- assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() );
}
@Test