mirror of https://github.com/apache/maven.git
Merging 391974 from branch to fix IT errors introduced when attempting to fix the case where a resolved POM expression contains a substring referencing that POM element. Two-expression cycles are still possible.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@391988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
39132c3e37
commit
ea8e24b1fb
|
@ -164,7 +164,7 @@ public class RegexBasedModelInterpolator
|
|||
}
|
||||
|
||||
// if the expression refers to itself, skip it.
|
||||
if ( String.valueOf( value ).indexOf( realExpr ) > -1 )
|
||||
if ( String.valueOf( value ).indexOf( wholeExpr ) > -1 )
|
||||
{
|
||||
throw new ModelInterpolationException( wholeExpr, model.getId() + " references itself." );
|
||||
}
|
||||
|
|
|
@ -45,28 +45,61 @@ public class RegexBasedModelInterpolatorTest
|
|||
|
||||
context = Collections.singletonMap( "basedir", "myBasedir" );
|
||||
}
|
||||
|
||||
public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws IOException
|
||||
|
||||
public void testShouldNotThrowExceptionOnReferenceToNonExistentValue()
|
||||
throws IOException, ModelInterpolationException
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
|
||||
Scm scm = new Scm();
|
||||
scm.setConnection( "${test}/somepath" );
|
||||
|
||||
model.setScm( scm );
|
||||
|
||||
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
|
||||
|
||||
assertEquals( "${test}/somepath", out.getScm().getConnection() );
|
||||
}
|
||||
|
||||
public void testShouldThrowExceptionOnRecursiveScmConnectionReference()
|
||||
throws IOException
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
Scm scm = new Scm();
|
||||
scm.setConnection( "${project.scm.connection}/somepath" );
|
||||
|
||||
|
||||
model.setScm( scm );
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
|
||||
|
||||
|
||||
fail( "The interpolator should not allow self-referencing expressions in POM." );
|
||||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression()
|
||||
throws IOException, ModelInterpolationException
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
Scm scm = new Scm();
|
||||
scm.setConnection( "${test}/somepath" );
|
||||
|
||||
model.setScm( scm );
|
||||
|
||||
model.addProperty( "test", "test" );
|
||||
|
||||
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
|
||||
|
||||
assertEquals( "test/somepath", out.getScm().getConnection() );
|
||||
}
|
||||
|
||||
public void testShouldInterpolateOrganizationNameCorrectly()
|
||||
throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue