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 2008/07/23 23:52:35 UTC
svn commit: r679206 - in /maven/components/branches/maven-2.0.x: ./
apache-maven/
maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/
maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/
maven-artifact/src/main/ja...
Author: jdcasey
Date: Wed Jul 23 14:52:34 2008
New Revision: 679206
URL: http://svn.apache.org/viewvc?rev=679206&view=rev
Log:
Merging RC branch from revId 675662 to revId 679193 back to 2.0.x branch for further development.
Added:
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
maven/components/branches/maven-2.0.x/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml
Removed:
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingValueSource.java
Modified:
maven/components/branches/maven-2.0.x/apache-maven/pom.xml
maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
maven/components/branches/maven-2.0.x/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
maven/components/branches/maven-2.0.x/maven-core-it-runner/pom.xml
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
maven/components/branches/maven-2.0.x/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java
maven/components/branches/maven-2.0.x/maven-script/maven-script-ant/pom.xml
maven/components/branches/maven-2.0.x/pom.xml
Modified: maven/components/branches/maven-2.0.x/apache-maven/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/apache-maven/pom.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/apache-maven/pom.xml (original)
+++ maven/components/branches/maven-2.0.x/apache-maven/pom.xml Wed Jul 23 14:52:34 2008
@@ -105,18 +105,8 @@
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<excludes>
- <exclude>
- org.codehaus.plexus.util.xml.Xpp3Dom
- </exclude>
- <exclude>
- org.codehaus.plexus.util.xml.pull.XmlPullParser
- </exclude>
- <exclude>
- org.codehaus.plexus.util.xml.pull.XmlPullParserException
- </exclude>
- <exclude>
- org.codehaus.plexus.util.xml.pull.XmlSerializer
- </exclude>
+ <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
+ <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
</relocation>
</relocations>
Modified: maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java (original)
+++ maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java Wed Jul 23 14:52:34 2008
@@ -50,11 +50,15 @@
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
@@ -64,16 +68,19 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
public class DefaultWagonManager
extends AbstractLogEnabled
- implements WagonManager, Contextualizable
+ implements WagonManager, Contextualizable, Initializable
{
private static final String WILDCARD = "*";
private static final String EXTERNAL_WILDCARD = "external:*";
+ private static final String MAVEN_ARTIFACT_PROPERTIES = "META-INF/maven/org.apache.maven/maven-artifact/pom.properties";
+
private PlexusContainer container;
// TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps
@@ -102,6 +109,8 @@
private RepositoryPermissions defaultRepositoryPermissions;
+ private String httpUserAgent;
+
// TODO: this leaks the component in the public api - it is never released back to the container
public Wagon getWagon( Repository repository )
throws UnsupportedProtocolException, WagonConfigurationException
@@ -115,7 +124,7 @@
Wagon wagon = getWagon( protocol );
- configureWagon( wagon, repository.getId() );
+ configureWagon( wagon, repository.getId(), protocol );
return wagon;
}
@@ -988,21 +997,27 @@
ArtifactRepository repository )
throws WagonConfigurationException
{
- configureWagon( wagon, repository.getId() );
+ configureWagon( wagon, repository.getId(), repository.getProtocol() );
}
private void configureWagon( Wagon wagon,
- String repositoryId )
+ String repositoryId,
+ String protocol )
throws WagonConfigurationException
{
- if ( serverConfigurationMap.containsKey( repositoryId ) )
+ PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId );
+ if ( protocol.startsWith( "http" ) || protocol.startsWith( "dav" ) )
+ {
+ config = updateUserAgentForHttp( wagon, config );
+ }
+
+ if ( config != null )
{
ComponentConfigurator componentConfigurator = null;
try
{
componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
- componentConfigurator.configureComponent( wagon, (PlexusConfiguration) serverConfigurationMap
- .get( repositoryId ), container.getContainerRealm() );
+ componentConfigurator.configureComponent( wagon, config, container.getContainerRealm() );
}
catch ( final ComponentLookupException e )
{
@@ -1032,6 +1047,59 @@
}
}
+ // TODO: Remove this, once the maven-shade-plugin 1.2 release is out, allowing configuration of httpHeaders in the components.xml
+ private PlexusConfiguration updateUserAgentForHttp( Wagon wagon, PlexusConfiguration config )
+ {
+ if ( config == null )
+ {
+ config = new XmlPlexusConfiguration( "configuration" );
+ }
+
+ if ( httpUserAgent != null )
+ {
+ try
+ {
+ wagon.getClass().getMethod( "setHttpHeaders", new Class[]{ Properties.class } );
+
+ PlexusConfiguration headerConfig = config.getChild( "httpHeaders", true );
+ PlexusConfiguration[] children = headerConfig.getChildren( "property" );
+ boolean found = false;
+ for ( int i = 0; i < children.length; i++ )
+ {
+ PlexusConfiguration c = children[i].getChild( "name", false );
+ if ( c != null && "User-Agent".equals( c.getValue( null ) ) )
+ {
+ found = true;
+ break;
+ }
+ }
+ if ( !found )
+ {
+ XmlPlexusConfiguration propertyConfig = new XmlPlexusConfiguration( "property" );
+ headerConfig.addChild( propertyConfig );
+
+ XmlPlexusConfiguration nameConfig = new XmlPlexusConfiguration( "name" );
+ nameConfig.setValue( "User-Agent" );
+ propertyConfig.addChild( nameConfig );
+
+ XmlPlexusConfiguration versionConfig = new XmlPlexusConfiguration( "value" );
+ versionConfig.setValue( httpUserAgent );
+ propertyConfig.addChild( versionConfig );
+ }
+ }
+ catch ( SecurityException e )
+ {
+ // forget it. this method is public, if it exists.
+ }
+ catch ( NoSuchMethodException e )
+ {
+ // forget it.
+ }
+ }
+
+ return config;
+ }
+
public void addConfiguration( String repositoryId,
Xpp3Dom configuration )
{
@@ -1049,4 +1117,58 @@
{
this.defaultRepositoryPermissions = defaultRepositoryPermissions;
}
+
+ // TODO: Remove this, once the maven-shade-plugin 1.2 release is out, allowing configuration of httpHeaders in the components.xml
+ public void initialize()
+ throws InitializationException
+ {
+ if ( httpUserAgent == null )
+ {
+ InputStream resourceAsStream = null;
+ try
+ {
+ Properties properties = new Properties();
+ resourceAsStream = getClass().getClassLoader().getResourceAsStream( MAVEN_ARTIFACT_PROPERTIES );
+
+ if ( resourceAsStream != null )
+ {
+ try
+ {
+ properties.load( resourceAsStream );
+
+ httpUserAgent =
+ "maven-artifact/" + properties.getProperty( "version" ) + " (Java "
+ + System.getProperty( "java.version" ) + "; " + System.getProperty( "os.name" ) + " "
+ + System.getProperty( "os.version" ) + ")";
+ }
+ catch ( IOException e )
+ {
+ getLogger().warn(
+ "Failed to load Maven artifact properties from:\n" + MAVEN_ARTIFACT_PROPERTIES
+ + "\n\nUser-Agent HTTP header may be incorrect for artifact resolution." );
+ }
+ }
+ }
+ finally
+ {
+ IOUtil.close( resourceAsStream );
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setHttpUserAgent( String userAgent )
+ {
+ this.httpUserAgent = userAgent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getHttpUserAgent()
+ {
+ return httpUserAgent;
+ }
}
Modified: maven/components/branches/maven-2.0.x/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java (original)
+++ maven/components/branches/maven-2.0.x/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java Wed Jul 23 14:52:34 2008
@@ -53,7 +53,7 @@
public class DefaultWagonManagerTest
extends PlexusTestCase
{
- private DefaultWagonManager wagonManager;
+ private WagonManager wagonManager;
private TransferListener transferListener = new Debug();
@@ -64,7 +64,7 @@
{
super.setUp();
- wagonManager = (DefaultWagonManager) lookup( WagonManager.ROLE );
+ wagonManager = (WagonManager) lookup( WagonManager.ROLE );
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
}
Modified: maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (original)
+++ maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java Wed Jul 23 14:52:34 2008
@@ -384,7 +384,7 @@
}
Artifact relocated = source.retrieveRelocatedArtifact( artifact, localRepository, childRemoteRepositories );
- if ( !artifact.equals( relocated ) )
+ if ( relocated != null && !artifact.equals( relocated ) )
{
artifact = relocated;
child.setArtifact( artifact );
Modified: maven/components/branches/maven-2.0.x/maven-core-it-runner/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core-it-runner/pom.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core-it-runner/pom.xml (original)
+++ maven/components/branches/maven-2.0.x/maven-core-it-runner/pom.xml Wed Jul 23 14:52:34 2008
@@ -36,8 +36,12 @@
<repository>
<id>test-plugins</id>
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
- <releases><enabled>false</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
</repository>
</repositories>
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed Jul 23 14:52:34 2008
@@ -21,8 +21,10 @@
import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.manager.DefaultWagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.BuildFailure;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
@@ -602,6 +604,49 @@
private void resolveParameters( Settings settings )
throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
{
+ // TODO: remove when components.xml can be used to configure this instead
+ try
+ {
+ DefaultWagonManager wagonManager = (DefaultWagonManager) container.lookup( WagonManager.ROLE );
+
+ String oldUserAgent = wagonManager.getHttpUserAgent();
+ int firstSpace = oldUserAgent == null ? -1 : oldUserAgent.indexOf( " " );
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append( "Apache-Maven/" );
+
+ ArtifactVersion version = runtimeInformation.getApplicationVersion();
+ if ( version != null )
+ {
+ buffer.append( version.getMajorVersion() );
+ buffer.append( '.' );
+ buffer.append( version.getMinorVersion() );
+ }
+ else
+ {
+ buffer.append( "unknown" );
+ }
+
+ buffer.append( ' ' );
+ if ( firstSpace > -1 )
+ {
+ buffer.append( oldUserAgent.substring( firstSpace + 1 ) );
+ buffer.append( ' ' );
+ buffer.append( oldUserAgent.substring( 0, firstSpace ) );
+ }
+ else
+ {
+ buffer.append( oldUserAgent );
+ }
+
+ wagonManager.setHttpUserAgent( buffer.toString() );
+ }
+ catch ( ClassCastException e )
+ {
+ // ignore
+ }
+
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
try
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed Jul 23 14:52:34 2008
@@ -1694,4 +1694,9 @@
return tasks;
}
}
+
+ public List getLifecycles()
+ {
+ return lifecycles;
+ }
}
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Wed Jul 23 14:52:34 2008
@@ -19,6 +19,8 @@
* under the License.
*/
+import java.util.List;
+
import org.apache.maven.BuildFailureException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
@@ -35,4 +37,9 @@
void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
throws LifecycleExecutionException, BuildFailureException;
+ /**
+ * @since 2.0.10
+ */
+ List getLifecycles();
+
}
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/resources/META-INF/plexus/components.xml Wed Jul 23 14:52:34 2008
@@ -584,37 +584,17 @@
</requirements>
</component>
+ <!-- TODO: Re-enable this once maven-shade-plugin 1.2 is release and can be
+ used to merge this configuration with that of the wagon artifacts.
+ We also need a way not to filter in the os.name, etc during the build, just the project version
<component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>http</role-hint>
- <implementation>org.apache.maven.wagon.providers.http.LightweightHttpWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description>LightweightHttpWagon</description>
- <isolated-realm>false</isolated-realm>
+ <role>org.apache.maven.artifact.manager.WagonManager</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
<configuration>
- <httpHeaders>
- <property>
- <name>User-Agent</name>
- <value>Apache Maven/${project.version}</value>
- </property>
- </httpHeaders>
- </configuration>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>https</role-hint>
- <implementation>org.apache.maven.wagon.providers.http.LightweightHttpsWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description>LIghtweightHttpsWagon</description>
- <isolated-realm>false</isolated-realm>
- <configuration>
- <httpHeaders>
- <property>
- <name>User-Agent</name>
- <value>Apache Maven/${project.version}</value>
- </property>
- </httpHeaders>
+ <httpUserAgent>Apache-Maven/${project.version} maven-artifact/${project.version} (Java @java.version@; @os.name@ @os.version@)</httpUserAgent>
</configuration>
</component>
+ -->
</components>
</component-set>
Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Wed Jul 23 14:52:34 2008
@@ -1114,6 +1114,8 @@
dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() );
+
+ dPlugin.setDependencies( iPlugin.getDependencies() );
}
}
@@ -1135,6 +1137,8 @@
dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() );
+
+ dPlugin.setDependencies( iPlugin.getDependencies() );
}
}
}
Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Wed Jul 23 14:52:34 2008
@@ -562,6 +562,8 @@
public static Model cloneModel( Model model )
{
// TODO: would be nice for the modello:java code to generate this as a copy constructor
+ // FIXME: Fix deep cloning issues with existing plugin instances (setting
+ // a version when resolved will pollute the original model instance)
Model newModel = new Model();
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
newModel.setModelVersion( model.getModelVersion() );
Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Wed Jul 23 14:52:34 2008
@@ -92,7 +92,7 @@
if ( rel == null )
{
- return null;
+ return artifact;
}
MavenProject project = rel.project;
@@ -101,14 +101,21 @@
return artifact;
}
+
+ // NOTE: Using artifact information here, since some POMs are deployed
+ // to central with one version in the filename, but another in the <version> string!
+ // Case in point: org.apache.ws.commons:XmlSchema:1.1:pom.
+ //
+ // Since relocation triggers a reconfiguration of the artifact's information
+ // in retrieveRelocatedProject(..), this is safe to do.
Artifact result = null;
if ( artifact.getClassifier() != null )
{
- result = artifactFactory.createArtifactWithClassifier( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getType(), artifact.getClassifier() );
+ result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() );
}
else
{
- result = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getScope(), artifact.getType() );
+ result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), artifact.getType() );
}
result.setResolved( artifact.isResolved() );
Added: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java?rev=679206&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java (added)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java Wed Jul 23 14:52:34 2008
@@ -0,0 +1,60 @@
+package org.apache.maven.project.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 org.apache.maven.project.path.PathTranslator;
+import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper;
+import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
+import org.codehaus.plexus.interpolation.ValueSource;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ *
+ * @version $Id: PathTranslatingPostProcessor.java 677447 2008-07-16 22:15:57Z jdcasey $
+ */
+public class PathTranslatingPostProcessor
+ implements InterpolationPostProcessor
+{
+
+ private final List unprefixedPathKeys;
+ private final File projectDir;
+ private final PathTranslator pathTranslator;
+
+ public PathTranslatingPostProcessor( List unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
+ {
+ this.unprefixedPathKeys = unprefixedPathKeys;
+ this.projectDir = projectDir;
+ this.pathTranslator = pathTranslator;
+ }
+
+ public Object execute( String expression,
+ Object value )
+ {
+ if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) )
+ {
+ return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir );
+ }
+
+ return value;
+ }
+
+}
Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java Wed Jul 23 14:52:34 2008
@@ -89,6 +89,12 @@
public RegexBasedModelInterpolator( Properties envars )
{
}
+
+ // for testing.
+ protected RegexBasedModelInterpolator( PathTranslator pathTranslator )
+ {
+ this.pathTranslator = pathTranslator;
+ }
/**
* @todo: Remove the throws clause.
@@ -202,15 +208,8 @@
timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat );
}
- ValueSource baseModelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
- ValueSource modelValueSource1 = new PathTranslatingValueSource( baseModelValueSource1,
- TRANSLATED_PATH_EXPRESSIONS,
- projectDir, pathTranslator );
-
- ValueSource baseModelValueSource2 = new ObjectBasedValueSource( model );
- ValueSource modelValueSource2 = new PathTranslatingValueSource( baseModelValueSource2,
- TRANSLATED_PATH_EXPRESSIONS,
- projectDir, pathTranslator );
+ ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
+ ValueSource modelValueSource2 = new ObjectBasedValueSource( model );
ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new ValueSource(){
public Object getValue( String expression )
@@ -235,6 +234,11 @@
interpolator.addValueSource( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
interpolator.addValueSource( modelValueSource2 );
interpolator.addValueSource( new MapBasedValueSource( config.getUserProperties() ) );
+
+ PathTranslatingPostProcessor pathTranslatingPostProcessor =
+ new PathTranslatingPostProcessor( TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator );
+
+ interpolator.addPostProcessor( pathTranslatingPostProcessor );
RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );
Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml Wed Jul 23 14:52:34 2008
@@ -115,7 +115,7 @@
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.4.1</version>
+ <version>2.4.2</version>
</plugin>
<plugin>
<artifactId>maven-rar-plugin</artifactId>
@@ -131,7 +131,7 @@
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-6</version>
+ <version>2.0-beta-7</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
@@ -139,7 +139,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
+ <version>2.4.3</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
Modified: maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java Wed Jul 23 14:52:34 2008
@@ -20,24 +20,34 @@
*/
import org.apache.maven.model.Build;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Resource;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
public class MavenProjectDynamismTest
extends PlexusTestCase
{
-
+
private MavenProjectBuilder projectBuilder;
public void setUp()
@@ -60,9 +70,12 @@
Build build = project.getBuild();
- assertTrue( build.getSourceDirectory() + " doesn't start with base-path: " + basepath, build.getSourceDirectory().startsWith( basepath ) );
- assertTrue( build.getTestSourceDirectory() + " doesn't start with base-path: " + basepath, build.getTestSourceDirectory().startsWith( basepath ) );
- assertTrue( build.getScriptSourceDirectory() + " doesn't start with base-path: " + basepath, build.getScriptSourceDirectory().startsWith( basepath ) );
+ assertTrue( build.getSourceDirectory() + " doesn't start with base-path: " + basepath,
+ build.getSourceDirectory().startsWith( basepath ) );
+ assertTrue( build.getTestSourceDirectory() + " doesn't start with base-path: " + basepath,
+ build.getTestSourceDirectory().startsWith( basepath ) );
+ assertTrue( build.getScriptSourceDirectory() + " doesn't start with base-path: " + basepath,
+ build.getScriptSourceDirectory().startsWith( basepath ) );
List plugins = build.getPlugins();
assertNotNull( plugins );
@@ -79,10 +92,8 @@
for ( int i = 0; i < children.length; i++ )
{
- assertEquals( "Configuration parameter: "
- + children[i].getName()
- + " should have a an interpolated POM groupId as its value.",
- children[i].getValue(),
+ assertEquals( "Configuration parameter: " + children[i].getName()
+ + " should have a an interpolated POM groupId as its value.", children[i].getValue(),
project.getGroupId() );
}
@@ -93,10 +104,13 @@
String nakedGidExpr = "${groupId}";
build = project.getBuild();
-
- assertTrue( build.getSourceDirectory() + " didn't start with: " + projectGidExpr, build.getSourceDirectory().startsWith( projectGidExpr ) );
- assertTrue( build.getTestSourceDirectory() + " didn't start with: " + pomGidExpr, build.getTestSourceDirectory().startsWith( pomGidExpr ) );
- assertTrue( build.getScriptSourceDirectory() + " didn't start with: " + nakedGidExpr, build.getScriptSourceDirectory().startsWith( nakedGidExpr ) );
+
+ assertTrue( build.getSourceDirectory() + " didn't start with: " + projectGidExpr,
+ build.getSourceDirectory().startsWith( projectGidExpr ) );
+ assertTrue( build.getTestSourceDirectory() + " didn't start with: " + pomGidExpr,
+ build.getTestSourceDirectory().startsWith( pomGidExpr ) );
+ assertTrue( build.getScriptSourceDirectory() + " didn't start with: " + nakedGidExpr,
+ build.getScriptSourceDirectory().startsWith( nakedGidExpr ) );
plugins = build.getPlugins();
assertNotNull( plugins );
@@ -111,19 +125,19 @@
children = conf.getChildren();
assertEquals( 3, children.length );
- assertEquals( "Configuration parameter: " + children[0].getName() + " should have "
- + projectGidExpr + " as its value.", children[0].getValue(), projectGidExpr );
+ assertEquals( "Configuration parameter: " + children[0].getName() + " should have " + projectGidExpr
+ + " as its value.", children[0].getValue(), projectGidExpr );
- assertEquals( "Configuration parameter: " + children[1].getName() + " should have "
- + pomGidExpr + " as its value.", children[1].getValue(), pomGidExpr );
+ assertEquals( "Configuration parameter: " + children[1].getName() + " should have " + pomGidExpr
+ + " as its value.", children[1].getValue(), pomGidExpr );
- assertEquals( "Configuration parameter: " + children[2].getName() + " should have "
- + nakedGidExpr + " as its value.", children[2].getValue(), nakedGidExpr );
+ assertEquals( "Configuration parameter: " + children[2].getName() + " should have " + nakedGidExpr
+ + " as its value.", children[2].getValue(), nakedGidExpr );
}
public void testRoundTrip()
- throws IOException, XmlPullParserException, URISyntaxException,
- ModelInterpolationException, ProjectBuildingException
+ throws IOException, XmlPullParserException, URISyntaxException, ModelInterpolationException,
+ ProjectBuildingException
{
MavenProject project = buildProject( "pom.xml" );
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
@@ -155,9 +169,7 @@
assertNotNull( "Concrete compile-source roots should not be null.", compileSourceRoots );
- assertEquals( "Concrete compile-source roots should contain one entry.",
- 1,
- compileSourceRoots.size() );
+ assertEquals( "Concrete compile-source roots should contain one entry.", 1, compileSourceRoots.size() );
assertEquals( "Concrete compile-source roots should contain interpolated source-directory value.",
new File( baseDir, "/src/main/java" ).getAbsolutePath(),
@@ -165,12 +177,9 @@
List testCompileSourceRoots = project.getTestCompileSourceRoots();
- assertNotNull( "Concrete test-compile-source roots should not be null.",
- testCompileSourceRoots );
+ assertNotNull( "Concrete test-compile-source roots should not be null.", testCompileSourceRoots );
- assertEquals( "Concrete test-compile-source roots should contain one entry.",
- 1,
- testCompileSourceRoots.size() );
+ assertEquals( "Concrete test-compile-source roots should contain one entry.", 1, testCompileSourceRoots.size() );
assertEquals( "Concrete test-compile-source roots should contain interpolated test-source-directory value.",
new File( baseDir, "/src/test/java" ).getAbsolutePath(),
@@ -180,9 +189,7 @@
assertNotNull( "Concrete script-source roots should not be null.", scriptSourceRoots );
- assertEquals( "Concrete script-source roots should contain one entry.",
- 1,
- scriptSourceRoots.size() );
+ assertEquals( "Concrete script-source roots should contain one entry.", 1, scriptSourceRoots.size() );
assertEquals( "Concrete script-source roots should contain interpolated script-source-directory value.",
new File( baseDir, "/src/main/scripts" ).getAbsolutePath(),
@@ -216,8 +223,7 @@
new File( buildDir, "/test-classes" ).getAbsolutePath(),
new File( build.getTestOutputDirectory() ).getAbsolutePath() );
- assertEquals( "Concrete build directory should be absolute.",
- new File( baseDir, "target" ).getAbsolutePath(),
+ assertEquals( "Concrete build directory should be absolute.", new File( baseDir, "target" ).getAbsolutePath(),
new File( build.getDirectory() ).getAbsolutePath() );
// --------------------------------------------------------------------
@@ -231,54 +237,42 @@
build = project.getBuild();
- assertEquals( "Restored source directory should be expressed in terms of the basedir.\nWas: " + build.getSourceDirectory() + "\nShould be: " + basedirExpr + "/src/main/java\n",
- basedirExpr + "/src/main/java",
- build.getSourceDirectory() );
-
- assertEquals( "Restored test-source directory should be expressed in terms of the basedir.",
- basedirExpr + "/src/test/java",
- build.getTestSourceDirectory() );
-
- assertEquals( "Restored script-source directory should be expressed in terms of the basedir.",
- basedirExpr + "/src/main/scripts",
- build.getScriptSourceDirectory() );
+ assertEquals( "Restored source directory should be expressed in terms of the basedir.\nWas: "
+ + build.getSourceDirectory() + "\nShould be: " + basedirExpr + "/src/main/java\n", basedirExpr
+ + "/src/main/java", build.getSourceDirectory() );
+
+ assertEquals( "Restored test-source directory should be expressed in terms of the basedir.", basedirExpr
+ + "/src/test/java", build.getTestSourceDirectory() );
+
+ assertEquals( "Restored script-source directory should be expressed in terms of the basedir.", basedirExpr
+ + "/src/main/scripts", build.getScriptSourceDirectory() );
compileSourceRoots = project.getCompileSourceRoots();
assertNotNull( "Restored compile-source roots should not be null.", compileSourceRoots );
- assertEquals( "Restored compile-source roots should contain one entry.",
- 1,
- compileSourceRoots.size() );
+ assertEquals( "Restored compile-source roots should contain one entry.", 1, compileSourceRoots.size() );
assertEquals( "Restored compile-source roots should contain uninterpolated source-directory value.",
- "${pom.basedir}/src/main/java",
- compileSourceRoots.get( 0 ) );
+ "${pom.basedir}/src/main/java", compileSourceRoots.get( 0 ) );
testCompileSourceRoots = project.getTestCompileSourceRoots();
- assertNotNull( "Restored test-compile-source roots should not be null.",
- testCompileSourceRoots );
+ assertNotNull( "Restored test-compile-source roots should not be null.", testCompileSourceRoots );
- assertEquals( "Restored test-compile-source roots should contain one entry.",
- 1,
- testCompileSourceRoots.size() );
+ assertEquals( "Restored test-compile-source roots should contain one entry.", 1, testCompileSourceRoots.size() );
assertEquals( "Restored test-compile-source roots should contain uninterpolated test-source-directory value.",
- "${pom.basedir}/src/test/java",
- testCompileSourceRoots.get( 0 ) );
+ "${pom.basedir}/src/test/java", testCompileSourceRoots.get( 0 ) );
scriptSourceRoots = project.getScriptSourceRoots();
assertNotNull( "Restored script-source roots should not be null.", scriptSourceRoots );
- assertEquals( "Restored script-source roots should contain one entry.",
- 1,
- scriptSourceRoots.size() );
+ assertEquals( "Restored script-source roots should contain one entry.", 1, scriptSourceRoots.size() );
assertEquals( "Restored script-source roots should contain uninterpolated script-source-directory value.",
- "${pom.basedir}/src/main/scripts",
- scriptSourceRoots.get( 0 ) );
+ "${pom.basedir}/src/main/scripts", scriptSourceRoots.get( 0 ) );
resources = build.getResources();
@@ -286,9 +280,8 @@
assertEquals( "Restored resources should contain one entry.", 1, resources.size() );
- assertEquals( "Restored resource should contain uninterpolated reference to build directory.",
- buildDirExpr + "/generated-resources/plexus",
- ( (Resource) resources.get( 0 ) ).getDirectory() );
+ assertEquals( "Restored resource should contain uninterpolated reference to build directory.", buildDirExpr
+ + "/generated-resources/plexus", ( (Resource) resources.get( 0 ) ).getDirectory() );
filters = build.getFilters();
@@ -296,21 +289,16 @@
assertEquals( "Restored filters should contain one entry.", 1, filters.size() );
- assertEquals( "Restored filter entry should contain uninterpolated reference to build directory.",
- buildDirExpr + "/generated-filters.properties",
- filters.get( 0 ) );
-
- assertEquals( "Restored output-directory should be expressed in terms of the build-directory.",
- buildDirExpr + "/classes",
- build.getOutputDirectory() );
+ assertEquals( "Restored filter entry should contain uninterpolated reference to build directory.", buildDirExpr
+ + "/generated-filters.properties", filters.get( 0 ) );
+
+ assertEquals( "Restored output-directory should be expressed in terms of the build-directory.", buildDirExpr
+ + "/classes", build.getOutputDirectory() );
assertEquals( "Restored test-output-directory should be expressed in terms of the build-directory.",
- buildDirExpr + "/test-classes",
- build.getTestOutputDirectory() );
+ buildDirExpr + "/test-classes", build.getTestOutputDirectory() );
- assertEquals( "Restored build directory should be relative.",
- "target",
- build.getDirectory() );
+ assertEquals( "Restored build directory should be relative.", "target", build.getDirectory() );
}
public void testShouldPreserveAddedResourceInRestoredState()
@@ -345,9 +333,7 @@
resources = build.getResources();
assertNotNull( "Restored resources should not be null.", resources );
assertEquals( "Restored resources should contain two entries.", 2, resources.size() );
- assertResourcePresent( "restored resources",
- "${pom.build.directory}/generated-resources/plexus",
- resources );
+ assertResourcePresent( "restored resources", "${pom.build.directory}/generated-resources/plexus", resources );
assertResourcePresent( "restored resources", "myDir", resources );
}
@@ -380,9 +366,7 @@
filters = build.getFilters();
assertNotNull( "Restored filters should not be null.", filters );
assertEquals( "Restored filters should contain two entries.", 2, filters.size() );
- assertFilterPresent( "restored filters",
- "${pom.build.directory}/generated-filters.properties",
- filters );
+ assertFilterPresent( "restored filters", "${pom.build.directory}/generated-filters.properties", filters );
assertFilterPresent( "restored filters", "myDir/filters.properties", filters );
}
@@ -398,8 +382,7 @@
Build build = project.getBuild();
assertEquals( "First concrete build directory should be absolute and point to target dir.",
- new File( project.getBasedir(), "target" ).getAbsolutePath(),
- build.getDirectory() );
+ new File( project.getBasedir(), "target" ).getAbsolutePath(), build.getDirectory() );
assertEquals( "First concrete build output-directory should be absolute and point to target/classes dir.",
new File( project.getBasedir(), "target/classes" ).getAbsolutePath(),
new File( build.getOutputDirectory() ).getAbsolutePath() );
@@ -407,9 +390,9 @@
build.setDirectory( "target2" );
assertEquals( "AFTER CHANGING BUILD DIRECTORY, build directory should be relative and point to target2 dir.",
- "target2",
- build.getDirectory() );
- assertEquals( "AFTER CHANGING BUILD DIRECTORY, build output-directory should be absolute and still point to target/classes dir.",
+ "target2", build.getDirectory() );
+ assertEquals(
+ "AFTER CHANGING BUILD DIRECTORY, build output-directory should be absolute and still point to target/classes dir.",
new File( project.getBasedir(), "target/classes" ).getAbsolutePath(),
new File( build.getOutputDirectory() ).getAbsolutePath() );
@@ -443,8 +426,7 @@
projectBuilder.calculateConcreteState( project, config );
assertEquals( "After resetting build-directory and going through a recalculation phase for the project, "
- + "property value for 'myProperty' should STILL be the absolute initial build directory.",
- originalValue,
+ + "property value for 'myProperty' should STILL be the absolute initial build directory.", originalValue,
project.getProperties().getProperty( "myProperty" ) );
}
@@ -458,51 +440,53 @@
projectBuilder.calculateConcreteState( project, config );
List compileSourceRoots = project.getCompileSourceRoots();
- assertNotNull( "First concrete state compile-source roots should not be null.",
- compileSourceRoots );
- assertEquals( "First concrete state should contain one compile-source root.",
- 1,
- compileSourceRoots.size() );
+ assertNotNull( "First concrete state compile-source roots should not be null.", compileSourceRoots );
+ assertEquals( "First concrete state should contain one compile-source root.", 1, compileSourceRoots.size() );
assertEquals( "First concrete state should have an absolute path for compile-source root.",
- new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(),
- compileSourceRoots.get( 0 ) );
+ new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) );
- String newSourceRoot = new File( project.getBuild().getDirectory(),
- "generated-sources/modello" ).getAbsolutePath();
+ String newSourceRoot =
+ new File( project.getBuild().getDirectory(), "generated-sources/modello" ).getAbsolutePath();
project.addCompileSourceRoot( newSourceRoot );
projectBuilder.restoreDynamicState( project, config );
compileSourceRoots = project.getCompileSourceRoots();
- assertNotNull( "Restored dynamic state compile-source roots should not be null.",
- compileSourceRoots );
- assertEquals( "Restored dynamic state should contain two compile-source roots.",
- 2,
- compileSourceRoots.size() );
+ assertNotNull( "Restored dynamic state compile-source roots should not be null.", compileSourceRoots );
+ assertEquals( "Restored dynamic state should contain two compile-source roots.", 2, compileSourceRoots.size() );
assertEquals( "Restored dynamic state should have a relative path for original compile-source root.",
- "src/main/java",
- compileSourceRoots.get( 0 ) );
+ "src/main/java", compileSourceRoots.get( 0 ) );
assertEquals( "Restored dynamic state should have a relative path for new compile-source root.",
- "target/generated-sources/modello",
- compileSourceRoots.get( 1 ) );
+ "target/generated-sources/modello", compileSourceRoots.get( 1 ) );
projectBuilder.calculateConcreteState( project, config );
compileSourceRoots = project.getCompileSourceRoots();
- assertNotNull( "Second concrete state compile-source roots should not be null.",
- compileSourceRoots );
- assertEquals( "Second concrete state should contain two compile-source roots.",
- 2,
- compileSourceRoots.size() );
+ assertNotNull( "Second concrete state compile-source roots should not be null.", compileSourceRoots );
+ assertEquals( "Second concrete state should contain two compile-source roots.", 2, compileSourceRoots.size() );
assertEquals( "Second concrete state should have an absolute path for original compile-source root.",
- new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(),
- compileSourceRoots.get( 0 ) );
- assertEquals( "Second concrete state should have an absolute path for new compile-source root.",
- newSourceRoot,
+ new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) );
+ assertEquals( "Second concrete state should have an absolute path for new compile-source root.", newSourceRoot,
compileSourceRoots.get( 1 ) );
}
+ public void testShouldInterpolatePluginLevelDependency()
+ throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
+ ModelInterpolationException
+ {
+ MavenProject project = buildProject( "plugin-level-dep.pom.xml" );
+
+ Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( "org.apache.maven.plugins:maven-compiler-plugin" );
+
+ assertNotNull( "ERROR - compiler plugin config not found!", plugin );
+ assertTrue( "ERROR - compiler plugin custom dependencies not found!", ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) );
+
+ Dependency dep = (Dependency) plugin.getDependencies().get( 0 );
+
+ assertEquals( "custom dependency version should be an INTERPOLATED reference to this project's version.", project.getVersion(), dep.getVersion() );
+ }
+
// Useful for diagnostics.
// private void displayPOM( Model model )
// throws IOException
@@ -513,9 +497,7 @@
// System.out.println( writer.toString() );
// }
- private void assertResourcePresent( String testLabel,
- String directory,
- List resources )
+ private void assertResourcePresent( String testLabel, String directory, List resources )
{
boolean found = false;
@@ -524,7 +506,8 @@
for ( Iterator it = resources.iterator(); it.hasNext(); )
{
Resource resource = (Resource) it.next();
- if ( new File( directory ).getAbsolutePath().equals( new File( resource.getDirectory() ).getAbsolutePath() ) )
+ if ( new File( directory ).getAbsolutePath().equals(
+ new File( resource.getDirectory() ).getAbsolutePath() ) )
{
found = true;
break;
@@ -538,9 +521,7 @@
}
}
- private void assertFilterPresent( String testLabel,
- String path,
- List filters )
+ private void assertFilterPresent( String testLabel, String path, List filters )
{
boolean found = false;
@@ -574,11 +555,13 @@
fail( "Cannot find classpath resource for POM: " + path );
}
- File pomFile = new File( resource.getPath() );
+ String resourcePath = StringUtils.replace( resource.getPath(), "%20", " " );
+ URI uri = new File( resourcePath ).toURI().normalize();
+
+ File pomFile = new File( uri );
pomFile = pomFile.getAbsoluteFile();
- MavenProject project = projectBuilder.build( pomFile,
- new DefaultProjectBuilderConfiguration() );
+ MavenProject project = projectBuilder.build( pomFile, new DefaultProjectBuilderConfiguration() );
assertEquals( pomFile, project.getFile() );
Modified: maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java Wed Jul 23 14:52:34 2008
@@ -27,6 +27,8 @@
import org.apache.maven.model.Resource;
import org.apache.maven.model.Scm;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.path.DefaultPathTranslator;
+import org.apache.maven.project.path.PathTranslator;
import java.io.File;
import java.io.IOException;
@@ -317,6 +319,31 @@
assertEquals( new File( basedir, "artifact.jar" ).getAbsolutePath(), new File( ( (Dependency) rDeps.get( 0 ) )
.getSystemPath() ).getAbsolutePath() );
}
+
+ public void testTwoLevelRecursiveBasedirAlignedExpression()
+ throws Exception
+ {
+ Model model = new Model();
+ Build build = new Build();
+
+ model.setBuild( build );
+
+ build.setDirectory( "${project.basedir}/target" );
+ build.setOutputDirectory( "${project.build.directory}/classes" );
+
+ PathTranslator translator = new DefaultPathTranslator();
+ RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator( translator );
+
+ File basedir = new File( System.getProperty( "java.io.tmpdir" ), "base" );
+
+ String value = interpolator.interpolate( "${project.build.outputDirectory}/foo", model, basedir, new DefaultProjectBuilderConfiguration(), true );
+ value = value.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+
+ String check = new File( basedir, "target/classes/foo" ).getAbsolutePath();
+ check = check.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+
+ assertEquals( check, value );
+ }
// public void testPOMExpressionDoesNotUseSystemProperty()
// throws Exception
Added: maven/components/branches/maven-2.0.x/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml?rev=679206&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml (added)
+++ maven/components/branches/maven-2.0.x/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml Wed Jul 23 14:52:34 2008
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>testing</groupId>
+ <artifactId>plugin-level-dep</artifactId>
+ <packaging>jar</packaging>
+ <version>3.8.1</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Modified: maven/components/branches/maven-2.0.x/maven-script/maven-script-ant/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-script/maven-script-ant/pom.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-script/maven-script-ant/pom.xml (original)
+++ maven/components/branches/maven-2.0.x/maven-script/maven-script-ant/pom.xml Wed Jul 23 14:52:34 2008
@@ -30,6 +30,16 @@
<name>Maven Ant Mojo Support</name>
<dependencies>
<dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</dependency>
@@ -37,6 +47,19 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-ant-factory</artifactId>
<version>1.0-alpha-2</version>
+ <!-- We need to exclude this artifact's dependency on Ant, -->
+ <!-- because it has a different groupId that the version of Ant -->
+ <!-- we want to use now. -->
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Modified: maven/components/branches/maven-2.0.x/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/pom.xml?rev=679206&r1=679205&r2=679206&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/pom.xml (original)
+++ maven/components/branches/maven-2.0.x/pom.xml Wed Jul 23 14:52:34 2008
@@ -225,6 +225,7 @@
<excludes>
<!-- TODO: These represent method ADDITIONS from 2.0.9, and should be removed after
2.0.10 is released. -->
+ <exclude>org/apache/maven/lifecycle/LifecycleExecutor*</exclude>
<exclude>org/apache/maven/artifact/metadata/ArtifactMetadataSource*</exclude>
<exclude>org/apache/maven/project/MavenProjectBuilder*</exclude>
<exclude>org/apache/maven/project/ProjectBuilderConfiguration*</exclude>
@@ -386,7 +387,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -396,7 +397,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>1.5.1</version>
+ <version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>