You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2009/04/27 15:58:48 UTC
svn commit: r768992 - in /maven/components/branches/maven-2.1.x: ./
maven-project/src/main/java/org/apache/maven/project/artifact/
maven-project/src/test/java/org/apache/maven/project/artifact/
Author: jdcasey
Date: Mon Apr 27 13:58:48 2009
New Revision: 768992
URL: http://svn.apache.org/viewvc?rev=768992&view=rev
Log:
[MNG-4140][MNG-4143] Go back to using JDK 1.4 binary compat, and catch NoClassDefFoundError to trigger a warning when POM version expressions can't be interpolated on install/deploy.
Added:
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/XPathVersionExpressionInterpolator.java
Modified:
maven/components/branches/maven-2.1.x/build.xml
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/VersionExpressionTransformation.java
maven/components/branches/maven-2.1.x/maven-project/src/test/java/org/apache/maven/project/artifact/VersionExpressionTransformationTest.java
maven/components/branches/maven-2.1.x/pom.xml
Modified: maven/components/branches/maven-2.1.x/build.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/build.xml?rev=768992&r1=768991&r2=768992&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/build.xml (original)
+++ maven/components/branches/maven-2.1.x/build.xml Mon Apr 27 13:58:48 2009
@@ -166,7 +166,7 @@
</path>
<mkdir dir="bootstrap/target/classes"/>
- <javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.5" target="1.5" debug="true">
+ <javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.4" target="1.4" debug="true">
<src refid="sources"/>
<classpath refid="pom.pathid"/>
</javac>
Modified: maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/VersionExpressionTransformation.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/VersionExpressionTransformation.java?rev=768992&r1=768991&r2=768992&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/VersionExpressionTransformation.java (original)
+++ maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/VersionExpressionTransformation.java Mon Apr 27 13:58:48 2009
@@ -37,90 +37,27 @@
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.RecursionInterceptor;
-import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor;
import org.codehaus.plexus.interpolation.ValueSource;
-import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.XmlStreamReader;
-import org.codehaus.plexus.util.xml.XmlStreamWriter;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
public class VersionExpressionTransformation
extends StringSearchModelInterpolator
implements Initializable, ArtifactTransformation
{
- private static final List<String> VERSION_INTERPOLATION_TARGET_XPATHS;
-
- static
- {
- List<String> targets = new ArrayList<String>();
-
- targets.add( "/project/parent/version/text()" );
- targets.add( "/project/version/text()" );
-
- targets.add( "/project/dependencies/dependency/version/text()" );
- targets.add( "/project/dependencyManagement/dependencies/dependency/version/text()" );
-
- targets.add( "/project/build/plugins/plugin/version/text()" );
- targets.add( "/project/build/pluginManagement/plugins/plugin/version/text()" );
- targets.add( "/project/build/plugins/plugin/dependencies/dependency/version/text()" );
- targets.add( "/project/build/pluginManagement/plugins/plugin/dependencies/dependency/version/text()" );
-
- targets.add( "/project/reporting/plugins/plugin/version/text()" );
-
- targets.add( "/project/profiles/profile/dependencies/dependency/version/text()" );
- targets.add( "/project/profiles/profile/dependencyManagement/dependencies/dependency/version/text()" );
-
- targets.add( "/project/profiles/profile/build/plugins/plugin/version/text()" );
- targets.add( "/project/profiles/profile/build/pluginManagement/plugins/plugin/version/text()" );
- targets.add( "/project/profiles/profile/build/plugins/plugin/dependencies/dependency/version/text()" );
- targets.add( "/project/profiles/profile/build/pluginManagement/plugins/plugin/dependencies/dependency/version/text()" );
-
- targets.add( "/project/profiles/profile/reporting/plugins/plugin/version/text()" );
-
- targets = Collections.unmodifiableList( targets );
-
- VERSION_INTERPOLATION_TARGET_XPATHS = targets;
- }
-
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException
@@ -309,7 +246,6 @@
return outputFile;
}
- @SuppressWarnings("unchecked")
protected void interpolateVersions( File pomFile, File outputFile, Model model, File projectDir,
ProjectBuilderConfiguration config )
throws ModelInterpolationException
@@ -320,7 +256,26 @@
// use of the XPP3 Model reader/writers, which have a tendency to lose XML comments and such.
// SOOO, we're using a two-stage string interpolation here. The first stage selects all XML 'version'
// elements, and subjects their values to interpolation in the second stage.
- XPathInterpolator interpolator = new XPathInterpolator( getLogger() );
+ XPathVersionExpressionInterpolator interpolator;
+ try
+ {
+ interpolator = new XPathVersionExpressionInterpolator( getLogger() );
+ }
+ catch ( NoClassDefFoundError ncdfe )
+ {
+ if ( ncdfe.getMessage().indexOf( "javax/xml/xpath" ) > -1 )
+ {
+ getLogger().warn( "Cannot load XPath classes from JDK. Your JDK version may be < 1.5." +
+ "\n\nNOTE: This prevents the interpolation of version expressions in your POMs " +
+ "during the install/deploy steps of the build!\n\n" );
+
+ return;
+ }
+ else
+ {
+ throw ncdfe;
+ }
+ }
// The second-stage interpolator is the 'normal' one used in all Model interpolation throughout
// maven-project.
@@ -333,18 +288,20 @@
// once we've isolated the version elements from the input XML.
interpolator.addValueSource( new SecondaryInterpolationValueSource( secondaryInterpolator, recursionInterceptor ) );
- List<ValueSource> valueSources = createValueSources( model, projectDir, config );
- List<InterpolationPostProcessor> postProcessors = createPostProcessors( model, projectDir, config );
+ List valueSources = createValueSources( model, projectDir, config );
+ List postProcessors = createPostProcessors( model, projectDir, config );
synchronized ( this )
{
- for ( ValueSource vs : valueSources )
+ for ( Iterator vsIt = valueSources.iterator(); vsIt.hasNext(); )
{
+ ValueSource vs = (ValueSource) vsIt.next();
secondaryInterpolator.addValueSource( vs );
}
- for ( InterpolationPostProcessor postProcessor : postProcessors )
+ for ( Iterator ppIt = postProcessors.iterator(); ppIt.hasNext(); )
{
+ InterpolationPostProcessor postProcessor = (InterpolationPostProcessor) ppIt.next();
secondaryInterpolator.addPostProcessor( postProcessor );
}
@@ -379,14 +336,15 @@
if ( debugEnabled )
{
- List<Object> feedback = (List<Object>) interpolator.getFeedback();
+ List feedback = (List) interpolator.getFeedback();
if ( feedback != null && !feedback.isEmpty() )
{
getLogger().debug( "Maven encountered the following problems while transforming POM versions:" );
Object last = null;
- for ( Object next : feedback )
+ for ( Iterator feedbackIt = feedback.iterator(); feedbackIt.hasNext(); )
{
+ Object next = (Object) feedbackIt.next();
if ( next instanceof Throwable )
{
if ( last == null )
@@ -420,13 +378,15 @@
}
finally
{
- for ( ValueSource vs : valueSources )
+ for ( Iterator vsIt = valueSources.iterator(); vsIt.hasNext(); )
{
+ ValueSource vs = (ValueSource) vsIt.next();
secondaryInterpolator.removeValuesSource( vs );
}
- for ( InterpolationPostProcessor postProcessor : postProcessors )
+ for ( Iterator ppIt = postProcessors.iterator(); ppIt.hasNext(); )
{
+ InterpolationPostProcessor postProcessor = (InterpolationPostProcessor) ppIt.next();
secondaryInterpolator.removePostProcessor( postProcessor );
}
@@ -467,7 +427,7 @@
private final RecursionInterceptor recursionInterceptor;
- private List<Object> localFeedback = new ArrayList<Object>();
+ private List localFeedback = new ArrayList();
public SecondaryInterpolationValueSource( Interpolator secondary, RecursionInterceptor recursionInterceptor )
{
@@ -480,7 +440,6 @@
secondary.clearFeedback();
}
- @SuppressWarnings("unchecked")
public List getFeedback()
{
List result = secondary.getFeedback();
@@ -510,238 +469,4 @@
}
}
- private static final class XPathInterpolator
- implements Interpolator
- {
-
- private List<InterpolationPostProcessor> postProcessors = new ArrayList<InterpolationPostProcessor>();
-
- private List<ValueSource> valueSources = new ArrayList<ValueSource>();
-
- private Map<String, Object> answers = new HashMap<String, Object>();
-
- private List<Object> feedback = new ArrayList<Object>();
-
- private final Logger logger;
-
- private String encoding;
-
- public XPathInterpolator( Logger logger )
- {
- this.logger = logger;
- }
-
- public void setEncoding( String encoding )
- {
- this.encoding = encoding;
- }
-
- public String interpolate( String input, RecursionInterceptor recursionInterceptor )
- throws InterpolationException
- {
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- TransformerFactory txFactory = TransformerFactory.newInstance();
- XPathFactory xpFactory = XPathFactory.newInstance();
-
- DocumentBuilder builder;
- Transformer transformer;
- XPath xpath;
- try
- {
- builder = dbFactory.newDocumentBuilder();
- transformer = txFactory.newTransformer();
- xpath = xpFactory.newXPath();
- }
- catch ( ParserConfigurationException e )
- {
- throw new InterpolationException( "Failed to construct XML DocumentBuilder: " + e.getMessage(), "-NONE-", e );
- }
- catch ( TransformerConfigurationException e )
- {
- throw new InterpolationException( "Failed to construct XML Transformer: " + e.getMessage(), "-NONE-", e );
- }
-
- Document document;
- try
- {
- document = builder.parse( new InputSource( new StringReader( input ) ) );
- }
- catch ( SAXException e )
- {
- throw new InterpolationException( "Failed to parse XML: " + e.getMessage(), "-NONE-", e );
- }
- catch ( IOException e )
- {
- throw new InterpolationException( "Failed to parse XML: " + e.getMessage(), "-NONE-", e );
- }
-
- inteprolateInternal( document, xpath );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XmlStreamWriter writer;
- try
- {
- writer = WriterFactory.newXmlWriter( baos );
- }
- catch ( IOException e )
- {
- throw new InterpolationException( "Failed to get XML writer: " + e.getMessage(), "-NONE-", e );
- }
-
- StreamResult r = new StreamResult( writer );
- DOMSource s = new DOMSource( document );
-
- try
- {
- if ( encoding != null )
- {
- logger.info( "Writing transformed POM using encoding: " + encoding );
- transformer.setOutputProperty( OutputKeys.ENCODING, encoding );
- }
- else
- {
- logger.info( "Writing transformed POM using default encoding" );
- }
-
- transformer.transform( s, r );
- }
- catch ( TransformerException e )
- {
- throw new InterpolationException( "Failed to render interpolated XML: " + e.getMessage(), "-NONE-", e );
- }
-
- try
- {
- return baos.toString( writer.getEncoding() );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new InterpolationException( "Failed to render interpolated XML: " + e.getMessage(), "-NONE-", e );
- }
- }
-
- private void inteprolateInternal( Document document, XPath xp )
- throws InterpolationException
- {
- for ( String expr : VERSION_INTERPOLATION_TARGET_XPATHS )
- {
- NodeList nodes;
- try
- {
- XPathExpression xpath = xp.compile( expr );
- nodes = (NodeList) xpath.evaluate( document, XPathConstants.NODESET );
- }
- catch ( XPathExpressionException e )
- {
- throw new InterpolationException( "Failed to evaluate XPath: " + expr + " (" + e.getMessage() + ")", "-NONE-", e );
- }
-
- if ( nodes != null )
- {
- for( int idx = 0; idx < nodes.getLength(); idx++ )
- {
- Node node = nodes.item( idx );
- Object value = node.getNodeValue();
- if ( value == null )
- {
- continue;
- }
-
- for ( ValueSource vs : valueSources )
- {
- if ( vs != null )
- {
- value = vs.getValue( value.toString() );
- if ( value != null && !value.equals( node.getNodeValue() ) )
- {
- break;
- }
- else if ( value == null )
- {
- value = node.getNodeValue();
- }
- }
- }
-
- if ( value != null && !value.equals( node.getNodeValue() ) )
- {
- for ( InterpolationPostProcessor postProcessor : postProcessors )
- {
- if ( postProcessor != null )
- {
- value = postProcessor.execute( node.getNodeValue(), value );
- }
- }
-
- node.setNodeValue( String.valueOf( value ) );
- }
- }
- }
- }
- }
-
- public void addPostProcessor( InterpolationPostProcessor postProcessor )
- {
- postProcessors.add( postProcessor );
- }
-
- public void addValueSource( ValueSource valueSource )
- {
- valueSources.add( valueSource );
- }
-
- public void clearAnswers()
- {
- answers.clear();
- }
-
- public void clearFeedback()
- {
- feedback.clear();
- }
-
- @SuppressWarnings( "unchecked" )
- public List getFeedback()
- {
- return feedback;
- }
-
- public String interpolate( String input )
- throws InterpolationException
- {
- return interpolate( input, new SimpleRecursionInterceptor() );
- }
-
- public String interpolate( String input, String thisPrefixPattern )
- throws InterpolationException
- {
- return interpolate( input, new SimpleRecursionInterceptor() );
- }
-
- public String interpolate( String input, String thisPrefixPattern, RecursionInterceptor recursionInterceptor )
- throws InterpolationException
- {
- return interpolate( input, recursionInterceptor );
- }
-
- public boolean isCacheAnswers()
- {
- return true;
- }
-
- public void removePostProcessor( InterpolationPostProcessor postProcessor )
- {
- postProcessors.remove( postProcessor );
- }
-
- public void removeValuesSource( ValueSource valueSource )
- {
- valueSources.remove( valueSource );
- }
-
- public void setCacheAnswers( boolean cacheAnswers )
- {
- }
- }
-
}
Added: maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/XPathVersionExpressionInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/XPathVersionExpressionInterpolator.java?rev=768992&view=auto
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/XPathVersionExpressionInterpolator.java (added)
+++ maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/artifact/XPathVersionExpressionInterpolator.java Mon Apr 27 13:58:48 2009
@@ -0,0 +1,314 @@
+package org.apache.maven.project.artifact;
+
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.codehaus.plexus.interpolation.RecursionInterceptor;
+import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor;
+import org.codehaus.plexus.interpolation.ValueSource;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.util.xml.XmlStreamWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+public class XPathVersionExpressionInterpolator
+ implements Interpolator
+{
+ private static final List VERSION_INTERPOLATION_TARGET_XPATHS;
+
+ static
+ {
+ List targets = new ArrayList();
+
+ targets.add( "/project/parent/version/text()" );
+ targets.add( "/project/version/text()" );
+
+ targets.add( "/project/dependencies/dependency/version/text()" );
+ targets.add( "/project/dependencyManagement/dependencies/dependency/version/text()" );
+
+ targets.add( "/project/build/plugins/plugin/version/text()" );
+ targets.add( "/project/build/pluginManagement/plugins/plugin/version/text()" );
+ targets.add( "/project/build/plugins/plugin/dependencies/dependency/version/text()" );
+ targets.add( "/project/build/pluginManagement/plugins/plugin/dependencies/dependency/version/text()" );
+
+ targets.add( "/project/reporting/plugins/plugin/version/text()" );
+
+ targets.add( "/project/profiles/profile/dependencies/dependency/version/text()" );
+ targets.add( "/project/profiles/profile/dependencyManagement/dependencies/dependency/version/text()" );
+
+ targets.add( "/project/profiles/profile/build/plugins/plugin/version/text()" );
+ targets.add( "/project/profiles/profile/build/pluginManagement/plugins/plugin/version/text()" );
+ targets.add( "/project/profiles/profile/build/plugins/plugin/dependencies/dependency/version/text()" );
+ targets.add( "/project/profiles/profile/build/pluginManagement/plugins/plugin/dependencies/dependency/version/text()" );
+
+ targets.add( "/project/profiles/profile/reporting/plugins/plugin/version/text()" );
+
+ targets = Collections.unmodifiableList( targets );
+
+ VERSION_INTERPOLATION_TARGET_XPATHS = targets;
+ }
+
+ private List postProcessors = new ArrayList();
+
+ private List valueSources = new ArrayList();
+
+ private Map answers = new HashMap();
+
+ private List feedback = new ArrayList();
+
+ private final Logger logger;
+
+ private String encoding;
+
+ public XPathVersionExpressionInterpolator( Logger logger )
+ {
+ this.logger = logger;
+ }
+
+ public void setEncoding( String encoding )
+ {
+ this.encoding = encoding;
+ }
+
+ public String interpolate( String input, RecursionInterceptor recursionInterceptor )
+ throws InterpolationException
+ {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ TransformerFactory txFactory = TransformerFactory.newInstance();
+ XPathFactory xpFactory = XPathFactory.newInstance();
+
+ DocumentBuilder builder;
+ Transformer transformer;
+ XPath xpath;
+ try
+ {
+ builder = dbFactory.newDocumentBuilder();
+ transformer = txFactory.newTransformer();
+ xpath = xpFactory.newXPath();
+ }
+ catch ( ParserConfigurationException e )
+ {
+ throw new InterpolationException( "Failed to construct XML DocumentBuilder: " + e.getMessage(), "-NONE-", e );
+ }
+ catch ( TransformerConfigurationException e )
+ {
+ throw new InterpolationException( "Failed to construct XML Transformer: " + e.getMessage(), "-NONE-", e );
+ }
+
+ Document document;
+ try
+ {
+ document = builder.parse( new InputSource( new StringReader( input ) ) );
+ }
+ catch ( SAXException e )
+ {
+ throw new InterpolationException( "Failed to parse XML: " + e.getMessage(), "-NONE-", e );
+ }
+ catch ( IOException e )
+ {
+ throw new InterpolationException( "Failed to parse XML: " + e.getMessage(), "-NONE-", e );
+ }
+
+ inteprolateInternal( document, xpath );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XmlStreamWriter writer;
+ try
+ {
+ writer = WriterFactory.newXmlWriter( baos );
+ }
+ catch ( IOException e )
+ {
+ throw new InterpolationException( "Failed to get XML writer: " + e.getMessage(), "-NONE-", e );
+ }
+
+ StreamResult r = new StreamResult( writer );
+ DOMSource s = new DOMSource( document );
+
+ try
+ {
+ if ( encoding != null )
+ {
+ logger.info( "Writing transformed POM using encoding: " + encoding );
+ transformer.setOutputProperty( OutputKeys.ENCODING, encoding );
+ }
+ else
+ {
+ logger.info( "Writing transformed POM using default encoding" );
+ }
+
+ transformer.transform( s, r );
+ }
+ catch ( TransformerException e )
+ {
+ throw new InterpolationException( "Failed to render interpolated XML: " + e.getMessage(), "-NONE-", e );
+ }
+
+ try
+ {
+ return baos.toString( writer.getEncoding() );
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ throw new InterpolationException( "Failed to render interpolated XML: " + e.getMessage(), "-NONE-", e );
+ }
+ }
+
+ private void inteprolateInternal( Document document, XPath xp )
+ throws InterpolationException
+ {
+ for ( Iterator it = VERSION_INTERPOLATION_TARGET_XPATHS.iterator(); it.hasNext(); )
+ {
+ String expr = (String) it.next();
+ NodeList nodes;
+ try
+ {
+ XPathExpression xpath = xp.compile( expr );
+ nodes = (NodeList) xpath.evaluate( document, XPathConstants.NODESET );
+ }
+ catch ( XPathExpressionException e )
+ {
+ throw new InterpolationException(
+ "Failed to evaluate XPath: " + expr + " (" + e.getMessage() + ")",
+ "-NONE-", e );
+ }
+
+ if ( nodes != null )
+ {
+ for ( int idx = 0; idx < nodes.getLength(); idx++ )
+ {
+ Node node = nodes.item( idx );
+ Object value = node.getNodeValue();
+ if ( value == null )
+ {
+ continue;
+ }
+
+ for ( Iterator vsIt = valueSources.iterator(); vsIt.hasNext(); )
+ {
+ ValueSource vs = (ValueSource) vsIt.next();
+ if ( vs != null )
+ {
+ value = vs.getValue( value.toString() );
+ if ( value != null && !value.equals( node.getNodeValue() ) )
+ {
+ break;
+ }
+ else if ( value == null )
+ {
+ value = node.getNodeValue();
+ }
+ }
+ }
+
+ if ( value != null && !value.equals( node.getNodeValue() ) )
+ {
+ for ( Iterator ppIt = postProcessors.iterator(); ppIt.hasNext(); )
+ {
+ InterpolationPostProcessor postProcessor = (InterpolationPostProcessor) ppIt.next();
+ if ( postProcessor != null )
+ {
+ value = postProcessor.execute( node.getNodeValue(), value );
+ }
+ }
+
+ node.setNodeValue( String.valueOf( value ) );
+ }
+ }
+ }
+ }
+ }
+
+ public void addPostProcessor( InterpolationPostProcessor postProcessor )
+ {
+ postProcessors.add( postProcessor );
+ }
+
+ public void addValueSource( ValueSource valueSource )
+ {
+ valueSources.add( valueSource );
+ }
+
+ public void clearAnswers()
+ {
+ answers.clear();
+ }
+
+ public void clearFeedback()
+ {
+ feedback.clear();
+ }
+
+ public List getFeedback()
+ {
+ return feedback;
+ }
+
+ public String interpolate( String input )
+ throws InterpolationException
+ {
+ return interpolate( input, new SimpleRecursionInterceptor() );
+ }
+
+ public String interpolate( String input, String thisPrefixPattern )
+ throws InterpolationException
+ {
+ return interpolate( input, new SimpleRecursionInterceptor() );
+ }
+
+ public String interpolate( String input, String thisPrefixPattern, RecursionInterceptor recursionInterceptor )
+ throws InterpolationException
+ {
+ return interpolate( input, recursionInterceptor );
+ }
+
+ public boolean isCacheAnswers()
+ {
+ return true;
+ }
+
+ public void removePostProcessor( InterpolationPostProcessor postProcessor )
+ {
+ postProcessors.remove( postProcessor );
+ }
+
+ public void removeValuesSource( ValueSource valueSource )
+ {
+ valueSources.remove( valueSource );
+ }
+
+ public void setCacheAnswers( boolean cacheAnswers )
+ {
+ }
+}
Modified: maven/components/branches/maven-2.1.x/maven-project/src/test/java/org/apache/maven/project/artifact/VersionExpressionTransformationTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/test/java/org/apache/maven/project/artifact/VersionExpressionTransformationTest.java?rev=768992&r1=768991&r2=768992&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-project/src/test/java/org/apache/maven/project/artifact/VersionExpressionTransformationTest.java (original)
+++ maven/components/branches/maven-2.1.x/maven-project/src/test/java/org/apache/maven/project/artifact/VersionExpressionTransformationTest.java Mon Apr 27 13:58:48 2009
@@ -64,6 +64,7 @@
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
@@ -75,7 +76,7 @@
private VersionExpressionTransformation transformation;
- private Set<File> toDelete = new HashSet<File>();
+ private Set toDelete = new HashSet();
public void setUp()
throws Exception
@@ -95,8 +96,9 @@
if ( toDelete != null && !toDelete.isEmpty() )
{
- for ( File f : toDelete )
+ for ( Iterator it = toDelete.iterator(); it.hasNext(); )
{
+ File f = (File) it.next();
try
{
FileUtils.forceDelete( f );
Modified: maven/components/branches/maven-2.1.x/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/pom.xml?rev=768992&r1=768991&r2=768992&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/pom.xml (original)
+++ maven/components/branches/maven-2.1.x/pom.xml Mon Apr 27 13:58:48 2009
@@ -135,8 +135,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.4</source>
+ <target>1.4</target>
</configuration>
</plugin>
<plugin>