mirror of https://github.com/apache/maven.git
PR: MNG-864
Fail build if the model contains an expression that doesn't evaluate git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
84d1a85baf
commit
3171417299
|
@ -25,8 +25,14 @@ public class ModelInterpolationException
|
||||||
extends Exception
|
extends Exception
|
||||||
{
|
{
|
||||||
private String expression;
|
private String expression;
|
||||||
|
|
||||||
private String originalMessage;
|
private String originalMessage;
|
||||||
|
|
||||||
|
public ModelInterpolationException( String message )
|
||||||
|
{
|
||||||
|
super( message );
|
||||||
|
}
|
||||||
|
|
||||||
public ModelInterpolationException( String message, Throwable cause )
|
public ModelInterpolationException( String message, Throwable cause )
|
||||||
{
|
{
|
||||||
super( message, cause );
|
super( message, cause );
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a regular expression search to find and resolve expressions within the POM.
|
* Use a regular expression search to find and resolve expressions within the POM.
|
||||||
|
@ -142,6 +142,11 @@ public class RegexBasedModelInterpolator
|
||||||
// but this could result in multiple lookups of stringValue, and replaceAll is not correct behaviour
|
// but this could result in multiple lookups of stringValue, and replaceAll is not correct behaviour
|
||||||
matcher.reset( result );
|
matcher.reset( result );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ModelInterpolationException(
|
||||||
|
"Expression '" + wholeExpr + "' did not evaluate to anything in the model" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -68,9 +68,17 @@ public class RegexBasedModelInterpolatorTest
|
||||||
|
|
||||||
model.addDependency( dep );
|
model.addDependency( dep );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
|
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
|
||||||
|
fail( "Should have failed to interpolate with invalid reference" );
|
||||||
|
}
|
||||||
|
catch ( ModelInterpolationException expected )
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals( "${something}", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() );
|
// assertEquals( "${something}", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTwoReferences()
|
public void testTwoReferences()
|
||||||
|
|
Loading…
Reference in New Issue