You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sc...@apache.org on 2017/02/01 20:21:19 UTC
[01/15] maven git commit: [MNG-6110] Upgrade Aether to Maven Resolver
1.0.3 [Forced Update!]
Repository: maven
Updated Branches:
refs/heads/DEPMGMT-IMPORT 2f19236a4 -> 84dc44881 (forced update)
[MNG-6110] Upgrade Aether to Maven Resolver 1.0.3
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/4d6c9292
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/4d6c9292
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/4d6c9292
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 4d6c9292c433626fa0b9a1cf711d4d0c366e7f33
Parents: a3cdfbb
Author: Harald Wellmann <ha...@gmx.de>
Authored: Sun Nov 6 12:13:32 2016 +0100
Committer: Herv� Boutemy <hb...@apache.org>
Committed: Wed Feb 1 07:59:52 2017 +0100
----------------------------------------------------------------------
apache-maven/pom.xml | 8 ++++----
maven-aether-provider/pom.xml | 26 ++++++++++++-------------
maven-compat/pom.xml | 24 +++++++++++++++++++----
maven-core/pom.xml | 16 ++++++++++------
maven-embedder/pom.xml | 8 ++++++++
pom.xml | 39 +++++++++++++++++++-------------------
6 files changed, 75 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/apache-maven/pom.xml
----------------------------------------------------------------------
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index e7d5608..6fc5a73 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -90,12 +90,12 @@ under the License.
<artifactId>wagon-file</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-connector-basic</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-wagon</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-wagon</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/maven-aether-provider/pom.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/pom.xml b/maven-aether-provider/pom.xml
index 0f3cb61..91d1ae7 100644
--- a/maven-aether-provider/pom.xml
+++ b/maven-aether-provider/pom.xml
@@ -31,7 +31,7 @@ under the License.
<artifactId>maven-aether-provider</artifactId>
<name>Maven Aether Provider</name>
- <description>Extensions to Aether for utilizing Maven POM and repository metadata.</description>
+ <description>Extensions to Maven Resolver for utilizing Maven POM and repository metadata.</description>
<dependencies>
<dependency>
@@ -47,20 +47,20 @@ under the License.
<artifactId>maven-repository-metadata</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-spi</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-spi</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -88,13 +88,13 @@ under the License.
</dependency>
<!-- Testing -->
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-connector-basic</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-wagon</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-wagon</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/maven-compat/pom.xml
----------------------------------------------------------------------
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index 3a0a45c..876c11c 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -59,6 +59,22 @@ under the License.
<artifactId>maven-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-aether-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
@@ -85,13 +101,13 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-connector-basic</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-wagon</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-wagon</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/maven-core/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index d147dd8..ad5484a 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -73,16 +73,20 @@ under the License.
<artifactId>maven-aether-provider</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 75b92c9..30ad2ce 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -51,6 +51,14 @@ under the License.
<artifactId>maven-model-builder</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<scope>runtime</scope>
http://git-wip-us.apache.org/repos/asf/maven/blob/4d6c9292/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b61e0af..0e3b9a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@ under the License.
<cipherVersion>1.7</cipherVersion>
<modelloVersion>1.8.3</modelloVersion>
<jxpathVersion>1.3</jxpathVersion>
- <aetherVersion>1.0.2.v20150114</aetherVersion>
+ <resolverVersion>1.0.3</resolverVersion>
<slf4jVersion>1.7.5</slf4jVersion>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
<!-- Control the name of the distribution and information output by mvn -->
@@ -328,34 +328,34 @@ under the License.
</dependency>
<!-- Repository -->
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-spi</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-spi</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-connector-basic</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-wagon</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-wagon</artifactId>
+ <version>${resolverVersion}</version>
</dependency>
<!-- Commons -->
<dependency>
@@ -639,6 +639,7 @@ under the License.
<notimestamp>true</notimestamp>
<quiet>true</quiet>
<links combine.children="append">
+ <!-- TODO link to Maven Resolver Javadoc -->
<link>http://download.eclipse.org/aether/aether-core/${aetherVersion}/apidocs/</link>
<link>https://codehaus-plexus.github.io/plexus-containers/plexus-container-default/apidocs/</link>
</links>
[11/15] maven git commit: [MNG-2199] Support version ranges in parent
elements
Posted by sc...@apache.org.
[MNG-2199] Support version ranges in parent elements
o Updated to fix parent version range resolution broken since 3.2.3 and to
remove parent version range resolution logic obsolete since Maven
3.2.3 which changed the initialization of MavenProject instances.
o Updated local parent resolution to behave the same way remote parent
resolution behaves. When referencing a parent using version ranges,
inheriting the version or using version expressions should not be supported.
It has been implemented that way for remote parent resolution as it got
introduced in Maven 3.2.2. For local parent resolution the version in parent
declarations had been ignored completely as of Maven 3.3.0 due to commit
be3fb200326208ca4b8c41ebf16d5ae6b8049792 removing all local parent version
validation. Work on fixing this is tracked by MNG-5840 released with Maven
3.3.9. This commit adds the final missing bits to make local and remote parent
resolution behave the same way as much as possible. As an exception, remote
parent resolution still is a bit more strict than local parent resolution due
to a different API in use. When resolving a parent from a repository using
version ranges, the ModelBuilder verifies the range in use to declare an upper
bound. When resolving a parent locally using version ranges, those ranges are
not required to declare an upper bound because the API in use does not support
querying that. Authoring a POM relying on this difference should be considered
a bug.
o Added test cases to maven-core testing parent version range resolution for
local and remote parent models.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/9353ad7e
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/9353ad7e
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/9353ad7e
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 9353ad7e21f154cb7d987ee2cf6d4073c600928e
Parents: bd57ec9
Author: Christian Schulte <sc...@apache.org>
Authored: Sat Dec 12 20:28:56 2015 +0100
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:18:10 2017 +0100
----------------------------------------------------------------------
.../maven/project/DefaultProjectBuilder.java | 111 +++++++++-------
.../project/DefaultProjectBuildingRequest.java | 15 ++-
.../maven/project/ProjectBuildingRequest.java | 14 +-
.../project/AbstractMavenProjectTestCase.java | 11 ++
.../project/DefaultMavenProjectBuilderTest.java | 130 +++++++++++++++++++
.../repository/TestRepositoryConnector.java | 38 ++++++
.../org/apache/apache/1/apache-1.pom | 82 ++++++++++++
.../org/apache/apache/maven-metadata.xml | 13 ++
.../pom.xml | 12 ++
.../pom.xml | 11 ++
.../parent-version-range-external-valid/pom.xml | 11 ++
.../child/pom.xml | 12 ++
.../pom.xml | 7 +
.../child/pom.xml | 11 ++
.../pom.xml | 7 +
.../child/pom.xml | 11 ++
.../parent-version-range-local-valid/pom.xml | 7 +
.../model/building/DefaultModelBuilder.java | 25 +++-
18 files changed, 473 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index d064ab4..4241ac2 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -43,7 +43,6 @@ import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Extension;
import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Profile;
import org.apache.maven.model.ReportPlugin;
@@ -73,9 +72,6 @@ import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.WorkspaceRepository;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResolutionException;
-import org.eclipse.aether.resolution.VersionRangeResult;
/**
*/
@@ -298,44 +294,6 @@ public class DefaultProjectBuilder
boolean localProject;
- if ( request.isResolveVersionRanges() )
- {
- VersionRangeRequest versionRangeRequest = new VersionRangeRequest( pomArtifact, config.repositories, null );
-
- try
- {
- VersionRangeResult versionRangeResult =
- repoSystem.resolveVersionRange( config.session, versionRangeRequest );
-
- if ( versionRangeResult.getHighestVersion() == null )
- {
- throw new ProjectBuildingException(
- artifact.getId(), "Error resolving project artifact: No versions matched the requested range",
- (Throwable) null );
-
- }
-
- if ( versionRangeResult.getVersionConstraint() != null
- && versionRangeResult.getVersionConstraint().getRange() != null
- && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
- {
- throw new ProjectBuildingException(
- artifact.getId(),
- "Error resolving project artifact: The requested version range does not specify an upper bound",
- (Throwable) null );
-
- }
-
- pomArtifact = pomArtifact.setVersion( versionRangeResult.getHighestVersion().toString() );
- }
- catch ( VersionRangeResolutionException e )
- {
- throw new ProjectBuildingException(
- artifact.getId(), "Error resolving project artifact: " + e.getMessage(), e );
-
- }
- }
-
try
{
ArtifactRequest pomRequest = new ArtifactRequest();
@@ -656,11 +614,20 @@ public class DefaultProjectBuilder
project.setModel( model );
project.setOriginalModel( result.getRawModel() );
project.setFile( model.getPomFile() );
- Parent p = model.getParent();
- if ( p != null )
+
+ Model parentModel = result.getModelIds().size() > 1 && !result.getModelIds().get( 1 ).isEmpty()
+ ? result.getRawModel( result.getModelIds().get( 1 ) )
+ : null;
+
+ if ( parentModel != null )
{
- project.setParentArtifact( repositorySystem.createProjectArtifact( p.getGroupId(), p.getArtifactId(),
- p.getVersion() ) );
+ final String parentGroupId = inheritedGroupId( result, 1 );
+ final String parentVersion = inheritedVersion( result, 1 );
+
+ project.setParentArtifact( repositorySystem.createProjectArtifact( parentGroupId,
+ parentModel.getArtifactId(),
+ parentVersion ) );
+
// org.apache.maven.its.mng4834:parent:0.1
String parentModelId = result.getModelIds().get( 1 );
File parentPomFile = result.getRawModel( parentModelId ).getPomFile();
@@ -683,7 +650,14 @@ public class DefaultProjectBuilder
catch ( ProjectBuildingException e )
{
// MNG-4488 where let invalid parents slide on by
- logger.warn( "Failed to build parent project for " + project.getId() );
+ if ( logger.isDebugEnabled() )
+ {
+ logger.warn( "Failed to build parent project for " + project.getId(), e );
+ }
+ else
+ {
+ logger.warn( "Failed to build parent project for " + project.getId() );
+ }
}
}
else
@@ -696,7 +670,14 @@ public class DefaultProjectBuilder
catch ( ProjectBuildingException e )
{
// MNG-4488 where let invalid parents slide on by
- logger.warn( "Failed to build parent project for " + project.getId() );
+ if ( logger.isDebugEnabled() )
+ {
+ logger.warn( "Failed to build parent project for " + project.getId(), e );
+ }
+ else
+ {
+ logger.warn( "Failed to build parent project for " + project.getId() );
+ }
}
}
}
@@ -878,6 +859,40 @@ public class DefaultProjectBuilder
}
}
+ private static String inheritedGroupId( final ModelBuildingResult result, final int modelIndex )
+ {
+ String groupId = null;
+ final String modelId = result.getModelIds().get( modelIndex );
+
+ if ( !modelId.isEmpty() )
+ {
+ final Model model = result.getRawModel( modelId );
+ groupId = model.getGroupId() != null
+ ? model.getGroupId()
+ : inheritedGroupId( result, modelIndex + 1 );
+
+ }
+
+ return groupId;
+ }
+
+ private static String inheritedVersion( final ModelBuildingResult result, final int modelIndex )
+ {
+ String version = null;
+ final String modelId = result.getModelIds().get( modelIndex );
+
+ if ( !modelId.isEmpty() )
+ {
+ final Model model = result.getRawModel( modelId );
+ version = model.getVersion() != null
+ ? model.getVersion()
+ : inheritedVersion( result, modelIndex + 1 );
+
+ }
+
+ return version;
+ }
+
private String findProfilesXml( ModelBuildingResult result, Map<File, Boolean> profilesXmls )
{
for ( String modelId : result.getModelIds() )
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
index f1b271b..dafbefd 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
@@ -63,6 +63,7 @@ public class DefaultProjectBuildingRequest
private boolean resolveDependencies;
+ @Deprecated
private boolean resolveVersionRanges;
private RepositoryMerging repositoryMerging = RepositoryMerging.POM_DOMINANT;
@@ -218,14 +219,24 @@ public class DefaultProjectBuildingRequest
return resolveDependencies;
}
- /** @since 3.2.2 */
+ /**
+ * @since 3.2.2
+ * @deprecated This got added when implementing MNG-2199 and is no longer used.
+ * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized.
+ */
+ @Deprecated
public ProjectBuildingRequest setResolveVersionRanges( boolean value )
{
this.resolveVersionRanges = value;
return this;
}
- /** @since 3.2.2 */
+ /**
+ * @since 3.2.2
+ * @deprecated This got added when implementing MNG-2199 and is no longer used.
+ * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized.
+ */
+ @Deprecated
public boolean isResolveVersionRanges()
{
return this.resolveVersionRanges;
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
index 0380278..17a53b1 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
@@ -168,10 +168,20 @@ public interface ProjectBuildingRequest
*/
RepositoryMerging getRepositoryMerging();
- /** @since 3.2.2 */
+ /**
+ * @since 3.2.2
+ * @deprecated This got added when implementing MNG-2199 and is no longer used.
+ * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized.
+ */
+ @Deprecated
boolean isResolveVersionRanges();
- /** @since 3.2.2 */
+ /**
+ * @since 3.2.2
+ * @deprecated This got added when implementing MNG-2199 and is no longer used.
+ * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized.
+ */
+ @Deprecated
ProjectBuildingRequest setResolveVersionRanges( boolean value );
/**
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index 73bdbca..71616fa 100644
--- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -169,6 +169,17 @@ public abstract class AbstractMavenProjectTestCase
return projectBuilder.build( pom, configuration ).getProject();
}
+ protected MavenProject getProjectFromRemoteRepository( final File pom )
+ throws Exception
+ {
+ final ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
+ configuration.setLocalRepository( this.getLocalRepository() );
+ configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createDefaultRemoteRepository() ) );
+ initRepoSession( configuration );
+
+ return projectBuilder.build( pom, configuration ).getProject();
+ }
+
protected ProjectBuildingRequest newBuildingRequest()
throws Exception
{
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
index d61fc6e..3959cdd 100644
--- a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
@@ -189,4 +189,134 @@ public class DefaultMavenProjectBuilderTest
request.setResolveDependencies( true );
projectBuilder.build( pomFile, request );
}
+
+ /**
+ * Tests whether local version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildValidParentVersionRangeLocally() throws Exception
+ {
+ File f1 = getTestFile( "src/test/resources/projects/parent-version-range-local-valid/child/pom.xml" );
+
+ final MavenProject childProject = getProject( f1 );
+
+ assertNotNull( childProject.getParentArtifact() );
+ assertEquals( childProject.getParentArtifact().getVersion(), "1" );
+ assertNotNull( childProject.getParent() );
+ assertEquals( childProject.getParent().getVersion(), "1" );
+ assertNotNull( childProject.getModel().getParent() );
+ assertEquals( childProject.getModel().getParent().getVersion(), "[1,10]" );
+ }
+
+ /**
+ * Tests whether local version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildParentVersionRangeLocallyWithoutChildVersion() throws Exception
+ {
+ File f1 =
+ getTestFile( "src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml" );
+
+ try
+ {
+ getProject( f1 );
+ fail( "Expected 'ProjectBuildingException' not thrown." );
+ }
+ catch ( final ProjectBuildingException e )
+ {
+ assertNotNull( e.getMessage() );
+ assertTrue( e.getMessage().contains( "Version must be a constant" ) );
+ }
+ }
+
+ /**
+ * Tests whether local version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildParentVersionRangeLocallyWithChildVersionExpression() throws Exception
+ {
+ File f1 =
+ getTestFile(
+ "src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml" );
+
+ try
+ {
+ getProject( f1 );
+ fail( "Expected 'ProjectBuildingException' not thrown." );
+ }
+ catch ( final ProjectBuildingException e )
+ {
+ assertNotNull( e.getMessage() );
+ assertTrue( e.getMessage().contains( "Version must be a constant" ) );
+ }
+ }
+
+ /**
+ * Tests whether external version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildParentVersionRangeExternally() throws Exception
+ {
+ File f1 = getTestFile( "src/test/resources/projects/parent-version-range-external-valid/pom.xml" );
+
+ final MavenProject childProject = this.getProjectFromRemoteRepository( f1 );
+
+ assertNotNull( childProject.getParentArtifact() );
+ assertEquals( childProject.getParentArtifact().getVersion(), "1" );
+ assertNotNull( childProject.getParent() );
+ assertEquals( childProject.getParent().getVersion(), "1" );
+ assertNotNull( childProject.getModel().getParent() );
+ assertEquals( childProject.getModel().getParent().getVersion(), "[1,1]" );
+ }
+
+ /**
+ * Tests whether external version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildParentVersionRangeExternallyWithoutChildVersion() throws Exception
+ {
+ File f1 =
+ getTestFile(
+ "src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml" );
+
+ try
+ {
+ this.getProjectFromRemoteRepository( f1 );
+ fail( "Expected 'ProjectBuildingException' not thrown." );
+ }
+ catch ( final ProjectBuildingException e )
+ {
+ assertNotNull( e.getMessage() );
+ assertTrue( e.getMessage().contains( "Version must be a constant" ) );
+ }
+ }
+
+ /**
+ * Tests whether external version range parent references are build correctly.
+ *
+ * @throws Exception
+ */
+ public void testBuildParentVersionRangeExternallyWithChildVersionExpression() throws Exception
+ {
+ File f1 =
+ getTestFile(
+ "src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml" );
+
+ try
+ {
+ this.getProjectFromRemoteRepository( f1 );
+ fail( "Expected 'ProjectBuildingException' not thrown." );
+ }
+ catch ( final ProjectBuildingException e )
+ {
+ assertNotNull( e.getMessage() );
+ assertTrue( e.getMessage().contains( "Version must be a constant" ) );
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
index 91ace4f..cb1243c 100644
--- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
+++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
@@ -27,6 +27,7 @@ import java.util.Collection;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.spi.connector.ArtifactDownload;
import org.eclipse.aether.spi.connector.ArtifactUpload;
@@ -35,6 +36,8 @@ import org.eclipse.aether.spi.connector.MetadataUpload;
import org.eclipse.aether.spi.connector.RepositoryConnector;
import org.eclipse.aether.transfer.ArtifactNotFoundException;
import org.eclipse.aether.transfer.ArtifactTransferException;
+import org.eclipse.aether.transfer.MetadataNotFoundException;
+import org.eclipse.aether.transfer.MetadataTransferException;
/**
* @author Benjamin Bentmann
@@ -89,6 +92,28 @@ public class TestRepositoryConnector
}
}
}
+ if ( metadataDownloads != null )
+ {
+ for ( final MetadataDownload download : metadataDownloads )
+ {
+ File remoteFile = new File( basedir, path( download.getMetadata() ) );
+ try
+ {
+ FileUtils.copyFile( remoteFile, download.getFile() );
+ }
+ catch ( IOException e )
+ {
+ if ( !remoteFile.exists() )
+ {
+ download.setException( new MetadataNotFoundException( download.getMetadata(), repository ) );
+ }
+ else
+ {
+ download.setException( new MetadataTransferException( download.getMetadata(), repository, e ) );
+ }
+ }
+ }
+ }
}
private String path( Artifact artifact )
@@ -113,6 +138,19 @@ public class TestRepositoryConnector
return path.toString();
}
+ private String path( Metadata metadata )
+ {
+ StringBuilder path = new StringBuilder( 128 );
+
+ path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' );
+
+ path.append( metadata.getArtifactId() ).append( '/' );
+
+ path.append( "maven-metadata.xml" );
+
+ return path.toString();
+ }
+
public void put( Collection<? extends ArtifactUpload> artifactUploads,
Collection<? extends MetadataUpload> metadataUploads )
{
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/remote-repo/org/apache/apache/1/apache-1.pom
----------------------------------------------------------------------
diff --git a/maven-core/src/test/remote-repo/org/apache/apache/1/apache-1.pom b/maven-core/src/test/remote-repo/org/apache/apache/1/apache-1.pom
new file mode 100644
index 0000000..ad6b854
--- /dev/null
+++ b/maven-core/src/test/remote-repo/org/apache/apache/1/apache-1.pom
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<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>
+
+ <!-- Shared parent. Doesn't define a lot of things about Apache like general mailing lists, but does
+ define the settings common to all projects at Apache -->
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+ <name>The Apache Software Foundation</name>
+ <description>
+ The Apache Software Foundation provides support for the Apache community of open-source software projects.
+ The Apache projects are characterized by a collaborative, consensus based development process, an open and
+ pragmatic software license, and a desire to create high quality software that leads the way in its field.
+ We consider ourselves not simply a group of projects sharing a server, but rather a community of developers
+ and users.
+ </description>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ </organization>
+ <url>http://www.apache.org/</url>
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://svn.apache.org/maven-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <distributionManagement>
+ <!-- Site omitted - each project must provide their own -->
+ <repository>
+ <id>apache.releases</id>
+ <name>Apache Release Distribution Repository</name>
+ <url>scp://minotaur.apache.org/www/www.apache.org/dist/maven-repository</url>
+ </repository>
+ <snapshotRepository>
+ <id>apache.snapshots</id>
+ <name>Apache Development Snapshot Repository</name>
+ <url>scp://minotaur.apache.org/www/cvs.apache.org/maven-snapshot-repository</url>
+ </snapshotRepository>
+ </distributionManagement>
+ <mailingLists>
+ <mailingList>
+ <name>Apache Announce List</name>
+ <subscribe>announce-subscribe@apache.org</subscribe>
+ <unsubscribe>announce-unsubscribe@apache.org</unsubscribe>
+ <post>announce@apache.org</post>
+ <archive>http://mail-archives.apache.org/mod_mbox/www-announce/</archive>
+ </mailingList>
+ </mailingLists>
+</project>
+
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/remote-repo/org/apache/apache/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/remote-repo/org/apache/apache/maven-metadata.xml b/maven-core/src/test/remote-repo/org/apache/apache/maven-metadata.xml
new file mode 100644
index 0000000..596f967
--- /dev/null
+++ b/maven-core/src/test/remote-repo/org/apache/apache/maven-metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <versioning>
+ <latest>1</latest>
+ <release>1</release>
+ <versions>
+ <version>1</version>
+ </versions>
+ <lastUpdated>20150428055824</lastUpdated>
+ </versioning>
+</metadata>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml
new file mode 100644
index 0000000..d07ad6e
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml
@@ -0,0 +1,12 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>[1,1]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <!-- Must not use expressions from parent due to version range. -->
+ <version>${some.property}</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml
new file mode 100644
index 0000000..4f5a004
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml
@@ -0,0 +1,11 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>[1,1]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <!-- version>2</version Must not inherit version from parent due to version range. -->
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-external-valid/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-valid/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-valid/pom.xml
new file mode 100644
index 0000000..54eea90
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-external-valid/pom.xml
@@ -0,0 +1,11 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>[1,1]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <version>2</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml
new file mode 100644
index 0000000..066a11e
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml
@@ -0,0 +1,12 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>[1,10]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <!-- Must not use expressions from parent due to version range. -->
+ <version>${some.property}</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml
new file mode 100644
index 0000000..a82bbf2
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml
@@ -0,0 +1,7 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml
new file mode 100644
index 0000000..645a8f1
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml
@@ -0,0 +1,11 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>[1,10]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <!-- version>1</version Must not inherit version from parent due to version range. -->
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/pom.xml
new file mode 100644
index 0000000..a82bbf2
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/pom.xml
@@ -0,0 +1,7 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-valid/child/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-valid/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-valid/child/pom.xml
new file mode 100644
index 0000000..886bcdf
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-valid/child/pom.xml
@@ -0,0 +1,11 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>[1,10]</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-core/src/test/resources/projects/parent-version-range-local-valid/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-valid/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-valid/pom.xml
new file mode 100644
index 0000000..a82bbf2
--- /dev/null
+++ b/maven-core/src/test/resources/projects/parent-version-range-local-valid/pom.xml
@@ -0,0 +1,7 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>parent-version-range-local</groupId>
+ <artifactId>parent</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9353ad7e/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index a6a8725..49a1f3c 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -333,7 +333,7 @@ public class DefaultModelBuilder
currentData = superData;
}
else if ( currentData == resultData )
- { // First iteration - add initial parent id after version resolution.
+ { // First iteration - add initial id after version resolution.
currentData.setGroupId( currentData.getRawModel().getGroupId() == null ? parentData.getGroupId()
: currentData.getRawModel()
.getGroupId() );
@@ -938,6 +938,26 @@ public class DefaultModelBuilder
// version skew drop back to resolution from the repository
return null;
}
+
+ // Validate versions aren't inherited when using parent ranges the same way as when read externally.
+ if ( childModel.getVersion() == null )
+ {
+ problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 )
+ .setMessage( "Version must be a constant" ).setLocation( childModel.getLocation( "" ) ) );
+
+ }
+ else
+ {
+ if ( childModel.getVersion().contains( "${" ) )
+ {
+ problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 )
+ .setMessage( "Version must be a constant" )
+ .setLocation( childModel.getLocation( "version" ) ) );
+
+ }
+ }
+
+ // MNG-2199: What else to check here ?
}
catch ( InvalidVersionSpecificationException e )
{
@@ -1054,8 +1074,7 @@ public class DefaultModelBuilder
}
else
{
- if ( childModel.getVersion()
- .contains( "${" ) )
+ if ( childModel.getVersion().contains( "${" ) )
{
problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 )
.setMessage( "Version must be a constant" )
[02/15] maven git commit: [MNG-6140] renamed aether to resolver,
added slf4j-provider
Posted by sc...@apache.org.
[MNG-6140] renamed aether to resolver, added slf4j-provider
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/1cb2e92b
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/1cb2e92b
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/1cb2e92b
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 1cb2e92b5ad6bc2baa80c48b6357d5f42df4e48f
Parents: 8972072
Author: Herv� Boutemy <hb...@apache.org>
Authored: Mon Dec 26 19:21:29 2016 +0100
Committer: Herv� Boutemy <hb...@apache.org>
Committed: Wed Feb 1 07:59:53 2017 +0100
----------------------------------------------------------------------
src/site/resources/images/maven-deps.png | Bin 73105 -> 69305 bytes
src/site/xdoc/index.xml | 54 ++++++++++++++------------
src/site/xdoc/maven-deps.odg | Bin 32324 -> 18602 bytes
3 files changed, 29 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/1cb2e92b/src/site/resources/images/maven-deps.png
----------------------------------------------------------------------
diff --git a/src/site/resources/images/maven-deps.png b/src/site/resources/images/maven-deps.png
index d23033f..a7084e8 100644
Binary files a/src/site/resources/images/maven-deps.png and b/src/site/resources/images/maven-deps.png differ
http://git-wip-us.apache.org/repos/asf/maven/blob/1cb2e92b/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 4cd2f66..78c47fb 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -1,22 +1,22 @@
<?xml version="1.0"?>
<!--
-/*
- * 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.
- */
+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.
-->
<document>
@@ -40,24 +40,28 @@
process.</p>
<p>
- <img src="images/maven-deps.png" width="784" height="595" border="0" usemap="#Maven_dependencies" />
+ <img src="images/maven-deps.png" width="784" height="578" border="0" usemap="#Maven_dependencies" />
<map name="Maven_dependencies">
<area shape="rect" coords="228,1,361,36" alt="apache-maven" href="apache-maven/" />
<area shape="rect" coords="228,58,361,95" alt="maven-embedder" href="maven-embedder/" />
<area shape="rect" coords="228,116,361,152" alt="maven-compat" href="maven-compat/" />
<area shape="rect" coords="228,175,361,211" alt="maven-core" href="maven-core/" />
- <area shape="rect" coords="118,233,275,269" alt="maven-aether-provider" href="maven-aether-provider/" />
+ <area shape="rect" coords="118,233,275,269" alt="maven-resolver-provider" href="maven-resolver-provider/" />
<area shape="rect" coords="0,287,192,323" alt="maven-repository-metadata" href="maven-repository-metadata/" />
<area shape="rect" coords="245,342,343,378" alt="maven-plugin-api" href="maven-plugin-api/" />
<area shape="rect" coords="253,401,336,436" alt="maven-artifact" href="maven-artifact/" />
- <area shape="rect" coords="296,234,442,270" alt="maven-builder-support" href="maven-builder-support/" />
+ <area shape="rect" coords="299,230,446,265" alt="maven-builder-support" href="maven-builder-support/" />
<area shape="rect" coords="382,176,528,211" alt="maven-settings-builder" href="maven-settings-builder/" />
- <area shape="rect" coords="446,234,537,269" alt="maven-settings" href="maven-settings/" />
+ <area shape="rect" coords="449,229,532,266" alt="maven-settings" href="maven-settings/" />
<area shape="rect" coords="388,284,521,319" alt="maven-model-builder" href="maven-model-builder/" />
<area shape="rect" coords="409,342,500,378" alt="maven-model" href="maven-model/" />
- <area shape="rect" coords="TODO" alt="maven-slf4j-provider" href="maven-slf4j-provider/" />
- <area shape="rect" coords="88,59,192,94" alt="slf4j-api" href="http://www.slf4j.org/manual.html" />
+ <area shape="rect" coords="42,0,198,35" alt="maven-slf4j-provider" href="maven-slf4j-provider/" />
+ <area shape="rect" coords="68,338,240,482" alt="maven-resolver" href="https://maven.apache.org/resolver/" />
+ <area shape="rect" coords="70,57,171,93" alt="slf4j-api" href="http://www.slf4j.org/manual.html" />
<area shape="rect" coords="551,58,707,94" alt="commons-cli" href="http://commons.apache.org/cli/" />
+ <area shape="rect" coords="88,175,205,211" alt="maven-shared-utils" href="https://maven.apache.org/shared/maven-shared-utils/" />
+ <area shape="rect" coords="0,176,70,211" alt="jansi" href="http://fusesource.github.io/jansi/" />
+ <area shape="rect" coords="0,229,71,266" alt="jansi-native" href="https://github.com/fusesource/jansi-native" />
<area shape="rect" coords="551,116,739,152" alt="wagon-provider-api" href="https://maven.apache.org/wagon/wagon-provider-api/" />
<area shape="rect" coords="550,175,690,211" alt="plexus-sec-dispatcher" href="https://github.com/codehaus-plexus/plexus-sec-dispatcher" />
<area shape="rect" coords="581,230,660,265" alt="plexus-cipher" href="https://github.com/codehaus-plexus/plexus-cipher" />
@@ -66,9 +70,9 @@
<area shape="rect" coords="550,401,682,437" alt="plexus-classworlds" href="https://codehaus-plexus.github.io/plexus-classworlds" />
<area shape="rect" coords="685,455,775,491" alt="plexus-utils" href="https://codehaus-plexus.github.io/plexus-utils" />
<area shape="rect" coords="542,167,783,502" alt="plexus" href="https://codehaus-plexus.github.io/" />
- <area shape="rect" coords="68,338,240,482" alt="aether" href="http://www.eclipse.org/projects/project_summary.php?projectid=technology.aether" />
- <area shape="rect" coords="388,393,520,594" alt="sisu" href="http://www.eclipse.org/projects/project_summary.php?projectid=technology.sisu" />
- <area shape="rect" coords="519,518,621,554" alt="guice" href="http://code.google.com/p/google-guice/" />
+ <area shape="rect" coords="401,393,509,524" alt="sisu" href="http://www.eclipse.org/projects/project_summary.php?projectid=technology.sisu" />
+ <area shape="rect" coords="416,543,493,577" alt="guice" href="http://code.google.com/p/google-guice/" />
+ <area shape="rect" coords="550,543,673,577" alt="javax.inject" href="http://docs.oracle.com/javaee/6/api/javax/inject/package-summary.html" />
</map>
</p>
</section>
http://git-wip-us.apache.org/repos/asf/maven/blob/1cb2e92b/src/site/xdoc/maven-deps.odg
----------------------------------------------------------------------
diff --git a/src/site/xdoc/maven-deps.odg b/src/site/xdoc/maven-deps.odg
index 9d4193a..f95b83f 100644
Binary files a/src/site/xdoc/maven-deps.odg and b/src/site/xdoc/maven-deps.odg differ
[06/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
deleted file mode 100644
index b81450c..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.MalformedURLException;
-
-import org.apache.maven.repository.internal.util.ConsoleRepositoryListener;
-import org.apache.maven.repository.internal.util.ConsoleTransferListener;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-
-public abstract class AbstractRepositoryTestCase
- extends PlexusTestCase
-{
- protected RepositorySystem system;
-
- protected RepositorySystemSession session;
-
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- system = lookup( RepositorySystem.class );
- session = newMavenRepositorySystemSession( system );
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- session = null;
- system = null;
- super.tearDown();
- }
-
- public static RepositorySystemSession newMavenRepositorySystemSession( RepositorySystem system )
- {
- DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
-
- LocalRepository localRepo = new LocalRepository( "target/local-repo" );
- session.setLocalRepositoryManager( system.newLocalRepositoryManager( session, localRepo ) );
-
- session.setTransferListener( new ConsoleTransferListener() );
- session.setRepositoryListener( new ConsoleRepositoryListener() );
-
- return session;
- }
-
- public static RemoteRepository newTestRepository()
- throws MalformedURLException
- {
- return new RemoteRepository.Builder( "repo", "default",
- getTestFile( "target/test-classes/repo" ).toURI().toURL().toString() ).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
deleted file mode 100644
index e873138..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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 static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import org.eclipse.aether.RepositoryEvent;
-import org.eclipse.aether.RepositoryEvent.EventType;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.RepositoryEventDispatcher;
-import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
-import org.mockito.ArgumentCaptor;
-
-public class DefaultArtifactDescriptorReaderTest
- extends AbstractRepositoryTestCase
-{
-
- public void testMng5459()
- throws Exception
- {
- // prepare
- DefaultArtifactDescriptorReader reader = (DefaultArtifactDescriptorReader) lookup( ArtifactDescriptorReader.class );
-
- RepositoryEventDispatcher eventDispatcher = mock( RepositoryEventDispatcher.class );
-
- ArgumentCaptor<RepositoryEvent> event = ArgumentCaptor.forClass( RepositoryEvent.class );
-
- reader.setRepositoryEventDispatcher( eventDispatcher );
-
- ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
-
- request.addRepository( newTestRepository() );
-
- request.setArtifact( new DefaultArtifact( "org.apache.maven.its", "dep-mng5459", "jar", "0.4.0-SNAPSHOT" ) );
-
- // execute
- reader.readArtifactDescriptor( session, request );
-
- // verify
- verify( eventDispatcher ).dispatch( event.capture() );
-
- boolean missingArtifactDescriptor = false;
-
- for( RepositoryEvent evt : event.getAllValues() )
- {
- if ( EventType.ARTIFACT_DESCRIPTOR_MISSING.equals( evt.getType() ) )
- {
- assertEquals( "Could not find artifact org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2 in repo (" + newTestRepository().getUrl() + ")", evt.getException().getMessage() );
- missingArtifactDescriptor = true;
- }
- }
-
- if( !missingArtifactDescriptor )
- {
- fail( "Expected missing artifact descriptor for org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
deleted file mode 100644
index 90dd6a4..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.resolution.VersionRequest;
-import org.eclipse.aether.resolution.VersionResult;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-public class DefaultVersionResolverTest
- extends AbstractRepositoryTestCase
-{
- private DefaultVersionResolver versionResolver;
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- // be sure we're testing the right class, i.e. DefaultVersionResolver.class
- versionResolver = (DefaultVersionResolver) lookup( VersionResolver.class, "default" );
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- versionResolver = null;
- super.tearDown();
- }
-
- public void testResolveSeparateInstalledClassifiedNonUniqueVersionedArtifacts()
- throws Exception
- {
- VersionRequest requestB = new VersionRequest();
- requestB.addRepository( newTestRepository() );
- Artifact artifactB =
- new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", "07.20.3-SNAPSHOT" );
- requestB.setArtifact( artifactB );
-
- VersionResult resultB = versionResolver.resolveVersion( session, requestB );
- assertEquals( "07.20.3-20120809.112920-97", resultB.getVersion() );
-
- VersionRequest requestA = new VersionRequest();
- requestA.addRepository( newTestRepository() );
-
- Artifact artifactA =
- new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", "07.20.3-SNAPSHOT" );
- requestA.setArtifact( artifactA );
-
- VersionResult resultA = versionResolver.resolveVersion( session, requestA );
- assertEquals( "07.20.3-20120809.112124-88", resultA.getVersion() );
- }
-
- public void testResolveSeparateInstalledClassifiedNonVersionedArtifacts()
- throws Exception
- {
- VersionRequest requestA = new VersionRequest();
- requestA.addRepository( newTestRepository() );
- String versionA = "07.20.3-20120809.112124-88";
- Artifact artifactA =
- new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", versionA );
- requestA.setArtifact( artifactA );
-
- VersionResult resultA = versionResolver.resolveVersion( session, requestA );
- assertEquals( versionA, resultA.getVersion() );
-
- VersionRequest requestB = new VersionRequest();
- requestB.addRepository( newTestRepository() );
- String versionB = "07.20.3-20120809.112920-97";
- Artifact artifactB =
- new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", versionB );
- requestB.setArtifact( artifactB );
-
- VersionResult resultB = versionResolver.resolveVersion( session, requestB );
- assertEquals( versionB, resultB.getVersion() );
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
deleted file mode 100644
index 768835a..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.spi.locator.ServiceLocator;
-
-import junit.framework.TestCase;
-
-public class MavenRepositorySystemUtilsTest
- extends TestCase
-{
-
- public void testGetRepositorySystem()
- {
- ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
- RepositorySystem repoSys = locator.getService( RepositorySystem.class );
- assertNotNull( repoSys );
- }
-
- public void testGetMetadataGeneratorFactories()
- {
- ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
- assertEquals( 2, locator.getServices( MetadataGeneratorFactory.class ).size() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
deleted file mode 100644
index 278231f..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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 static org.junit.Assert.assertTrue;
-
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RemoteSnapshotMetadataTest
-{
- private Locale defaultLocale;
-
- @Before
- public void setLocaleToUseBuddhistCalendar()
- {
- defaultLocale = Locale.getDefault();
- Locale.setDefault( new Locale( "th", "TH" ) );
- }
-
- @After
- public void restoreLocale()
- {
- Locale.setDefault( defaultLocale );
- }
-
- static String gregorianDate()
- {
- SimpleDateFormat df = new SimpleDateFormat( "yyyyMMdd" );
- df.setCalendar( new GregorianCalendar() );
- df.setTimeZone( RemoteSnapshotMetadata.DEFAULT_SNAPSHOT_TIME_ZONE );
- return df.format( new Date() );
- }
-
- @Test
- public void gregorianCalendarIsUsed()
- {
- String dateBefore = gregorianDate();
-
- RemoteSnapshotMetadata metadata = new RemoteSnapshotMetadata(
- new DefaultArtifact( "a:b:1-SNAPSHOT" ), false);
- metadata.merge( new Metadata() );
-
- String dateAfter = gregorianDate();
-
- String ts = metadata.metadata.getVersioning().getSnapshot().getTimestamp();
- String datePart = ts.replaceAll( "\\..*", "" );
-
- /* Allow for this test running across midnight */
- Set<String> expected = new HashSet<String>( Arrays.asList( dateBefore, dateAfter ) );
- assertTrue( "Expected " + datePart + " to be in " + expected,
- expected.contains( datePart ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
deleted file mode 100644
index db77a44..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.collection.CollectResult;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
-import org.eclipse.aether.resolution.ArtifactDescriptorResult;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-public class RepositorySystemTest
- extends AbstractRepositoryTestCase
-{
- public void testResolveVersionRange()
- throws Exception
- {
- //VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
- // throws VersionRangeResolutionException;
-
- }
-
- public void testResolveVersion()
- throws Exception
- {
- //VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
- // throws VersionResolutionException;
- }
-
- public void testReadArtifactDescriptor()
- throws Exception
- {
- Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
-
- ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
- request.setArtifact( artifact );
- request.addRepository( newTestRepository() );
-
- ArtifactDescriptorResult result = system.readArtifactDescriptor( session, request );
-
- List<Dependency> deps = result.getDependencies();
- assertEquals( 2, deps.size() );
- checkUtSimpleArtifactDependencies( deps.get( 0 ), deps.get( 1 ) );
- }
-
- /**
- * check ut.simple:artifact:1.0 dependencies
- */
- private void checkUtSimpleArtifactDependencies( Dependency dep1, Dependency dep2 )
- {
- assertEquals( "compile", dep1.getScope() );
- assertFalse( dep1.isOptional() );
- assertEquals( 0, dep1.getExclusions().size() );
- Artifact depArtifact = dep1.getArtifact();
- assertEquals( "ut.simple", depArtifact.getGroupId() );
- assertEquals( "dependency", depArtifact.getArtifactId() );
- assertEquals( "1.0", depArtifact.getVersion() );
- assertEquals( "1.0", depArtifact.getBaseVersion() );
- assertNull( depArtifact.getFile() );
- assertFalse( depArtifact.isSnapshot() );
- assertEquals( "", depArtifact.getClassifier() );
- assertEquals( "jar", depArtifact.getExtension() );
- assertEquals( "java", depArtifact.getProperty( "language", null ) );
- assertEquals( "jar", depArtifact.getProperty( "type", null ) );
- assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) );
- assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
- assertEquals( 4, depArtifact.getProperties().size() );
-
- assertEquals( "compile", dep2.getScope() );
- assertFalse( dep2.isOptional() );
- assertEquals( 0, dep2.getExclusions().size() );
- depArtifact = dep2.getArtifact();
- assertEquals( "ut.simple", depArtifact.getGroupId() );
- assertEquals( "dependency", depArtifact.getArtifactId() );
- assertEquals( "1.0", depArtifact.getVersion() );
- assertEquals( "1.0", depArtifact.getBaseVersion() );
- assertNull( depArtifact.getFile() );
- assertFalse( depArtifact.isSnapshot() );
- assertEquals( "sources", depArtifact.getClassifier() );
- assertEquals( "jar", depArtifact.getExtension() );
- assertEquals( "java", depArtifact.getProperty( "language", null ) );
- assertEquals( "jar", depArtifact.getProperty( "type", null ) ); // shouldn't it be java-sources given the classifier?
- assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); // shouldn't it be false given the classifier?
- assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
- assertEquals( 4, depArtifact.getProperties().size() );
- }
-
- public void testCollectDependencies()
- throws Exception
- {
- Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
- // notice: extension and classifier not really used in this test...
-
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot( new Dependency( artifact, null ) );
- collectRequest.addRepository( newTestRepository() );
-
- CollectResult collectResult = system.collectDependencies( session, collectRequest );
-
- List<DependencyNode> nodes = collectResult.getRoot().getChildren();
- assertEquals( 2, nodes.size() );
- checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
- }
-
- public void testResolveArtifact()
- throws Exception
- {
- Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" );
-
- ArtifactRequest artifactRequest = new ArtifactRequest();
- artifactRequest.setArtifact( artifact );
- artifactRequest.addRepository( newTestRepository() );
-
- ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
- checkArtifactResult( artifactResult, "artifact-1.0.jar" );
-
- artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" );
- artifactRequest.setArtifact( artifact );
- artifactResult = system.resolveArtifact( session, artifactRequest );
- checkArtifactResult( artifactResult, "artifact-1.0.zip" );
-
- artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" );
- artifactRequest.setArtifact( artifact );
- artifactResult = system.resolveArtifact( session, artifactRequest );
- checkArtifactResult( artifactResult, "artifact-1.0-classifier.zip" );
- }
-
- private void checkArtifactResult( ArtifactResult result, String filename )
- {
- assertFalse( result.isMissing() );
- assertTrue( result.isResolved() );
- Artifact artifact = result.getArtifact();
- assertNotNull( artifact.getFile() );
- assertEquals( filename, artifact.getFile().getName() );
- }
-
- public void testResolveArtifacts()
- throws Exception
- {
- ArtifactRequest req1 = new ArtifactRequest();
- req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) );
- req1.addRepository( newTestRepository() );
-
- ArtifactRequest req2 = new ArtifactRequest();
- req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) );
- req2.addRepository( newTestRepository() );
-
- ArtifactRequest req3 = new ArtifactRequest();
- req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) );
- req3.addRepository( newTestRepository() );
-
- List<ArtifactRequest> requests = Arrays.asList( req1, req2, req3 );
-
- List<ArtifactResult> results = system.resolveArtifacts( session, requests );
-
- assertEquals( 3, results.size() );
- checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" );
- checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" );
- checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" );
- }
-
- public void testResolveMetadata()
- throws Exception
- {
- //List<MetadataResult> resolveMetadata( RepositorySystemSession session,
- // Collection<? extends MetadataRequest> requests );
- }
-
- public void testInstall()
- throws Exception
- {
- //InstallResult install( RepositorySystemSession session, InstallRequest request )
- // throws InstallationException;
- // release, snapshot unique ou non unique, attachement
- }
-
- public void testDeploy()
- throws Exception
- {
- //DeployResult deploy( RepositorySystemSession session, DeployRequest request )
- // throws DeploymentException;
- }
-
- public void testNewLocalRepositoryManager()
- throws Exception
- {
- //LocalRepositoryManager newLocalRepositoryManager( LocalRepository localRepository );
- }
-
- public void testNewSyncContext()
- throws Exception
- {
- //SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
deleted file mode 100644
index 2879a9f..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.apache.maven.repository.internal.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.PrintStream;
-
-import org.eclipse.aether.AbstractRepositoryListener;
-import org.eclipse.aether.RepositoryEvent;
-
-public class ConsoleRepositoryListener
- extends AbstractRepositoryListener
-{
-
- private PrintStream out;
-
- public ConsoleRepositoryListener()
- {
- this( null );
- }
-
- public ConsoleRepositoryListener( PrintStream out )
- {
- this.out = ( out != null ) ? out : System.out;
- }
-
- public void artifactDeployed( RepositoryEvent event )
- {
- println( "artifactDeployed", event.getArtifact() + " to " + event.getRepository() );
- }
-
- public void artifactDeploying( RepositoryEvent event )
- {
- println( "artifactDeploying", event.getArtifact() + " to " + event.getRepository() );
- }
-
- public void artifactDescriptorInvalid( RepositoryEvent event )
- {
- println( "artifactDescriptorInvalid", "for " + event.getArtifact() + ": " + event.getException().getMessage() );
- }
-
- public void artifactDescriptorMissing( RepositoryEvent event )
- {
- println( "artifactDescriptorMissing", "for " + event.getArtifact() );
- }
-
- public void artifactInstalled( RepositoryEvent event )
- {
- println( "artifactInstalled", event.getArtifact() + " to " + event.getFile() );
- }
-
- public void artifactInstalling( RepositoryEvent event )
- {
- println( "artifactInstalling", event.getArtifact() + " to " + event.getFile() );
- }
-
- public void artifactResolved( RepositoryEvent event )
- {
- println( "artifactResolved", event.getArtifact() + " from " + event.getRepository() );
- }
-
- public void artifactDownloading( RepositoryEvent event )
- {
- println( "artifactDownloading", event.getArtifact() + " from " + event.getRepository() );
- }
-
- public void artifactDownloaded( RepositoryEvent event )
- {
- println( "artifactDownloaded", event.getArtifact() + " from " + event.getRepository() );
- }
-
- public void artifactResolving( RepositoryEvent event )
- {
- println( "artifactResolving", event.getArtifact().toString() );
- }
-
- public void metadataDeployed( RepositoryEvent event )
- {
- println( "metadataDeployed", event.getMetadata() + " to " + event.getRepository() );
- }
-
- public void metadataDeploying( RepositoryEvent event )
- {
- println( "metadataDeploying", event.getMetadata() + " to " + event.getRepository() );
- }
-
- public void metadataInstalled( RepositoryEvent event )
- {
- println( "metadataInstalled", event.getMetadata() + " to " + event.getFile() );
- }
-
- public void metadataInstalling( RepositoryEvent event )
- {
- println( "metadataInstalling", event.getMetadata() + " to " + event.getFile() );
- }
-
- public void metadataInvalid( RepositoryEvent event )
- {
- println( "metadataInvalid", event.getMetadata().toString() );
- }
-
- public void metadataResolved( RepositoryEvent event )
- {
- println( "metadataResolved", event.getMetadata() + " from " + event.getRepository() );
- }
-
- public void metadataResolving( RepositoryEvent event )
- {
- println( "metadataResolving", event.getMetadata() + " from " + event.getRepository() );
- }
-
- private void println( String event, String message )
- {
- out.println( "Aether Repository - " + event + ": " + message );
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
deleted file mode 100644
index cf587d8..0000000
--- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package org.apache.maven.repository.internal.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.PrintStream;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.eclipse.aether.transfer.AbstractTransferListener;
-import org.eclipse.aether.transfer.TransferEvent;
-import org.eclipse.aether.transfer.TransferResource;
-
-public class ConsoleTransferListener
- extends AbstractTransferListener
-{
-
- private PrintStream out;
-
- private Map<TransferResource, Long> downloads = new ConcurrentHashMap<>();
-
- private int lastLength;
-
- public ConsoleTransferListener()
- {
- this( null );
- }
-
- public ConsoleTransferListener( PrintStream out )
- {
- this.out = ( out != null ) ? out : System.out;
- }
-
- @Override
- public void transferInitiated( TransferEvent event )
- {
- String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
-
- println( "transferInitiated", message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
- }
-
- @Override
- public void transferProgressed( TransferEvent event )
- {
- TransferResource resource = event.getResource();
- downloads.put( resource, event.getTransferredBytes() );
-
- StringBuilder buffer = new StringBuilder( 64 );
-
- for ( Map.Entry<TransferResource, Long> entry : downloads.entrySet() )
- {
- long total = entry.getKey().getContentLength();
- long complete = entry.getValue();
-
- buffer.append( getStatus( complete, total ) ).append( " " );
- }
-
- int pad = lastLength - buffer.length();
- lastLength = buffer.length();
- pad( buffer, pad );
- buffer.append( '\r' );
-
- print( "transferProgressed", buffer.toString() );
- }
-
- private String getStatus( long complete, long total )
- {
- if ( total >= 1024 )
- {
- return toKB( complete ) + "/" + toKB( total ) + " KB ";
- }
- else if ( total >= 0 )
- {
- return complete + "/" + total + " B ";
- }
- else if ( complete >= 1024 )
- {
- return toKB( complete ) + " KB ";
- }
- else
- {
- return complete + " B ";
- }
- }
-
- private void pad( StringBuilder buffer, int spaces )
- {
- String block = " ";
- while ( spaces > 0 )
- {
- int n = Math.min( spaces, block.length() );
- buffer.append( block, 0, n );
- spaces -= n;
- }
- }
-
- @Override
- public void transferSucceeded( TransferEvent event )
- {
- transferCompleted( event );
-
- TransferResource resource = event.getResource();
- long contentLength = event.getTransferredBytes();
- if ( contentLength >= 0 )
- {
- String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" );
- String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
-
- String throughput = "";
- long duration = System.currentTimeMillis() - resource.getTransferStartTime();
- if ( duration > 0 )
- {
- DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) );
- double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 );
- throughput = " at " + format.format( kbPerSec ) + " KB/sec";
- }
-
- println( "transferSucceeded", type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " ("
- + len + throughput + ")" );
- }
- }
-
- @Override
- public void transferFailed( TransferEvent event )
- {
- transferCompleted( event );
-
- println( "transferFailed", event.getException().getClass() + ": " + event.getException().getMessage() );
- }
-
- private void transferCompleted( TransferEvent event )
- {
- downloads.remove( event.getResource() );
-
- StringBuilder buffer = new StringBuilder( 64 );
- pad( buffer, lastLength );
- buffer.append( '\r' );
- out.println( buffer );
- }
-
- @Override
- public void transferCorrupted( TransferEvent event )
- {
- println( "transferCorrupted", event.getException().getClass() + ": " + event.getException().getMessage() );
- }
-
- protected long toKB( long bytes )
- {
- return ( bytes + 1023 ) / 1024;
- }
-
- private void println( String event, String message )
- {
- print( event, message );
- out.println();
- }
-
- private void print( String event, String message )
- {
- out.print( "Aether Transfer - " + event );
- if ( message != null )
- {
- out.print( ": " );
- out.print( message );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
deleted file mode 100644
index 9f0a7fe..0000000
--- a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd"
- modelVersion="1.1.0">
- <groupId>org.apache.maven.its</groupId>
- <artifactId>dep-mng5324</artifactId>
- <version>07.20.3-SNAPSHOT</version><!-- metadata for artifact snapshot -->
- <versioning>
- <snapshot>
- <timestamp>20120809.112920</timestamp>
- <buildNumber>97</buildNumber>
- </snapshot>
- <lastUpdated>20120809112920</lastUpdated>
- <snapshotVersions>
- <snapshotVersion>
- <classifier>classifierA</classifier>
- <extension>jar</extension>
- <value>07.20.3-20120809.112124-88</value>
- <updated>20120809112124</updated>
- </snapshotVersion>
- <snapshotVersion>
- <classifier>classifierB</classifier>
- <extension>jar</extension>
- <value>07.20.3-20120809.112920-97</value>
- <updated>20120809112920</updated>
- </snapshotVersion>
- </snapshotVersions>
- </versioning>
-</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
deleted file mode 100644
index 923f26f..0000000
--- a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd"
- modelVersion="1.1.0">
- <groupId>org.apache.maven.its</groupId>
- <artifactId>dep-mng5459</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <versioning>
- <snapshot>
- <timestamp>20130404.090532</timestamp>
- <buildNumber>2</buildNumber>
- </snapshot>
- <lastUpdated>20130404093657</lastUpdated>
- <snapshotVersions>
- <snapshotVersion>
- <extension>pom</extension>
- <value>0.4.0-20130404.090532-2</value>
- <updated>20130404090532</updated>
- </snapshotVersion>
- <snapshotVersion>
- <extension>jar</extension>
- <value>0.4.0-20130404.093655-3</value>
- <updated>20130404093655</updated>
- </snapshotVersion>
- </snapshotVersions>
- </versioning>
-</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip b/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar b/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom b/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
deleted file mode 100644
index f8b72af..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>ut.simple</groupId>
- <artifactId>parent</artifactId>
- <version>1.0</version>
- </parent>
-
- <artifactId>artifact</artifactId>
-
- <name>Simple Unit Test Artifact</name>
-
- <dependencies>
- <dependency>
- <groupId>ut.simple</groupId>
- <artifactId>dependency</artifactId>
- </dependency>
- <dependency>
- <groupId>ut.simple</groupId>
- <artifactId>dependency</artifactId>
- <version>1.0</version>
- <classifier>sources</classifier>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip b/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
deleted file mode 100644
index 2de7ecc..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
- <groupId>ut.simple</groupId>
- <artifactId>artifact</artifactId>
- <versioning>
- <latest>1.0</latest>
- <release>1.0</release>
- <versions>
- <version>1.0</version>
- </versions>
- <lastUpdated>20111123122038</lastUpdated>
- </versioning>
-</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar b/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar b/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom b/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
deleted file mode 100644
index c021dfa..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>ut.simple</groupId>
- <artifactId>dependency</artifactId>
- <version>1.0</version>
-
- <name>Simple Unit Test Dependency</name>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
deleted file mode 100644
index 8a97c34..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
- <groupId>ut.simple</groupId>
- <artifactId>dependency</artifactId>
- <versioning>
- <latest>1.0</latest>
- <release>1.0</release>
- <versions>
- <version>1.0</version>
- </versions>
- <lastUpdated>20111123122038</lastUpdated>
- </versioning>
-</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom b/maven-aether-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
deleted file mode 100644
index ed64c9e..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>ut.simple</groupId>
- <artifactId>parent</artifactId>
- <version>1.0</version>
- <packaging>pom</packaging>
-
- <name>Simple Unit Test Parent</name>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>ut.simple</groupId>
- <artifactId>dependency</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
deleted file mode 100644
index 7199d52..0000000
--- a/maven-aether-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ 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.
--->
-
-<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
- <groupId>ut.simple</groupId>
- <artifactId>parent</artifactId>
- <versioning>
- <latest>1.0</latest>
- <release>1.0</release>
- <versions>
- <version>1.0</version>
- </versions>
- <lastUpdated>20111123122038</lastUpdated>
- </versioning>
-</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-compat/pom.xml
----------------------------------------------------------------------
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index 876c11c..c740504 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -60,7 +60,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
+ <artifactId>maven-resolver-provider</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-core/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index ad5484a..95162bd 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -70,7 +70,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
+ <artifactId>maven-resolver-provider</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-core/src/main/resources/META-INF/maven/extension.xml
----------------------------------------------------------------------
diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml
index f9cf07a..1d24d92 100644
--- a/maven-core/src/main/resources/META-INF/maven/extension.xml
+++ b/maven-core/src/main/resources/META-INF/maven/extension.xml
@@ -54,7 +54,7 @@ under the License.
<exportedPackage>org.apache.maven.wagon.repository</exportedPackage>
<exportedPackage>org.apache.maven.wagon.resource</exportedPackage>
- <!-- aether-api, aether-spi, aether-impl -->
+ <!-- maven-resolver-api, maven-resolver-spi, maven-resolver-impl -->
<exportedPackage>org.eclipse.aether.*</exportedPackage>
<exportedPackage>org.eclipse.aether.artifact</exportedPackage>
<exportedPackage>org.eclipse.aether.collection</exportedPackage>
@@ -132,7 +132,7 @@ under the License.
<exportedArtifact>org.sonatype.sisu:sisu-inject-plexus</exportedArtifact>
<exportedArtifact>org.eclipse.sisu:org.eclipse.sisu.plexus</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-artifact</exportedArtifact>
- <exportedArtifact>org.apache.maven:maven-aether-provider</exportedArtifact>
+ <exportedArtifact>org.apache.maven:maven-resolver-provider</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-artifact-manager</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-compat</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-core</exportedArtifact>
@@ -152,9 +152,9 @@ under the License.
<exportedArtifact>org.apache.maven:maven-settings-builder</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-toolchain</exportedArtifact>
<exportedArtifact>org.apache.maven.wagon:wagon-provider-api</exportedArtifact>
- <exportedArtifact>org.eclipse.aether:aether-api</exportedArtifact>
- <exportedArtifact>org.eclipse.aether:aether-spi</exportedArtifact>
- <exportedArtifact>org.eclipse.aether:aether-impl</exportedArtifact>
+ <exportedArtifact>org.apache.maven.resolver:maven-resolver-api</exportedArtifact>
+ <exportedArtifact>org.apache.maven.resolver:maven-resolver-spi</exportedArtifact>
+ <exportedArtifact>org.apache.maven.resolver:maven-resolver-impl</exportedArtifact>
<exportedArtifact>javax.inject:javax.inject</exportedArtifact>
<exportedArtifact>org.slf4j:slf4j-api</exportedArtifact>
@@ -166,6 +166,9 @@ under the License.
<exportedArtifact>org.sonatype.aether:aether-api</exportedArtifact>
<exportedArtifact>org.sonatype.aether:aether-spi</exportedArtifact>
<exportedArtifact>org.sonatype.aether:aether-impl</exportedArtifact>
+ <exportedArtifact>org.eclipse.aether:aether-api</exportedArtifact>
+ <exportedArtifact>org.eclipse.aether:aether-spi</exportedArtifact>
+ <exportedArtifact>org.eclipse.aether:aether-impl</exportedArtifact>
<!--
| NOTE: Don't exclude the wagons or any of their dependencies (apart from the wagon API). This would otherwise
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/pom.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml
new file mode 100644
index 0000000..7d71e33
--- /dev/null
+++ b/maven-resolver-provider/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven</artifactId>
+ <version>3.5.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-resolver-provider</artifactId>
+
+ <name>Maven Artifact Resolver Provider</name>
+ <description>Extensions to Maven Resolver for utilizing Maven POM and repository metadata.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model-builder</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-repository-metadata</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <classifier>no_aop</classifier>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <!-- Testing -->
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-wagon</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-file</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
new file mode 100644
index 0000000..2395b36
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
@@ -0,0 +1,153 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.License;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Prerequisites;
+import org.apache.maven.model.Repository;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.artifact.ArtifactType;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.DefaultArtifactType;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.Exclusion;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+
+/**
+ * Populates Aether {@link ArtifactDescriptorResult} from Maven project {@link Model}.
+ *
+ * @since 3.2.4
+ * @provisional This class is part of work in progress and can be changed or removed without notice.
+ */
+public class ArtifactDescriptorReaderDelegate
+{
+ public void populateResult( RepositorySystemSession session, ArtifactDescriptorResult result, Model model )
+ {
+ ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
+
+ for ( Repository r : model.getRepositories() )
+ {
+ result.addRepository( ArtifactDescriptorUtils.toRemoteRepository( r ) );
+ }
+
+ for ( org.apache.maven.model.Dependency dependency : model.getDependencies() )
+ {
+ result.addDependency( convert( dependency, stereotypes ) );
+ }
+
+ DependencyManagement mngt = model.getDependencyManagement();
+ if ( mngt != null )
+ {
+ for ( org.apache.maven.model.Dependency dependency : mngt.getDependencies() )
+ {
+ result.addManagedDependency( convert( dependency, stereotypes ) );
+ }
+ }
+
+ Map<String, Object> properties = new LinkedHashMap<>();
+
+ Prerequisites prerequisites = model.getPrerequisites();
+ if ( prerequisites != null )
+ {
+ properties.put( "prerequisites.maven", prerequisites.getMaven() );
+ }
+
+ List<License> licenses = model.getLicenses();
+ properties.put( "license.count", licenses.size() );
+ for ( int i = 0; i < licenses.size(); i++ )
+ {
+ License license = licenses.get( i );
+ properties.put( "license." + i + ".name", license.getName() );
+ properties.put( "license." + i + ".url", license.getUrl() );
+ properties.put( "license." + i + ".comments", license.getComments() );
+ properties.put( "license." + i + ".distribution", license.getDistribution() );
+ }
+
+ result.setProperties( properties );
+
+ setArtifactProperties( result, model );
+ }
+
+ private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes )
+ {
+ ArtifactType stereotype = stereotypes.get( dependency.getType() );
+ if ( stereotype == null )
+ {
+ stereotype = new DefaultArtifactType( dependency.getType() );
+ }
+
+ boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0;
+
+ Map<String, String> props = null;
+ if ( system )
+ {
+ props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() );
+ }
+
+ Artifact artifact =
+ new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
+ dependency.getVersion(), props, stereotype );
+
+ List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() );
+ for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
+ {
+ exclusions.add( convert( exclusion ) );
+ }
+
+ Dependency result = new Dependency( artifact, dependency.getScope(), dependency.isOptional(), exclusions );
+
+ return result;
+ }
+
+ private Exclusion convert( org.apache.maven.model.Exclusion exclusion )
+ {
+ return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" );
+ }
+
+ private void setArtifactProperties( ArtifactDescriptorResult result, Model model )
+ {
+ String downloadUrl = null;
+ DistributionManagement distMngt = model.getDistributionManagement();
+ if ( distMngt != null )
+ {
+ downloadUrl = distMngt.getDownloadUrl();
+ }
+ if ( downloadUrl != null && downloadUrl.length() > 0 )
+ {
+ Artifact artifact = result.getArtifact();
+ Map<String, String> props = new HashMap<>( artifact.getProperties() );
+ props.put( ArtifactProperties.DOWNLOAD_URL, downloadUrl );
+ result.setArtifact( artifact.setProperties( props ) );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
new file mode 100644
index 0000000..7d4ede8
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
@@ -0,0 +1,81 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.model.Repository;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.RepositoryPolicy;
+
+/**
+ * <strong>Warning:</strong> This is an internal utility class that is only public for technical reasons, it is not part
+ * of the public API. In particular, this class can be changed or deleted without prior notice.
+ *
+ * @author Benjamin Bentmann
+ */
+public class ArtifactDescriptorUtils
+{
+
+ public static Artifact toPomArtifact( Artifact artifact )
+ {
+ Artifact pomArtifact = artifact;
+
+ if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
+ {
+ pomArtifact =
+ new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion() );
+ }
+
+ return pomArtifact;
+ }
+
+ public static RemoteRepository toRemoteRepository( Repository repository )
+ {
+ RemoteRepository.Builder builder =
+ new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() );
+ builder.setSnapshotPolicy( toRepositoryPolicy( repository.getSnapshots() ) );
+ builder.setReleasePolicy( toRepositoryPolicy( repository.getReleases() ) );
+ return builder.build();
+ }
+
+ public static RepositoryPolicy toRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy )
+ {
+ boolean enabled = true;
+ String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN;
+ String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
+
+ if ( policy != null )
+ {
+ enabled = policy.isEnabled();
+ if ( policy.getUpdatePolicy() != null )
+ {
+ updates = policy.getUpdatePolicy();
+ }
+ if ( policy.getChecksumPolicy() != null )
+ {
+ checksums = policy.getChecksumPolicy();
+ }
+ }
+
+ return new RepositoryPolicy( enabled, updates, checksums );
+ }
+
+}
[10/15] maven git commit: [MNG-5981] upgrade Sisu to 0.3.3 to pick up
lifecycle fix
Posted by sc...@apache.org.
[MNG-5981] upgrade Sisu to 0.3.3 to pick up lifecycle fix
This closes #78
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/bd57ec96
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/bd57ec96
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/bd57ec96
Branch: refs/heads/DEPMGMT-IMPORT
Commit: bd57ec9666531fa2e32b8fd1aa68b85ac86f7790
Parents: 9b763cc
Author: Stuart McCulloch <mc...@gmail.com>
Authored: Wed Feb 17 23:55:18 2016 +0000
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:16:16 2017 +0100
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/bd57ec96/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 36bdf5b..75bdb87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@ under the License.
<!-- Latest version of Guava that works with Sisu -->
<guavaVersion>18.0</guavaVersion>
<guiceVersion>4.0</guiceVersion>
- <sisuInjectVersion>0.3.2</sisuInjectVersion>
+ <sisuInjectVersion>0.3.3</sisuInjectVersion>
<wagonVersion>2.12</wagonVersion>
<securityDispatcherVersion>1.3</securityDispatcherVersion>
<cipherVersion>1.7</cipherVersion>
[09/15] maven git commit: [MNG-5878] added project.directory property
to support module name != artifactId in every calculated URLs
Posted by sc...@apache.org.
[MNG-5878] added project.directory property to support module name !=
artifactId in every calculated URLs
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/9b763cc0
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/9b763cc0
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/9b763cc0
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 9b763cc002e9a4e247baf7538727da5a29a6ce0b
Parents: 1cb2e92
Author: Herv� Boutemy <hb...@apache.org>
Authored: Sat Dec 5 23:44:20 2015 +0100
Committer: Herv� Boutemy <hb...@apache.org>
Committed: Wed Feb 1 08:01:11 2017 +0100
----------------------------------------------------------------------
.../DefaultInheritanceAssembler.java | 66 +++++++++++++++-----
maven-model-builder/src/site/apt/index.apt | 37 ++++++++---
.../DefaultInheritanceAssemblerTest.java | 39 ++++++++++--
.../module-path-not-artifactId-child.xml | 43 +++++++++++++
.../module-path-not-artifactId-expected.xml | 58 +++++++++++++++++
.../module-path-not-artifactId-parent.xml | 48 ++++++++++++++
maven-model/src/main/mdo/maven.mdo | 10 +--
7 files changed, 270 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
index 6cf4760..8206da9 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
@@ -19,14 +19,16 @@ package org.apache.maven.model.inheritance;
* under the License.
*/
-import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
+import org.apache.maven.model.ModelBase;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.ReportPlugin;
@@ -49,12 +51,18 @@ public class DefaultInheritanceAssembler
private InheritanceModelMerger merger = new InheritanceModelMerger();
+ private static final String CHILD_DIRECTORY = "child-directory";
+
+ private static final String CHILD_DIRECTORY_PROPERTY = "project.directory";
+
@Override
public void assembleModelInheritance( Model child, Model parent, ModelBuildingRequest request,
ModelProblemCollector problems )
{
Map<Object, Object> hints = new HashMap<>();
- hints.put( MavenModelMerger.CHILD_PATH_ADJUSTMENT, getChildPathAdjustment( child, parent ) );
+ String childPath = child.getProperties().getProperty( CHILD_DIRECTORY_PROPERTY, child.getArtifactId() );
+ hints.put( CHILD_DIRECTORY, childPath );
+ hints.put( MavenModelMerger.CHILD_PATH_ADJUSTMENT, getChildPathAdjustment( child, parent, childPath ) );
merger.merge( child, parent, false, hints );
}
@@ -74,9 +82,10 @@ public class DefaultInheritanceAssembler
*
* @param child The child model, must not be <code>null</code>.
* @param parent The parent model, may be <code>null</code>.
+ * @param childDirectory The directory defined in child model, may be <code>null</code>.
* @return The path adjustment, can be empty but never <code>null</code>.
*/
- private String getChildPathAdjustment( Model child, Model parent )
+ private String getChildPathAdjustment( Model child, Model parent, String childDirectory )
{
String adjustment = "";
@@ -91,10 +100,9 @@ public class DefaultInheritanceAssembler
* repository. In other words, modules where artifactId != moduleDirName will see different effective URLs
* depending on how the model was constructed (from filesystem or from repository).
*/
- File childDirectory = child.getProjectDirectory();
- if ( childDirectory != null )
+ if ( child.getProjectDirectory() != null )
{
- childName = childDirectory.getName();
+ childName = child.getProjectDirectory().getName();
}
for ( String module : parent.getModules() )
@@ -116,7 +124,7 @@ public class DefaultInheritanceAssembler
moduleName = moduleName.substring( lastSlash + 1 );
- if ( moduleName.equals( childName ) && lastSlash >= 0 )
+ if ( ( moduleName.equals( childName ) || ( moduleName.equals( childDirectory ) ) ) && lastSlash >= 0 )
{
adjustment = module.substring( 0, lastSlash );
break;
@@ -134,18 +142,16 @@ public class DefaultInheritanceAssembler
@Override
protected String extrapolateChildUrl( String parentUrl, Map<Object, Object> context )
{
- Object artifactId = context.get( ARTIFACT_ID );
+ Object childDirectory = context.get( CHILD_DIRECTORY );
Object childPathAdjustment = context.get( CHILD_PATH_ADJUSTMENT );
- if ( artifactId != null && childPathAdjustment != null && StringUtils.isNotBlank( parentUrl ) )
- {
- // append childPathAdjustment and artifactId to parent url
- return appendPath( parentUrl, artifactId.toString(), childPathAdjustment.toString() );
- }
- else
+ if ( StringUtils.isBlank( parentUrl ) || childDirectory == null || childPathAdjustment == null )
{
return parentUrl;
}
+
+ // append childPathAdjustment and childDirectory to parent url
+ return appendPath( parentUrl, childDirectory.toString(), childPathAdjustment.toString() );
}
private String appendPath( String parentUrl, String childPath, String pathAdjustment )
@@ -192,6 +198,38 @@ public class DefaultInheritanceAssembler
}
@Override
+ protected void mergeModelBase_Properties( ModelBase target, ModelBase source, boolean sourceDominant,
+ Map<Object, Object> context )
+ {
+ Properties merged = new Properties();
+ if ( sourceDominant )
+ {
+ merged.putAll( target.getProperties() );
+ putAll( merged, source.getProperties(), CHILD_DIRECTORY_PROPERTY );
+ }
+ else
+ {
+ putAll( merged, source.getProperties(), CHILD_DIRECTORY_PROPERTY );
+ merged.putAll( target.getProperties() );
+ }
+ target.setProperties( merged );
+ target.setLocation( "properties",
+ InputLocation.merge( target.getLocation( "properties" ),
+ source.getLocation( "properties" ), sourceDominant ) );
+ }
+
+ private void putAll( Map<Object, Object> s, Map<Object, Object> t, Object excludeKey )
+ {
+ for ( Map.Entry<Object, Object> e : t.entrySet() )
+ {
+ if ( !e.getKey().equals( excludeKey ) )
+ {
+ s.put( e.getKey(), e.getValue() );
+ }
+ }
+ }
+
+ @Override
protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source,
boolean sourceDominant, Map<Object, Object> context )
{
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/site/apt/index.apt b/maven-model-builder/src/site/apt/index.apt
index 9a645f4..03946e6 100644
--- a/maven-model-builder/src/site/apt/index.apt
+++ b/maven-model-builder/src/site/apt/index.apt
@@ -57,14 +57,15 @@ Maven Model Builder
** parent resolution until {{{./super-pom.html}super-pom}}
- ** inheritance assembly: <<<InheritanceAssembler>>> ({{{./apidocs/org/apache/maven/model/inheritance/InheritanceAssembler.html}javadoc}}),
- with its <<<DefaultInheritanceAssembler>>> implementation
- ({{{./xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html}source}}). Notice that
- <<<project.url>>>, <<<project.scm.connection>>>, <<<project.scm.developerConnection>>>, <<<project.scm.url>>> and
- <<<project.distributionManagement.site.url>>> have a special treatment: if not overridden in child, the default value is parent's one
- with child artifact id appended
+ []
+
+ * phase 2, with optional plugin processing
- ** model interpolation (see below)
+ ** dependency management import (for dependencies of type <<<pom>>> in the <<<\<dependencyManagement\>>>> section)
+
+ ** inheritance assembly (see {{{./index.html#Inheritance_Assembly}below}})
+
+ ** model interpolation (see {{{./index.html#Model_Interpolation}below}})
** url normalization: <<<UrlNormalizer>>> ({{{./apidocs/org/apache/maven/model/path/UrlNormalizer.html}javadoc}}),
with its <<<DefaultUrlNormalizer>>> implementation
@@ -117,6 +118,28 @@ Maven Model Builder
[]
+* Inheritance Assembly
+
+ Inheritance Assembly consists in filling current model empty fields with values taken from parent model.
+ It is done in <<<InheritanceAssembler>>> ({{{./apidocs/org/apache/maven/model/inheritance/InheritanceAssembler.html}javadoc}}),
+ with its <<<DefaultInheritanceAssembler>>> implementation
+ ({{{./xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html}source}}).
+
+ By default, every model field is inherited as-is from parent, with a few exceptions that are intentionally not inherited:
+ <<<modelVersion>>>, <<<artifactId>>>, <<<profiles>>> (injected in phase 1) and <<<prerequisites>>>.
+
+ Notice that the 5 URLs from the model (<<<project.url>>>, <<<project.scm.connection>>>, <<<project.scm.developerConnection>>>,
+ <<<project.scm.url>>> and <<<project.distributionManagement.site.url>>>) have a special inheritance handling:
+
+ ** if not configured in current model, the inherited value is the parent's one with current artifact id appended,
+
+ ** since Maven 3.5.0, if <<<project.directory>>> POM property value is defined, it is used instead of artifact id:
+ this permits default inheritance calculations when module directory name is not equal to artifact id. Notice that this
+ property is not inherited from a POM to its child: childs POM will use child artifact id if property is not
+ set.
+
+ []
+
* Model Interpolation
Model Interpolation consists in replacing <<<$\{...\}>>> with calculated value. It is done in <<<StringSearchModelInterpolator>>>
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
index e477fde..96eed6f 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
@@ -35,6 +35,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.StandardCharsets;
/**
* @author Herv� Boutemy
@@ -112,12 +113,13 @@ public class DefaultInheritanceAssemblerTest
{
// build from disk expected to fail
testInheritance( "tricky-flat-artifactId-urls", false );
- fail( "should have failed since module reference == artifactId != directory name" );
+ //fail( "should have failed since module reference == artifactId != directory name" );
}
catch ( AssertionFailedError afe )
{
// expected failure: wrong relative path calculation
- assertTrue( afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
+ assertTrue( afe.getMessage(),
+ afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
}
// but ok from repo: local disk is ignored
testInheritance( "tricky-flat-artifactId-urls", true );
@@ -133,7 +135,8 @@ public class DefaultInheritanceAssemblerTest
catch ( AssertionFailedError afe )
{
// expected failure
- assertTrue( afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
+ assertTrue( afe.getMessage(),
+ afe.getMessage().contains( "http://www.apache.org/path/to/parent/child-artifact-id/" ) );
}
}
@@ -176,12 +179,38 @@ public class DefaultInheritanceAssemblerTest
// check with getPom( baseName + "-expected" )
File expected = getPom( baseName + "-expected" );
- try ( Reader control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" );
- Reader test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" ) )
+ try ( Reader control = new InputStreamReader( new FileInputStream( expected ), StandardCharsets.UTF_8 );
+ Reader test = new InputStreamReader( new FileInputStream( actual ), StandardCharsets.UTF_8 ) )
{
XMLUnit.setIgnoreComments( true );
XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual( control, test );
}
}
+
+ public void testModulePathNotArtifactId()
+ throws Exception
+ {
+ Model parent = getModel( "module-path-not-artifactId-parent" );
+
+ Model child = getModel( "module-path-not-artifactId-child" );
+
+ SimpleProblemCollector problems = new SimpleProblemCollector();
+
+ assembler.assembleModelInheritance( child, parent, null, problems );
+
+ File actual = getTestFile( "target/test-classes/poms/inheritance/module-path-not-artifactId-actual.xml" );
+
+ writer.write( actual, null, child );
+
+ // check with getPom( "module-path-not-artifactId-effective" )
+ File expected = getPom( "module-path-not-artifactId-expected" );
+ try ( Reader control = new InputStreamReader( new FileInputStream( expected ), StandardCharsets.UTF_8 );
+ Reader test = new InputStreamReader( new FileInputStream( actual ), StandardCharsets.UTF_8 ) )
+ {
+ XMLUnit.setIgnoreComments( true );
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual( control, test );
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml
new file mode 100644
index 0000000..7031f44
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>inheritance</groupId>
+ <artifactId>parent</artifactId>
+ <version>11-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>child-artifact-id</artifactId>
+ <name>Model inheritance test parent: module directory != artifactId</name>
+ <description>
+ artifactId == "child-artifact-id"
+ but expect path on SCM and site == "child"
+ feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId"
+ </description>
+
+ <properties>
+ <project.directory>child</project.directory>
+ </properties>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml
new file mode 100644
index 0000000..e82f289
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>inheritance</groupId>
+ <artifactId>parent</artifactId>
+ <version>11-SNAPSHOT</version>
+ </parent>
+
+ <groupId>inheritance</groupId>
+ <artifactId>child-artifact-id</artifactId>
+ <version>11-SNAPSHOT</version>
+ <name>Model inheritance test parent: module directory != artifactId</name>
+ <description>
+ artifactId == "child-artifact-id"
+ but expect path on SCM and site == "child"
+ feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId"
+ </description>
+
+ <!-- 5 inherited urls with ${project.directory} added to parent instead of artifactId -->
+ <url>http://www.apache.org/child/</url>
+ <scm>
+ <connection>scm:my-scm:http://domain.org/base/child</connection>
+ <developerConnection>scm:my-scm:https://domain.org/base/child/</developerConnection>
+ <url>https://domain.org/base/child</url>
+ </scm>
+ <distributionManagement>
+ <site>
+ <url>scp://scp.domain.org/base/child/</url>
+ </site>
+ </distributionManagement>
+
+ <properties>
+ <project.directory>child</project.directory>
+ </properties>
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml
new file mode 100644
index 0000000..9b923cd
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>inheritance</groupId>
+ <artifactId>parent</artifactId>
+ <version>11-SNAPSHOT</version>
+
+ <name>Model inheritance test parent: module path != artifactId</name>
+
+ <modules>
+ <module>child</module>
+ </modules>
+
+ <!-- 5 URLs in the pom will be inherited with path added -->
+ <url>http://www.apache.org/</url>
+ <scm>
+ <connection>scm:my-scm:http://domain.org/base</connection>
+ <developerConnection>scm:my-scm:https://domain.org/base/</developerConnection>
+ <url>https://domain.org/base</url>
+ </scm>
+ <distributionManagement>
+ <site>
+ <url>scp://scp.domain.org/base/</url>
+ </site>
+ </distributionManagement>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/9b763cc0/maven-model/src/main/mdo/maven.mdo
----------------------------------------------------------------------
diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo
index d830113..5322c35 100644
--- a/maven-model/src/main/mdo/maven.mdo
+++ b/maven-model/src/main/mdo/maven.mdo
@@ -245,7 +245,7 @@
<description>
<![CDATA[
The URL to the project's homepage.
- <br /><b>Default value is</b>: parent value [+ path adjustment] + artifactId
+ <br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
]]>
</description>
<type>String</type>
@@ -2142,7 +2142,7 @@
<a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
This connection is read-only.
- <br /><b>Default value is</b>: parent value [+ path adjustment] + artifactId
+ <br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
]]>
</description>
<type>String</type>
@@ -2154,7 +2154,7 @@
<![CDATA[
Just like <code>connection</code>, but for developers, i.e. this scm connection
will not be read only.
- <br /><b>Default value is</b>: parent value [+ path adjustment] + artifactId
+ <br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
]]>
</description>
<type>String</type>
@@ -2172,7 +2172,7 @@
<description>
<![CDATA[
The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
- <br /><b>Default value is</b>: parent value [+ path adjustment] + artifactId
+ <br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
]]>
</description>
<type>String</type>
@@ -2605,7 +2605,7 @@
<description>
<![CDATA[
The url of the location where website is deployed, in the form <code>protocol://hostname/path</code>.
- <br /><b>Default value is</b>: parent value [+ path adjustment] + artifactId
+ <br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
]]>
</description>
<type>String</type>
[07/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
deleted file mode 100644
index 2b0890b..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
+++ /dev/null
@@ -1,617 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.commons.lang3.Validate;
-import org.apache.maven.artifact.repository.metadata.Snapshot;
-import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
-import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-import org.eclipse.aether.RepositoryCache;
-import org.eclipse.aether.RepositoryEvent;
-import org.eclipse.aether.RepositoryEvent.EventType;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.SyncContext;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.impl.MetadataResolver;
-import org.eclipse.aether.impl.RepositoryEventDispatcher;
-import org.eclipse.aether.impl.SyncContextFactory;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.internal.impl.CacheUtils;
-import org.eclipse.aether.metadata.DefaultMetadata;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.repository.WorkspaceRepository;
-import org.eclipse.aether.resolution.MetadataRequest;
-import org.eclipse.aether.resolution.MetadataResult;
-import org.eclipse.aether.resolution.VersionRequest;
-import org.eclipse.aether.resolution.VersionResolutionException;
-import org.eclipse.aether.resolution.VersionResult;
-import org.eclipse.aether.spi.locator.Service;
-import org.eclipse.aether.spi.locator.ServiceLocator;
-import org.eclipse.aether.spi.log.Logger;
-import org.eclipse.aether.spi.log.LoggerFactory;
-import org.eclipse.aether.spi.log.NullLoggerFactory;
-import org.eclipse.aether.util.ConfigUtils;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Benjamin Bentmann
- */
-@Named
-@Component( role = VersionResolver.class )
-public class DefaultVersionResolver
- implements VersionResolver, Service
-{
-
- private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
-
- private static final String RELEASE = "RELEASE";
-
- private static final String LATEST = "LATEST";
-
- private static final String SNAPSHOT = "SNAPSHOT";
-
- @SuppressWarnings( "unused" )
- @Requirement( role = LoggerFactory.class )
- private Logger logger = NullLoggerFactory.LOGGER;
-
- @Requirement
- private MetadataResolver metadataResolver;
-
- @Requirement
- private SyncContextFactory syncContextFactory;
-
- @Requirement
- private RepositoryEventDispatcher repositoryEventDispatcher;
-
- public DefaultVersionResolver()
- {
- // enable no-arg constructor
- }
-
- @Inject
- DefaultVersionResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory,
- RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
- {
- setMetadataResolver( metadataResolver );
- setSyncContextFactory( syncContextFactory );
- setLoggerFactory( loggerFactory );
- setRepositoryEventDispatcher( repositoryEventDispatcher );
- }
-
- public void initService( ServiceLocator locator )
- {
- setLoggerFactory( locator.getService( LoggerFactory.class ) );
- setMetadataResolver( locator.getService( MetadataResolver.class ) );
- setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
- setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
- }
-
- public DefaultVersionResolver setLoggerFactory( LoggerFactory loggerFactory )
- {
- this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
- return this;
- }
-
- void setLogger( LoggerFactory loggerFactory )
- {
- // plexus support
- setLoggerFactory( loggerFactory );
- }
-
- public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver )
- {
- this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
- return this;
- }
-
- public DefaultVersionResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
- {
- this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
- return this;
- }
-
- public DefaultVersionResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
- {
- this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
- "repositoryEventDispatcher cannot be null" );
- return this;
- }
-
- public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
- throws VersionResolutionException
- {
- RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
-
- Artifact artifact = request.getArtifact();
-
- String version = artifact.getVersion();
-
- VersionResult result = new VersionResult( request );
-
- Key cacheKey = null;
- RepositoryCache cache = session.getCache();
- if ( cache != null && !ConfigUtils.getBoolean( session, false, "aether.versionResolver.noCache" ) )
- {
- cacheKey = new Key( session, request );
-
- Object obj = cache.get( session, cacheKey );
- if ( obj instanceof Record )
- {
- Record record = (Record) obj;
- result.setVersion( record.version );
- result.setRepository(
- CacheUtils.getRepository( session, request.getRepositories(), record.repoClass, record.repoId ) );
- return result;
- }
- }
-
- Metadata metadata;
-
- if ( RELEASE.equals( version ) )
- {
- metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
- Metadata.Nature.RELEASE );
- }
- else if ( LATEST.equals( version ) )
- {
- metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
- Metadata.Nature.RELEASE_OR_SNAPSHOT );
- }
- else if ( version.endsWith( SNAPSHOT ) )
- {
- WorkspaceReader workspace = session.getWorkspaceReader();
- if ( workspace != null && workspace.findVersions( artifact ).contains( version ) )
- {
- metadata = null;
- result.setRepository( workspace.getRepository() );
- }
- else
- {
- metadata =
- new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML,
- Metadata.Nature.SNAPSHOT );
- }
- }
- else
- {
- metadata = null;
- }
-
- if ( metadata == null )
- {
- result.setVersion( version );
- }
- else
- {
- List<MetadataRequest> metadataReqs = new ArrayList<>( request.getRepositories().size() );
-
- metadataReqs.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
-
- for ( RemoteRepository repository : request.getRepositories() )
- {
- MetadataRequest metadataRequest =
- new MetadataRequest( metadata, repository, request.getRequestContext() );
- metadataRequest.setDeleteLocalCopyIfMissing( true );
- metadataRequest.setFavorLocalRepository( true );
- metadataRequest.setTrace( trace );
- metadataReqs.add( metadataRequest );
- }
-
- List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataReqs );
-
- Map<String, VersionInfo> infos = new HashMap<>();
-
- for ( MetadataResult metadataResult : metadataResults )
- {
- result.addException( metadataResult.getException() );
-
- ArtifactRepository repository = metadataResult.getRequest().getRepository();
- if ( repository == null )
- {
- repository = session.getLocalRepository();
- }
-
- Versioning v = readVersions( session, trace, metadataResult.getMetadata(), repository, result );
- merge( artifact, infos, v, repository );
- }
-
- if ( RELEASE.equals( version ) )
- {
- resolve( result, infos, RELEASE );
- }
- else if ( LATEST.equals( version ) )
- {
- if ( !resolve( result, infos, LATEST ) )
- {
- resolve( result, infos, RELEASE );
- }
-
- if ( result.getVersion() != null && result.getVersion().endsWith( SNAPSHOT ) )
- {
- VersionRequest subRequest = new VersionRequest();
- subRequest.setArtifact( artifact.setVersion( result.getVersion() ) );
- if ( result.getRepository() instanceof RemoteRepository )
- {
- RemoteRepository r = (RemoteRepository) result.getRepository();
- subRequest.setRepositories( Collections.singletonList( r ) );
- }
- else
- {
- subRequest.setRepositories( request.getRepositories() );
- }
- VersionResult subResult = resolveVersion( session, subRequest );
- result.setVersion( subResult.getVersion() );
- result.setRepository( subResult.getRepository() );
- for ( Exception exception : subResult.getExceptions() )
- {
- result.addException( exception );
- }
- }
- }
- else
- {
- String key = SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() );
- merge( infos, SNAPSHOT, key );
- if ( !resolve( result, infos, key ) )
- {
- result.setVersion( version );
- }
- }
-
- if ( StringUtils.isEmpty( result.getVersion() ) )
- {
- throw new VersionResolutionException( result );
- }
- }
-
- if ( cacheKey != null && metadata != null && isSafelyCacheable( session, artifact ) )
- {
- cache.put( session, cacheKey, new Record( result.getVersion(), result.getRepository() ) );
- }
-
- return result;
- }
-
- private boolean resolve( VersionResult result, Map<String, VersionInfo> infos, String key )
- {
- VersionInfo info = infos.get( key );
- if ( info != null )
- {
- result.setVersion( info.version );
- result.setRepository( info.repository );
- }
- return info != null;
- }
-
- private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
- ArtifactRepository repository, VersionResult result )
- {
- Versioning versioning = null;
-
- FileInputStream fis = null;
- try
- {
- if ( metadata != null )
- {
-
- try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
- {
- syncContext.acquire( null, Collections.singleton( metadata ) );
-
- if ( metadata.getFile() != null && metadata.getFile().exists() )
- {
- fis = new FileInputStream( metadata.getFile() );
- org.apache.maven.artifact.repository.metadata.Metadata m =
- new MetadataXpp3Reader().read( fis, false );
- versioning = m.getVersioning();
-
- /*
- * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
- * of the local repository. This is especially troublesome during snapshot resolution so we try
- * to handle that gracefully.
- */
- if ( versioning != null && repository instanceof LocalRepository )
- {
- if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
- {
- Versioning repaired = new Versioning();
- repaired.setLastUpdated( versioning.getLastUpdated() );
- Snapshot snapshot = new Snapshot();
- snapshot.setLocalCopy( true );
- repaired.setSnapshot( snapshot );
- versioning = repaired;
-
- throw new IOException( "Snapshot information corrupted with remote repository data"
- + ", please verify that no remote repository uses the id '"
- + repository.getId() + "'" );
- }
- }
- }
- }
- }
- }
- catch ( Exception e )
- {
- invalidMetadata( session, trace, metadata, repository, e );
- result.addException( e );
- }
- finally
- {
- IOUtil.close( fis );
- }
-
- return ( versioning != null ) ? versioning : new Versioning();
- }
-
- private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
- ArtifactRepository repository, Exception exception )
- {
- RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID );
- event.setTrace( trace );
- event.setMetadata( metadata );
- event.setException( exception );
- event.setRepository( repository );
-
- repositoryEventDispatcher.dispatch( event.build() );
- }
-
- private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
- ArtifactRepository repository )
- {
- if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
- {
- merge( RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository );
- }
-
- if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
- {
- merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
- }
-
- for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
- {
- if ( StringUtils.isNotEmpty( sv.getVersion() ) )
- {
- String key = getKey( sv.getClassifier(), sv.getExtension() );
- merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
- }
- }
-
- Snapshot snapshot = versioning.getSnapshot();
- if ( snapshot != null && versioning.getSnapshotVersions().isEmpty() )
- {
- String version = artifact.getVersion();
- if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
- {
- String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
- version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
- }
- merge( SNAPSHOT, infos, versioning.getLastUpdated(), version, repository );
- }
- }
-
- private void merge( String key, Map<String, VersionInfo> infos, String timestamp, String version,
- ArtifactRepository repository )
- {
- VersionInfo info = infos.get( key );
- if ( info == null )
- {
- info = new VersionInfo( timestamp, version, repository );
- infos.put( key, info );
- }
- else if ( info.isOutdated( timestamp ) )
- {
- info.version = version;
- info.repository = repository;
- info.timestamp = timestamp;
- }
- }
-
- private void merge( Map<String, VersionInfo> infos, String srcKey, String dstKey )
- {
- VersionInfo srcInfo = infos.get( srcKey );
- VersionInfo dstInfo = infos.get( dstKey );
-
- if ( dstInfo == null || ( srcInfo != null && dstInfo.isOutdated( srcInfo.timestamp )
- && srcInfo.repository != dstInfo.repository ) )
- {
- infos.put( dstKey, srcInfo );
- }
- }
-
- private String getKey( String classifier, String extension )
- {
- return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
- }
-
- private boolean isSafelyCacheable( RepositorySystemSession session, Artifact artifact )
- {
- /*
- * The workspace/reactor is in flux so we better not assume definitive information for any of its
- * artifacts/projects.
- */
-
- WorkspaceReader workspace = session.getWorkspaceReader();
- if ( workspace == null )
- {
- return true;
- }
-
- Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( artifact );
-
- return workspace.findArtifact( pomArtifact ) == null;
- }
-
- private static class VersionInfo
- {
-
- String timestamp;
-
- String version;
-
- ArtifactRepository repository;
-
- public VersionInfo( String timestamp, String version, ArtifactRepository repository )
- {
- this.timestamp = ( timestamp != null ) ? timestamp : "";
- this.version = version;
- this.repository = repository;
- }
-
- public boolean isOutdated( String timestamp )
- {
- return timestamp != null && timestamp.compareTo( this.timestamp ) > 0;
- }
-
- }
-
- private static class Key
- {
-
- private final String groupId;
-
- private final String artifactId;
-
- private final String classifier;
-
- private final String extension;
-
- private final String version;
-
- private final String context;
-
- private final File localRepo;
-
- private final WorkspaceRepository workspace;
-
- private final List<RemoteRepository> repositories;
-
- private final int hashCode;
-
- public Key( RepositorySystemSession session, VersionRequest request )
- {
- Artifact artifact = request.getArtifact();
- groupId = artifact.getGroupId();
- artifactId = artifact.getArtifactId();
- classifier = artifact.getClassifier();
- extension = artifact.getExtension();
- version = artifact.getVersion();
- localRepo = session.getLocalRepository().getBasedir();
- workspace = CacheUtils.getWorkspace( session );
- repositories = new ArrayList<>( request.getRepositories().size() );
- boolean repoMan = false;
- for ( RemoteRepository repository : request.getRepositories() )
- {
- if ( repository.isRepositoryManager() )
- {
- repoMan = true;
- repositories.addAll( repository.getMirroredRepositories() );
- }
- else
- {
- repositories.add( repository );
- }
- }
- context = repoMan ? request.getRequestContext() : "";
-
- int hash = 17;
- hash = hash * 31 + groupId.hashCode();
- hash = hash * 31 + artifactId.hashCode();
- hash = hash * 31 + classifier.hashCode();
- hash = hash * 31 + extension.hashCode();
- hash = hash * 31 + version.hashCode();
- hash = hash * 31 + localRepo.hashCode();
- hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
- hashCode = hash;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( obj == this )
- {
- return true;
- }
- else if ( obj == null || !getClass().equals( obj.getClass() ) )
- {
- return false;
- }
-
- Key that = (Key) obj;
- return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && classifier.equals(
- that.classifier ) && extension.equals( that.extension ) && version.equals( that.version )
- && context.equals( that.context ) && localRepo.equals( that.localRepo )
- && CacheUtils.eq( workspace, that.workspace )
- && CacheUtils.repositoriesEquals( repositories, that.repositories );
- }
-
- @Override
- public int hashCode()
- {
- return hashCode;
- }
-
- }
-
- private static class Record
- {
- final String version;
-
- final String repoId;
-
- final Class<?> repoClass;
-
- public Record( String version, ArtifactRepository repository )
- {
- this.version = version;
- if ( repository != null )
- {
- repoId = repository.getId();
- repoClass = repository.getClass();
- }
- else
- {
- repoId = null;
- repoClass = null;
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
deleted file mode 100644
index a572010..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.apache.maven.artifact.repository.metadata.Snapshot;
-import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
-import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * @author Benjamin Bentmann
- */
-final class LocalSnapshotMetadata
- extends MavenMetadata
-{
-
- private final Collection<Artifact> artifacts = new ArrayList<>();
-
- private final boolean legacyFormat;
-
- public LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat )
- {
- super( createMetadata( artifact, legacyFormat ), null );
- this.legacyFormat = legacyFormat;
- }
-
- public LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
- {
- super( metadata, file );
- this.legacyFormat = legacyFormat;
- }
-
- private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
- {
- Snapshot snapshot = new Snapshot();
- snapshot.setLocalCopy( true );
- Versioning versioning = new Versioning();
- versioning.setSnapshot( snapshot );
-
- Metadata metadata = new Metadata();
- metadata.setVersioning( versioning );
- metadata.setGroupId( artifact.getGroupId() );
- metadata.setArtifactId( artifact.getArtifactId() );
- metadata.setVersion( artifact.getBaseVersion() );
-
- if ( !legacyFormat )
- {
- metadata.setModelVersion( "1.1.0" );
- }
-
- return metadata;
- }
-
- public void bind( Artifact artifact )
- {
- artifacts.add( artifact );
- }
-
- public MavenMetadata setFile( File file )
- {
- return new LocalSnapshotMetadata( metadata, file, legacyFormat );
- }
-
- public Object getKey()
- {
- return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
- }
-
- public static Object getKey( Artifact artifact )
- {
- return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
- }
-
- @Override
- protected void merge( Metadata recessive )
- {
- metadata.getVersioning().updateTimestamp();
-
- if ( !legacyFormat )
- {
- String lastUpdated = metadata.getVersioning().getLastUpdated();
-
- Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
-
- for ( Artifact artifact : artifacts )
- {
- SnapshotVersion sv = new SnapshotVersion();
- sv.setClassifier( artifact.getClassifier() );
- sv.setExtension( artifact.getExtension() );
- sv.setVersion( getVersion() );
- sv.setUpdated( lastUpdated );
- versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
- }
-
- Versioning versioning = recessive.getVersioning();
- if ( versioning != null )
- {
- for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
- {
- String key = getKey( sv.getClassifier(), sv.getExtension() );
- if ( !versions.containsKey( key ) )
- {
- versions.put( key, sv );
- }
- }
- }
-
- metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
- }
-
- artifacts.clear();
- }
-
- private String getKey( String classifier, String extension )
- {
- return classifier + ':' + extension;
- }
-
- public String getGroupId()
- {
- return metadata.getGroupId();
- }
-
- public String getArtifactId()
- {
- return metadata.getArtifactId();
- }
-
- public String getVersion()
- {
- return metadata.getVersion();
- }
-
- public Nature getNature()
- {
- return Nature.SNAPSHOT;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
deleted file mode 100644
index 072ba66..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.impl.MetadataGenerator;
-import org.eclipse.aether.installation.InstallRequest;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.util.ConfigUtils;
-
-/**
- * @author Benjamin Bentmann
- */
-class LocalSnapshotMetadataGenerator
- implements MetadataGenerator
-{
-
- private Map<Object, LocalSnapshotMetadata> snapshots;
-
- private final boolean legacyFormat;
-
- public LocalSnapshotMetadataGenerator( RepositorySystemSession session, InstallRequest request )
- {
- legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
-
- snapshots = new LinkedHashMap<>();
- }
-
- public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
- {
- for ( Artifact artifact : artifacts )
- {
- if ( artifact.isSnapshot() )
- {
- Object key = LocalSnapshotMetadata.getKey( artifact );
- LocalSnapshotMetadata snapshotMetadata = snapshots.get( key );
- if ( snapshotMetadata == null )
- {
- snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat );
- snapshots.put( key, snapshotMetadata );
- }
- snapshotMetadata.bind( artifact );
- }
- }
-
- return Collections.emptyList();
- }
-
- public Artifact transformArtifact( Artifact artifact )
- {
- return artifact;
- }
-
- public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
- {
- return snapshots.values();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
deleted file mode 100644
index 1c9acd7..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.apache.maven.model.building.DefaultModelBuilderFactory;
-import org.apache.maven.model.building.ModelBuilder;
-import org.eclipse.aether.impl.AetherModule;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.impl.VersionResolver;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-
-public final class MavenAetherModule
- extends AbstractModule
-{
-
- @Override
- protected void configure()
- {
- install( new AetherModule() );
- bind( ArtifactDescriptorReader.class ) //
- .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
- bind( VersionResolver.class ) //
- .to( DefaultVersionResolver.class ).in( Singleton.class );
- bind( VersionRangeResolver.class ) //
- .to( DefaultVersionRangeResolver.class ).in( Singleton.class );
- bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) //
- .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
- bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) //
- .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
- bind( ModelBuilder.class ) //
- .toInstance( new DefaultModelBuilderFactory().newInstance() );
- }
-
- @Provides
- @Singleton
- Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories( @Named( "snapshot" )
- MetadataGeneratorFactory snapshot,
- @Named( "versions" )
- MetadataGeneratorFactory versions )
- {
- Set<MetadataGeneratorFactory> factories = new HashSet<>();
- factories.add( snapshot );
- factories.add( versions );
- return Collections.unmodifiableSet( factories );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
deleted file mode 100644
index aef44f6..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.artifact.repository.metadata.Metadata;
-import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
-import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.WriterFactory;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.metadata.AbstractMetadata;
-import org.eclipse.aether.metadata.MergeableMetadata;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * @author Benjamin Bentmann
- */
-abstract class MavenMetadata
- extends AbstractMetadata
- implements MergeableMetadata
-{
-
- static final String MAVEN_METADATA_XML = "maven-metadata.xml";
-
- private final File file;
-
- protected Metadata metadata;
-
- private boolean merged;
-
- protected MavenMetadata( Metadata metadata, File file )
- {
- this.metadata = metadata;
- this.file = file;
- }
-
- public String getType()
- {
- return MAVEN_METADATA_XML;
- }
-
- public File getFile()
- {
- return file;
- }
-
- public void merge( File existing, File result )
- throws RepositoryException
- {
- Metadata recessive = read( existing );
-
- merge( recessive );
-
- write( result, metadata );
-
- merged = true;
- }
-
- public boolean isMerged()
- {
- return merged;
- }
-
- protected abstract void merge( Metadata recessive );
-
- static Metadata read( File metadataFile )
- throws RepositoryException
- {
- if ( metadataFile.length() <= 0 )
- {
- return new Metadata();
- }
-
- try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
- {
- return new MetadataXpp3Reader().read( reader, false );
- }
- catch ( IOException e )
- {
- throw new RepositoryException( "Could not read metadata " + metadataFile + ": " + e.getMessage(), e );
- }
- catch ( XmlPullParserException e )
- {
- throw new RepositoryException( "Could not parse metadata " + metadataFile + ": " + e.getMessage(), e );
- }
- }
-
- private void write( File metadataFile, Metadata metadata )
- throws RepositoryException
- {
- metadataFile.getParentFile().mkdirs();
- try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) )
- {
- new MetadataXpp3Writer().write( writer, metadata );
- }
- catch ( IOException e )
- {
- throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e );
- }
- }
-
- public Map<String, String> getProperties()
- {
- return Collections.emptyMap();
- }
-
- @Override
- public org.eclipse.aether.metadata.Metadata setProperties( Map<String, String> properties )
- {
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
deleted file mode 100644
index 1b11cb3..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Properties;
-
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.artifact.DefaultArtifactType;
-import org.eclipse.aether.collection.DependencyGraphTransformer;
-import org.eclipse.aether.collection.DependencyManager;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.collection.DependencyTraverser;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.DefaultServiceLocator;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
-import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
-import org.eclipse.aether.util.graph.selector.AndDependencySelector;
-import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
-import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
-import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
-import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
-import org.eclipse.aether.util.graph.transformer.ConflictResolver;
-import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
-import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
-import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
-import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
-import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
-import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
-import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
-
-/**
- * A utility class to assist in setting up a Maven-like repository system. <em>Note:</em> This component is meant to
- * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead
- * always use regular dependency injection to acquire the repository system.
- *
- * @author Benjamin Bentmann
- */
-public final class MavenRepositorySystemUtils
-{
-
- private MavenRepositorySystemUtils()
- {
- // hide constructor
- }
-
- /**
- * Creates a new service locator that already knows about all service implementations included in this library. To
- * acquire a complete repository system, clients need to add some repository connectors for remote transfers.
- *
- * @return The new service locator, never {@code null}.
- */
- public static DefaultServiceLocator newServiceLocator()
- {
- DefaultServiceLocator locator = new DefaultServiceLocator();
- locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class );
- locator.addService( VersionResolver.class, DefaultVersionResolver.class );
- locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class );
- locator.addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class );
- locator.addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class );
- return locator;
- }
-
- /**
- * Creates a new Maven-like repository system session by initializing the session with values typical for
- * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency
- * graphs, most other settings remain at their generic default value. Use the various setters to further configure
- * the session with authentication, mirror, proxy and other information required for your environment.
- *
- * @return The new repository system session, never {@code null}.
- */
- public static DefaultRepositorySystemSession newSession()
- {
- DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
-
- DependencyTraverser depTraverser = new FatArtifactTraverser();
- session.setDependencyTraverser( depTraverser );
-
- DependencyManager depManager = new ClassicDependencyManager();
- session.setDependencyManager( depManager );
-
- DependencySelector depFilter =
- new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
- new OptionalDependencySelector(), new ExclusionDependencySelector() );
- session.setDependencySelector( depFilter );
-
- DependencyGraphTransformer transformer =
- new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(),
- new SimpleOptionalitySelector(), new JavaScopeDeriver() );
- new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() );
- session.setDependencyGraphTransformer( transformer );
-
- DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
- stereotypes.add( new DefaultArtifactType( "pom" ) );
- stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) );
- stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) );
- stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) );
- stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) );
- stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) );
- stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) );
- stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) );
- stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) );
- stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) );
- stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) );
- stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) );
- session.setArtifactTypeRegistry( stereotypes );
-
- session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
-
- final Properties systemProperties = new Properties();
-
- // MNG-5670 guard against ConcurrentModificationException
- // MNG-6053 guard against key without value
- Properties sysProp = System.getProperties();
- synchronized ( sysProp )
- {
- systemProperties.putAll( sysProp );
- }
-
- session.setSystemProperties( systemProperties );
- session.setConfigProperties( systemProperties );
-
- return session;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
deleted file mode 100644
index e4c9a7e..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * @author Herv� Boutemy
- */
-abstract class MavenSnapshotMetadata
- extends MavenMetadata
-{
- static final String SNAPSHOT = "SNAPSHOT";
-
- protected final Collection<Artifact> artifacts = new ArrayList<>();
-
- protected final boolean legacyFormat;
-
- protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
- {
- super( metadata, file );
- this.legacyFormat = legacyFormat;
- }
-
- protected static Metadata createRepositoryMetadata( Artifact artifact, boolean legacyFormat )
- {
- Metadata metadata = new Metadata();
- if ( !legacyFormat )
- {
- metadata.setModelVersion( "1.1.0" );
- }
- metadata.setGroupId( artifact.getGroupId() );
- metadata.setArtifactId( artifact.getArtifactId() );
- metadata.setVersion( artifact.getBaseVersion() );
-
- return metadata;
- }
-
- public void bind( Artifact artifact )
- {
- artifacts.add( artifact );
- }
-
- public Object getKey()
- {
- return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
- }
-
- public static Object getKey( Artifact artifact )
- {
- return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
- }
-
- protected String getKey( String classifier, String extension )
- {
- return classifier + ':' + extension;
- }
-
- public String getGroupId()
- {
- return metadata.getGroupId();
- }
-
- public String getArtifactId()
- {
- return metadata.getArtifactId();
- }
-
- public String getVersion()
- {
- return metadata.getVersion();
- }
-
- public Nature getNature()
- {
- return Nature.SNAPSHOT;
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
deleted file mode 100644
index 270cf58..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.model.Model;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.WorkspaceReader;
-
-public interface MavenWorkspaceReader
- extends WorkspaceReader
-{
-
- Model findModel( Artifact artifact );
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
deleted file mode 100644
index c6ef3aa..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.commons.lang3.Validate;
-import org.eclipse.aether.artifact.AbstractArtifact;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * @author Benjamin Bentmann
- */
-final class RelocatedArtifact
- extends AbstractArtifact
-{
-
- private final Artifact artifact;
-
- private final String groupId;
-
- private final String artifactId;
-
- private final String version;
-
- public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
- {
- this.artifact = Validate.notNull( artifact, "artifact cannot be null" );
- // TODO Use StringUtils here
- this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null;
- this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null;
- this.version = ( version != null && version.length() > 0 ) ? version : null;
- }
-
- public String getGroupId()
- {
- if ( groupId != null )
- {
- return groupId;
- }
- else
- {
- return artifact.getGroupId();
- }
- }
-
- public String getArtifactId()
- {
- if ( artifactId != null )
- {
- return artifactId;
- }
- else
- {
- return artifact.getArtifactId();
- }
- }
-
- public String getVersion()
- {
- if ( version != null )
- {
- return version;
- }
- else
- {
- return artifact.getVersion();
- }
- }
-
- public String getClassifier()
- {
- return artifact.getClassifier();
- }
-
- public String getExtension()
- {
- return artifact.getExtension();
- }
-
- public File getFile()
- {
- return artifact.getFile();
- }
-
- public String getProperty( String key, String defaultValue )
- {
- return artifact.getProperty( key, defaultValue );
- }
-
- public Map<String, String> getProperties()
- {
- return artifact.getProperties();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
deleted file mode 100644
index 1e791d8..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.apache.maven.artifact.repository.metadata.Snapshot;
-import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
-import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * @author Benjamin Bentmann
- */
-final class RemoteSnapshotMetadata
- extends MavenSnapshotMetadata
-{
- public static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss";
-
- public static final TimeZone DEFAULT_SNAPSHOT_TIME_ZONE = TimeZone.getTimeZone( "Etc/UTC" );
-
- private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
-
- public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat )
- {
- super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat );
- }
-
- private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
- {
- super( metadata, file, legacyFormat );
- }
-
- public MavenMetadata setFile( File file )
- {
- return new RemoteSnapshotMetadata( metadata, file, legacyFormat );
- }
-
- public String getExpandedVersion( Artifact artifact )
- {
- String key = getKey( artifact.getClassifier(), artifact.getExtension() );
- return versions.get( key ).getVersion();
- }
-
- @Override
- protected void merge( Metadata recessive )
- {
- Snapshot snapshot;
- String lastUpdated;
-
- if ( metadata.getVersioning() == null )
- {
- DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT );
- utcDateFormatter.setCalendar( new GregorianCalendar() );
- utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE );
-
- snapshot = new Snapshot();
- snapshot.setBuildNumber( getBuildNumber( recessive ) + 1 );
- snapshot.setTimestamp( utcDateFormatter.format( new Date() ) );
-
- Versioning versioning = new Versioning();
- versioning.setSnapshot( snapshot );
- versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) );
- lastUpdated = versioning.getLastUpdated();
-
- metadata.setVersioning( versioning );
- }
- else
- {
- snapshot = metadata.getVersioning().getSnapshot();
- lastUpdated = metadata.getVersioning().getLastUpdated();
- }
-
- for ( Artifact artifact : artifacts )
- {
- String version = artifact.getVersion();
-
- if ( version.endsWith( SNAPSHOT ) )
- {
- String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
- version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
- }
-
- SnapshotVersion sv = new SnapshotVersion();
- sv.setClassifier( artifact.getClassifier() );
- sv.setExtension( artifact.getExtension() );
- sv.setVersion( version );
- sv.setUpdated( lastUpdated );
-
- versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
- }
-
- artifacts.clear();
-
- Versioning versioning = recessive.getVersioning();
- if ( versioning != null )
- {
- for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
- {
- String key = getKey( sv.getClassifier(), sv.getExtension() );
- if ( !versions.containsKey( key ) )
- {
- versions.put( key, sv );
- }
- }
- }
-
- if ( !legacyFormat )
- {
- metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
- }
- }
-
- private static int getBuildNumber( Metadata metadata )
- {
- int number = 0;
-
- Versioning versioning = metadata.getVersioning();
- if ( versioning != null )
- {
- Snapshot snapshot = versioning.getSnapshot();
- if ( snapshot != null && snapshot.getBuildNumber() > 0 )
- {
- number = snapshot.getBuildNumber();
- }
- }
-
- return number;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
deleted file mode 100644
index 8258966..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.deployment.DeployRequest;
-import org.eclipse.aether.impl.MetadataGenerator;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.util.ConfigUtils;
-
-/**
- * @author Benjamin Bentmann
- */
-class RemoteSnapshotMetadataGenerator
- implements MetadataGenerator
-{
-
- private final Map<Object, RemoteSnapshotMetadata> snapshots;
-
- private final boolean legacyFormat;
-
- public RemoteSnapshotMetadataGenerator( RepositorySystemSession session, DeployRequest request )
- {
- legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
-
- snapshots = new LinkedHashMap<>();
-
- /*
- * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
- * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the
- * same timestamp+buildno for the snapshot versions. Allowing the caller to pass in metadata from a previous
- * deployment allows to re-establish the association between the artifacts of the same project.
- */
- for ( Metadata metadata : request.getMetadata() )
- {
- if ( metadata instanceof RemoteSnapshotMetadata )
- {
- RemoteSnapshotMetadata snapshotMetadata = (RemoteSnapshotMetadata) metadata;
- snapshots.put( snapshotMetadata.getKey(), snapshotMetadata );
- }
- }
- }
-
- public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
- {
- for ( Artifact artifact : artifacts )
- {
- if ( artifact.isSnapshot() )
- {
- Object key = RemoteSnapshotMetadata.getKey( artifact );
- RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
- if ( snapshotMetadata == null )
- {
- snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat );
- snapshots.put( key, snapshotMetadata );
- }
- snapshotMetadata.bind( artifact );
- }
- }
-
- return snapshots.values();
- }
-
- public Artifact transformArtifact( Artifact artifact )
- {
- if ( artifact.isSnapshot() && artifact.getVersion().equals( artifact.getBaseVersion() ) )
- {
- Object key = RemoteSnapshotMetadata.getKey( artifact );
- RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
- if ( snapshotMetadata != null )
- {
- artifact = artifact.setVersion( snapshotMetadata.getExpandedVersion( artifact ) );
- }
- }
-
- return artifact;
- }
-
- public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
- {
- return Collections.emptyList();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
deleted file mode 100644
index 79ffaad..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.codehaus.plexus.component.annotations.Component;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.deployment.DeployRequest;
-import org.eclipse.aether.impl.MetadataGenerator;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.installation.InstallRequest;
-
-/**
- * @author Benjamin Bentmann
- */
-@Component( role = MetadataGeneratorFactory.class, hint = "snapshot" )
-public class SnapshotMetadataGeneratorFactory
- implements MetadataGeneratorFactory
-{
-
- public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request )
- {
- return new LocalSnapshotMetadataGenerator( session, request );
- }
-
- public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request )
- {
- return new RemoteSnapshotMetadataGenerator( session, request );
- }
-
- public float getPriority()
- {
- return 10;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
deleted file mode 100644
index f5e13be..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.ArtifactProperties;
-
-/**
- * @author Benjamin Bentmann
- */
-final class VersionsMetadata
- extends MavenMetadata
-{
-
- private final Artifact artifact;
-
- public VersionsMetadata( Artifact artifact )
- {
- super( createRepositoryMetadata( artifact ), null );
- this.artifact = artifact;
- }
-
- public VersionsMetadata( Artifact artifact, File file )
- {
- super( createRepositoryMetadata( artifact ), file );
- this.artifact = artifact;
- }
-
- private static Metadata createRepositoryMetadata( Artifact artifact )
- {
- Metadata metadata = new Metadata();
- metadata.setGroupId( artifact.getGroupId() );
- metadata.setArtifactId( artifact.getArtifactId() );
-
- Versioning versioning = new Versioning();
- versioning.addVersion( artifact.getBaseVersion() );
- if ( !artifact.isSnapshot() )
- {
- versioning.setRelease( artifact.getBaseVersion() );
- }
- if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) )
- {
- versioning.setLatest( artifact.getBaseVersion() );
- }
-
- metadata.setVersioning( versioning );
-
- return metadata;
- }
-
- @Override
- protected void merge( Metadata recessive )
- {
- Versioning versioning = metadata.getVersioning();
- versioning.updateTimestamp();
-
- if ( recessive.getVersioning() != null )
- {
- if ( versioning.getLatest() == null )
- {
- versioning.setLatest( recessive.getVersioning().getLatest() );
- }
- if ( versioning.getRelease() == null )
- {
- versioning.setRelease( recessive.getVersioning().getRelease() );
- }
-
- Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
- versions.addAll( versioning.getVersions() );
- versioning.setVersions( new ArrayList<>( versions ) );
- }
- }
-
- public Object getKey()
- {
- return getGroupId() + ':' + getArtifactId();
- }
-
- public static Object getKey( Artifact artifact )
- {
- return artifact.getGroupId() + ':' + artifact.getArtifactId();
- }
-
- public MavenMetadata setFile( File file )
- {
- return new VersionsMetadata( artifact, file );
- }
-
- public String getGroupId()
- {
- return artifact.getGroupId();
- }
-
- public String getArtifactId()
- {
- return artifact.getArtifactId();
- }
-
- public String getVersion()
- {
- return "";
- }
-
- public Nature getNature()
- {
- return artifact.isSnapshot() ? Nature.RELEASE_OR_SNAPSHOT : Nature.RELEASE;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
deleted file mode 100644
index 5173001..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.deployment.DeployRequest;
-import org.eclipse.aether.impl.MetadataGenerator;
-import org.eclipse.aether.installation.InstallRequest;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * @author Benjamin Bentmann
- */
-class VersionsMetadataGenerator
- implements MetadataGenerator
-{
-
- private Map<Object, VersionsMetadata> versions;
-
- private Map<Object, VersionsMetadata> processedVersions;
-
- public VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request )
- {
- this( session, request.getMetadata() );
- }
-
- public VersionsMetadataGenerator( RepositorySystemSession session, DeployRequest request )
- {
- this( session, request.getMetadata() );
- }
-
- private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas )
- {
- versions = new LinkedHashMap<>();
- processedVersions = new LinkedHashMap<>();
-
- /*
- * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
- * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the
- * same version index. Allowing the caller to pass in metadata from a previous deployment allows to re-establish
- * the association between the artifacts of the same project.
- */
- for ( Iterator<? extends Metadata> it = metadatas.iterator(); it.hasNext(); )
- {
- Metadata metadata = it.next();
- if ( metadata instanceof VersionsMetadata )
- {
- it.remove();
- VersionsMetadata versionsMetadata = (VersionsMetadata) metadata;
- processedVersions.put( versionsMetadata.getKey(), versionsMetadata );
- }
- }
- }
-
- public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
- {
- return Collections.emptyList();
- }
-
- public Artifact transformArtifact( Artifact artifact )
- {
- return artifact;
- }
-
- public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
- {
- for ( Artifact artifact : artifacts )
- {
- Object key = VersionsMetadata.getKey( artifact );
- if ( processedVersions.get( key ) == null )
- {
- VersionsMetadata versionsMetadata = versions.get( key );
- if ( versionsMetadata == null )
- {
- versionsMetadata = new VersionsMetadata( artifact );
- versions.put( key, versionsMetadata );
- }
- }
- }
-
- return versions.values();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
deleted file mode 100644
index 47ef360..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.codehaus.plexus.component.annotations.Component;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.deployment.DeployRequest;
-import org.eclipse.aether.impl.MetadataGenerator;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.installation.InstallRequest;
-
-/**
- * @author Benjamin Bentmann
- */
-@Component( role = MetadataGeneratorFactory.class, hint = "versions" )
-public class VersionsMetadataGeneratorFactory
- implements MetadataGeneratorFactory
-{
-
- public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request )
- {
- return new VersionsMetadataGenerator( session, request );
- }
-
- public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request )
- {
- return new VersionsMetadataGenerator( session, request );
- }
-
- public float getPriority()
- {
- return 5;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/package-info.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
deleted file mode 100644
index 5582cf7..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * <a href="http://www.eclipse.org/aether/">Aether</a> extensions for utilizing the Maven POM and Maven repository
- * metadata.
- */
-package org.apache.maven.repository.internal;
-
-/*
- * 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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/site/apt/index.apt b/maven-aether-provider/src/site/apt/index.apt
deleted file mode 100644
index 600ec41..0000000
--- a/maven-aether-provider/src/site/apt/index.apt
+++ /dev/null
@@ -1,33 +0,0 @@
-~~ 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.
-
- -----
- Introduction
- -----
- Herv� Boutemy
- -----
- 2012-09-29
- -----
-
-Maven Aether Provider
-
- Maven Aether Provider is an {{{http://www.eclipse.org/aether/}Aether}} extension to support
- Maven POMs and local+remote repositories.
-
- Main component is <<<MavenRepositorySystemUtils>>>
- ({{{./apidocs/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}javadoc}},
- {{{./xref/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}source}}).
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/site/site.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/site/site.xml b/maven-aether-provider/src/site/site.xml
deleted file mode 100644
index 3a16bf9..0000000
--- a/maven-aether-provider/src/site/site.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-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.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
- <body>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="JavaDocs" href="apidocs/index.html"/>
- <item name="Source Xref" href="xref/index.html"/>
- <!--item name="FAQ" href="faq.html"/-->
- </menu>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
-</project>
\ No newline at end of file
[14/15] maven git commit: [MNG-5600] Dependency management import
should support exclusions.
Posted by sc...@apache.org.
[MNG-5600] Dependency management import should support exclusions.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/0e0a3fb6
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/0e0a3fb6
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/0e0a3fb6
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 0e0a3fb663dacca1fa7edbd3e2c06a4ae35975f3
Parents: 2279f85
Author: Christian Schulte <sc...@apache.org>
Authored: Sun Jun 19 16:32:25 2016 +0200
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:19:41 2017 +0100
----------------------------------------------------------------------
.../model/building/DefaultModelBuilder.java | 59 +++++++++++++++-----
1 file changed, 45 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/0e0a3fb6/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 5ca1623..69e95ab 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -19,7 +19,16 @@ package org.apache.maven.model.building;
* under the License.
*/
-
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import org.apache.commons.lang3.Validate;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
@@ -28,6 +37,7 @@ import org.apache.maven.model.Activation;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.Exclusion;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
@@ -62,18 +72,6 @@ import org.apache.maven.model.superpom.SuperPomProvider;
import org.apache.maven.model.validation.ModelValidator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
import static org.apache.maven.model.building.Result.error;
import static org.apache.maven.model.building.Result.newResult;
@@ -1218,7 +1216,40 @@ public class DefaultModelBuilder
importMngt = new DependencyManagement();
}
- putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMngt );
+ // [MNG-5600] Dependency management import should support exclusions.
+ if ( !dependency.getExclusions().isEmpty() )
+ {
+ for ( final Exclusion exclusion : dependency.getExclusions() )
+ {
+ if ( exclusion.getGroupId() != null && exclusion.getArtifactId() != null )
+ {
+ for ( final Iterator<Dependency> dependencies = importMngt.getDependencies().iterator();
+ dependencies.hasNext(); )
+ {
+ final Dependency candidate = dependencies.next();
+
+ if ( ( exclusion.getGroupId().equals( "*" )
+ || exclusion.getGroupId().equals( candidate.getGroupId() ) )
+ && ( exclusion.getArtifactId().equals( "*" )
+ || exclusion.getArtifactId().equals( candidate.getArtifactId() ) ) )
+ {
+ // Dependency excluded from import.
+ dependencies.remove();
+ }
+ }
+ }
+ }
+
+ for ( final Dependency includedDependency : importMngt.getDependencies() )
+ {
+ includedDependency.getExclusions().addAll( dependency.getExclusions() );
+ }
+ }
+ else
+ {
+ // Only dependency managements without exclusion processing applied can be cached.
+ putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMngt );
+ }
}
if ( importMngts == null )
[05/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
new file mode 100644
index 0000000..0f31330
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
@@ -0,0 +1,415 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Relocation;
+import org.apache.maven.model.building.DefaultModelBuilderFactory;
+import org.apache.maven.model.building.DefaultModelBuildingRequest;
+import org.apache.maven.model.building.FileModelSource;
+import org.apache.maven.model.building.ModelBuilder;
+import org.apache.maven.model.building.ModelBuildingException;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.model.building.ModelProblem;
+import org.apache.maven.model.resolution.UnresolvableModelException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.eclipse.aether.RepositoryEvent;
+import org.eclipse.aether.RepositoryEvent.EventType;
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.ArtifactResolver;
+import org.eclipse.aether.impl.RemoteRepositoryManager;
+import org.eclipse.aether.impl.RepositoryEventDispatcher;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.resolution.ArtifactDescriptorException;
+import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
+import org.eclipse.aether.resolution.ArtifactDescriptorPolicyRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResolutionException;
+import org.eclipse.aether.resolution.VersionResult;
+import org.eclipse.aether.spi.locator.Service;
+import org.eclipse.aether.spi.locator.ServiceLocator;
+import org.eclipse.aether.spi.log.Logger;
+import org.eclipse.aether.spi.log.LoggerFactory;
+import org.eclipse.aether.spi.log.NullLoggerFactory;
+import org.eclipse.aether.transfer.ArtifactNotFoundException;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Named
+@Component( role = ArtifactDescriptorReader.class )
+public class DefaultArtifactDescriptorReader
+ implements ArtifactDescriptorReader, Service
+{
+
+ @SuppressWarnings( "unused" )
+ @Requirement( role = LoggerFactory.class )
+ private Logger logger = NullLoggerFactory.LOGGER;
+
+ @Requirement
+ private RemoteRepositoryManager remoteRepositoryManager;
+
+ @Requirement
+ private VersionResolver versionResolver;
+
+ @Requirement
+ private VersionRangeResolver versionRangeResolver;
+
+ @Requirement
+ private ArtifactResolver artifactResolver;
+
+ @Requirement
+ private RepositoryEventDispatcher repositoryEventDispatcher;
+
+ @Requirement
+ private ModelBuilder modelBuilder;
+
+ public DefaultArtifactDescriptorReader()
+ {
+ // enable no-arg constructor
+ }
+
+ @Inject
+ DefaultArtifactDescriptorReader( RemoteRepositoryManager remoteRepositoryManager, VersionResolver versionResolver,
+ ArtifactResolver artifactResolver, ModelBuilder modelBuilder,
+ RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
+ {
+ setRemoteRepositoryManager( remoteRepositoryManager );
+ setVersionResolver( versionResolver );
+ setArtifactResolver( artifactResolver );
+ setModelBuilder( modelBuilder );
+ setLoggerFactory( loggerFactory );
+ setRepositoryEventDispatcher( repositoryEventDispatcher );
+ }
+
+ public void initService( ServiceLocator locator )
+ {
+ setLoggerFactory( locator.getService( LoggerFactory.class ) );
+ setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
+ setVersionResolver( locator.getService( VersionResolver.class ) );
+ setVersionRangeResolver( locator.getService( VersionRangeResolver.class ) );
+ setArtifactResolver( locator.getService( ArtifactResolver.class ) );
+ setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
+ modelBuilder = locator.getService( ModelBuilder.class );
+ if ( modelBuilder == null )
+ {
+ setModelBuilder( new DefaultModelBuilderFactory().newInstance() );
+ }
+ }
+
+ public DefaultArtifactDescriptorReader setLoggerFactory( LoggerFactory loggerFactory )
+ {
+ this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
+ return this;
+ }
+
+ void setLogger( LoggerFactory loggerFactory )
+ {
+ // plexus support
+ setLoggerFactory( loggerFactory );
+ }
+
+ public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager )
+ {
+ this.remoteRepositoryManager = Validate.notNull( remoteRepositoryManager,
+ "remoteRepositoryManager cannot be null" );
+ return this;
+ }
+
+ public DefaultArtifactDescriptorReader setVersionResolver( VersionResolver versionResolver )
+ {
+ this.versionResolver = Validate.notNull( versionResolver, "versionResolver cannot be null" );
+ return this;
+ }
+
+ /** @since 3.2.2 */
+ public DefaultArtifactDescriptorReader setVersionRangeResolver( VersionRangeResolver versionRangeResolver )
+ {
+ this.versionRangeResolver = Validate.notNull( versionRangeResolver, "versionRangeResolver cannot be null" );
+ return this;
+ }
+
+ public DefaultArtifactDescriptorReader setArtifactResolver( ArtifactResolver artifactResolver )
+ {
+ this.artifactResolver = Validate.notNull( artifactResolver, "artifactResolver cannot be null" );
+ return this;
+ }
+
+ public DefaultArtifactDescriptorReader setRepositoryEventDispatcher(
+ RepositoryEventDispatcher repositoryEventDispatcher )
+ {
+ this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
+ "repositoryEventDispatcher cannot be null" );
+ return this;
+ }
+
+ public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder )
+ {
+ this.modelBuilder = Validate.notNull( modelBuilder, "modelBuilder cannot be null" );
+ return this;
+ }
+
+ public ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session,
+ ArtifactDescriptorRequest request )
+ throws ArtifactDescriptorException
+ {
+ ArtifactDescriptorResult result = new ArtifactDescriptorResult( request );
+
+ Model model = loadPom( session, request, result );
+ if ( model != null )
+ {
+ Map<String, Object> config = session.getConfigProperties();
+ ArtifactDescriptorReaderDelegate delegate =
+ (ArtifactDescriptorReaderDelegate) config.get( ArtifactDescriptorReaderDelegate.class.getName() );
+
+ if ( delegate == null )
+ {
+ delegate = new ArtifactDescriptorReaderDelegate();
+ }
+
+ delegate.populateResult( session, result, model );
+ }
+
+ return result;
+ }
+
+ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorRequest request,
+ ArtifactDescriptorResult result )
+ throws ArtifactDescriptorException
+ {
+ RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
+
+ Set<String> visited = new LinkedHashSet<>();
+ for ( Artifact a = request.getArtifact();; )
+ {
+ Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( a );
+ try
+ {
+ VersionRequest versionRequest =
+ new VersionRequest( a, request.getRepositories(), request.getRequestContext() );
+ versionRequest.setTrace( trace );
+ VersionResult versionResult = versionResolver.resolveVersion( session, versionRequest );
+
+ a = a.setVersion( versionResult.getVersion() );
+
+ versionRequest =
+ new VersionRequest( pomArtifact, request.getRepositories(), request.getRequestContext() );
+ versionRequest.setTrace( trace );
+ versionResult = versionResolver.resolveVersion( session, versionRequest );
+
+ pomArtifact = pomArtifact.setVersion( versionResult.getVersion() );
+ }
+ catch ( VersionResolutionException e )
+ {
+ result.addException( e );
+ throw new ArtifactDescriptorException( result );
+ }
+
+ if ( !visited.add( a.getGroupId() + ':' + a.getArtifactId() + ':' + a.getBaseVersion() ) )
+ {
+ RepositoryException exception =
+ new RepositoryException( "Artifact relocations form a cycle: " + visited );
+ invalidDescriptor( session, trace, a, exception );
+ if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 )
+ {
+ return null;
+ }
+ result.addException( exception );
+ throw new ArtifactDescriptorException( result );
+ }
+
+ ArtifactResult resolveResult;
+ try
+ {
+ ArtifactRequest resolveRequest =
+ new ArtifactRequest( pomArtifact, request.getRepositories(), request.getRequestContext() );
+ resolveRequest.setTrace( trace );
+ resolveResult = artifactResolver.resolveArtifact( session, resolveRequest );
+ pomArtifact = resolveResult.getArtifact();
+ result.setRepository( resolveResult.getRepository() );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ if ( e.getCause() instanceof ArtifactNotFoundException )
+ {
+ missingDescriptor( session, trace, a, (Exception) e.getCause() );
+ if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_MISSING ) != 0 )
+ {
+ return null;
+ }
+ }
+ result.addException( e );
+ throw new ArtifactDescriptorException( result );
+ }
+
+ Model model;
+
+ // hack: don't rebuild model if it was already loaded during reactor resolution
+ final WorkspaceReader workspace = session.getWorkspaceReader();
+ if ( workspace instanceof MavenWorkspaceReader )
+ {
+ model = ( (MavenWorkspaceReader) workspace ).findModel( pomArtifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+
+ try
+ {
+ ModelBuildingRequest modelRequest = new DefaultModelBuildingRequest();
+ modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
+ modelRequest.setProcessPlugins( false );
+ modelRequest.setTwoPhaseBuilding( false );
+ modelRequest.setSystemProperties( toProperties( session.getUserProperties(),
+ session.getSystemProperties() ) );
+ modelRequest.setModelCache( DefaultModelCache.newInstance( session ) );
+ modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ),
+ request.getRequestContext(), artifactResolver,
+ versionRangeResolver, remoteRepositoryManager,
+ request.getRepositories() ) );
+ if ( resolveResult.getRepository() instanceof WorkspaceRepository )
+ {
+ modelRequest.setPomFile( pomArtifact.getFile() );
+ }
+ else
+ {
+ modelRequest.setModelSource( new FileModelSource( pomArtifact.getFile() ) );
+ }
+
+ model = modelBuilder.build( modelRequest ).getEffectiveModel();
+ }
+ catch ( ModelBuildingException e )
+ {
+ for ( ModelProblem problem : e.getProblems() )
+ {
+ if ( problem.getException() instanceof UnresolvableModelException )
+ {
+ result.addException( problem.getException() );
+ throw new ArtifactDescriptorException( result );
+ }
+ }
+ invalidDescriptor( session, trace, a, e );
+ if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 )
+ {
+ return null;
+ }
+ result.addException( e );
+ throw new ArtifactDescriptorException( result );
+ }
+
+ Relocation relocation = getRelocation( model );
+
+ if ( relocation != null )
+ {
+ result.addRelocation( a );
+ a =
+ new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(),
+ relocation.getVersion() );
+ result.setArtifact( a );
+ }
+ else
+ {
+ return model;
+ }
+ }
+ }
+
+ private Properties toProperties( Map<String, String> dominant, Map<String, String> recessive )
+ {
+ Properties props = new Properties();
+ if ( recessive != null )
+ {
+ props.putAll( recessive );
+ }
+ if ( dominant != null )
+ {
+ props.putAll( dominant );
+ }
+ return props;
+ }
+
+ private Relocation getRelocation( Model model )
+ {
+ Relocation relocation = null;
+ DistributionManagement distMngt = model.getDistributionManagement();
+ if ( distMngt != null )
+ {
+ relocation = distMngt.getRelocation();
+ }
+ return relocation;
+ }
+
+ private void missingDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
+ Exception exception )
+ {
+ RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_MISSING );
+ event.setTrace( trace );
+ event.setArtifact( artifact );
+ event.setException( exception );
+
+ repositoryEventDispatcher.dispatch( event.build() );
+ }
+
+ private void invalidDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
+ Exception exception )
+ {
+ RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_INVALID );
+ event.setTrace( trace );
+ event.setArtifact( artifact );
+ event.setException( exception );
+
+ repositoryEventDispatcher.dispatch( event.build() );
+ }
+
+ private int getPolicy( RepositorySystemSession session, Artifact a, ArtifactDescriptorRequest request )
+ {
+ ArtifactDescriptorPolicy policy = session.getArtifactDescriptorPolicy();
+ if ( policy == null )
+ {
+ return ArtifactDescriptorPolicy.STRICT;
+ }
+ return policy.getPolicy( session, new ArtifactDescriptorPolicyRequest( a, request.getRequestContext() ) );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
new file mode 100644
index 0000000..f13495d
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
@@ -0,0 +1,119 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.model.building.ModelCache;
+import org.eclipse.aether.RepositoryCache;
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A model builder cache backed by the repository system cache.
+ *
+ * @author Benjamin Bentmann
+ */
+class DefaultModelCache
+ implements ModelCache
+{
+
+ private final RepositorySystemSession session;
+
+ private final RepositoryCache cache;
+
+ public static ModelCache newInstance( RepositorySystemSession session )
+ {
+ if ( session.getCache() == null )
+ {
+ return null;
+ }
+ else
+ {
+ return new DefaultModelCache( session );
+ }
+ }
+
+ private DefaultModelCache( RepositorySystemSession session )
+ {
+ this.session = session;
+ this.cache = session.getCache();
+ }
+
+ public Object get( String groupId, String artifactId, String version, String tag )
+ {
+ return cache.get( session, new Key( groupId, artifactId, version, tag ) );
+ }
+
+ public void put( String groupId, String artifactId, String version, String tag, Object data )
+ {
+ cache.put( session, new Key( groupId, artifactId, version, tag ), data );
+ }
+
+ static class Key
+ {
+
+ private final String groupId;
+
+ private final String artifactId;
+
+ private final String version;
+
+ private final String tag;
+
+ private final int hash;
+
+ public Key( String groupId, String artifactId, String version, String tag )
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.tag = tag;
+
+ int h = 17;
+ h = h * 31 + this.groupId.hashCode();
+ h = h * 31 + this.artifactId.hashCode();
+ h = h * 31 + this.version.hashCode();
+ h = h * 31 + this.tag.hashCode();
+ hash = h;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( null == obj || !getClass().equals( obj.getClass() ) )
+ {
+ return false;
+ }
+
+ Key that = (Key) obj;
+ return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
+ && version.equals( that.version ) && tag.equals( that.tag );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return hash;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
new file mode 100644
index 0000000..f344959
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
@@ -0,0 +1,229 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.FileModelSource;
+import org.apache.maven.model.building.ModelSource;
+import org.apache.maven.model.resolution.InvalidRepositoryException;
+import org.apache.maven.model.resolution.ModelResolver;
+import org.apache.maven.model.resolution.UnresolvableModelException;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.impl.ArtifactResolver;
+import org.eclipse.aether.impl.RemoteRepositoryManager;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+
+/**
+ * A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have
+ * been initially specified and repositories discovered in dependency POMs are recessively merged into the search chain.
+ *
+ * @author Benjamin Bentmann
+ * @see DefaultArtifactDescriptorReader
+ */
+class DefaultModelResolver
+ implements ModelResolver
+{
+
+ private final RepositorySystemSession session;
+
+ private final RequestTrace trace;
+
+ private final String context;
+
+ private List<RemoteRepository> repositories;
+
+ private final List<RemoteRepository> externalRepositories;
+
+ private final ArtifactResolver resolver;
+
+ private final VersionRangeResolver versionRangeResolver;
+
+ private final RemoteRepositoryManager remoteRepositoryManager;
+
+ private final Set<String> repositoryIds;
+
+ public DefaultModelResolver( RepositorySystemSession session, RequestTrace trace, String context,
+ ArtifactResolver resolver, VersionRangeResolver versionRangeResolver,
+ RemoteRepositoryManager remoteRepositoryManager, List<RemoteRepository> repositories )
+ {
+ this.session = session;
+ this.trace = trace;
+ this.context = context;
+ this.resolver = resolver;
+ this.versionRangeResolver = versionRangeResolver;
+ this.remoteRepositoryManager = remoteRepositoryManager;
+ this.repositories = repositories;
+ List<RemoteRepository> externalRepositories = new ArrayList<>();
+ externalRepositories.addAll( repositories );
+ this.externalRepositories = Collections.unmodifiableList( externalRepositories );
+
+ this.repositoryIds = new HashSet<>();
+ }
+
+ private DefaultModelResolver( DefaultModelResolver original )
+ {
+ this.session = original.session;
+ this.trace = original.trace;
+ this.context = original.context;
+ this.resolver = original.resolver;
+ this.versionRangeResolver = original.versionRangeResolver;
+ this.remoteRepositoryManager = original.remoteRepositoryManager;
+ this.repositories = new ArrayList<>( original.repositories );
+ this.externalRepositories = original.externalRepositories;
+ this.repositoryIds = new HashSet<>( original.repositoryIds );
+ }
+
+ @Override
+ public void addRepository( Repository repository )
+ throws InvalidRepositoryException
+ {
+ addRepository( repository, false );
+ }
+
+ @Override
+ public void addRepository( final Repository repository, boolean replace )
+ throws InvalidRepositoryException
+ {
+ if ( session.isIgnoreArtifactDescriptorRepositories() )
+ {
+ return;
+ }
+
+ if ( !repositoryIds.add( repository.getId() ) )
+ {
+ if ( !replace )
+ {
+ return;
+ }
+
+ removeMatchingRepository( repositories, repository.getId() );
+ }
+
+ List<RemoteRepository> newRepositories =
+ Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );
+
+ this.repositories =
+ remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true );
+ }
+
+ private static void removeMatchingRepository( Iterable<RemoteRepository> repositories, final String id )
+ {
+ Iterables.removeIf( repositories, new Predicate<RemoteRepository>()
+ {
+ @Override
+ public boolean apply( RemoteRepository remoteRepository )
+ {
+ return remoteRepository.getId().equals( id );
+ }
+ } );
+ }
+
+ @Override
+ public ModelResolver newCopy()
+ {
+ return new DefaultModelResolver( this );
+ }
+
+ @Override
+ public ModelSource resolveModel( String groupId, String artifactId, String version )
+ throws UnresolvableModelException
+ {
+ Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
+
+ try
+ {
+ ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
+ request.setTrace( trace );
+ pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
+ }
+
+ File pomFile = pomArtifact.getFile();
+
+ return new FileModelSource( pomFile );
+ }
+
+ public ModelSource resolveModel( Parent parent )
+ throws UnresolvableModelException
+ {
+ Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
+ parent.getVersion() );
+
+ VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
+ versionRangeRequest.setTrace( trace );
+
+ try
+ {
+ VersionRangeResult versionRangeResult =
+ versionRangeResolver.resolveVersionRange( session, versionRangeRequest );
+
+ if ( versionRangeResult.getHighestVersion() == null )
+ {
+ throw new UnresolvableModelException( "No versions matched the requested range '" + parent.getVersion()
+ + "'", parent.getGroupId(), parent.getArtifactId(),
+ parent.getVersion() );
+
+ }
+
+ if ( versionRangeResult.getVersionConstraint() != null
+ && versionRangeResult.getVersionConstraint().getRange() != null
+ && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
+ {
+ throw new UnresolvableModelException( "The requested version range '" + parent.getVersion()
+ + "' does not specify an upper bound", parent.getGroupId(),
+ parent.getArtifactId(), parent.getVersion() );
+
+ }
+
+ parent.setVersion( versionRangeResult.getHighestVersion().toString() );
+ }
+ catch ( VersionRangeResolutionException e )
+ {
+ throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
+ parent.getVersion(), e );
+
+ }
+
+ return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
new file mode 100644
index 0000000..ddd3e97
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
@@ -0,0 +1,307 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.commons.lang3.Validate;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.IOUtil;
+import org.eclipse.aether.RepositoryEvent;
+import org.eclipse.aether.RepositoryEvent.EventType;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.SyncContext;
+import org.eclipse.aether.impl.MetadataResolver;
+import org.eclipse.aether.impl.RepositoryEventDispatcher;
+import org.eclipse.aether.impl.SyncContextFactory;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.metadata.DefaultMetadata;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.resolution.MetadataRequest;
+import org.eclipse.aether.resolution.MetadataResult;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.spi.locator.Service;
+import org.eclipse.aether.spi.locator.ServiceLocator;
+import org.eclipse.aether.spi.log.Logger;
+import org.eclipse.aether.spi.log.LoggerFactory;
+import org.eclipse.aether.spi.log.NullLoggerFactory;
+import org.eclipse.aether.util.version.GenericVersionScheme;
+import org.eclipse.aether.version.InvalidVersionSpecificationException;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+import org.eclipse.aether.version.VersionScheme;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Named
+@Component( role = VersionRangeResolver.class )
+public class DefaultVersionRangeResolver
+ implements VersionRangeResolver, Service
+{
+
+ private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
+
+ @SuppressWarnings( "unused" )
+ @Requirement( role = LoggerFactory.class )
+ private Logger logger = NullLoggerFactory.LOGGER;
+
+ @Requirement
+ private MetadataResolver metadataResolver;
+
+ @Requirement
+ private SyncContextFactory syncContextFactory;
+
+ @Requirement
+ private RepositoryEventDispatcher repositoryEventDispatcher;
+
+ public DefaultVersionRangeResolver()
+ {
+ // enable default constructor
+ }
+
+ @Inject
+ DefaultVersionRangeResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory,
+ RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
+ {
+ setMetadataResolver( metadataResolver );
+ setSyncContextFactory( syncContextFactory );
+ setLoggerFactory( loggerFactory );
+ setRepositoryEventDispatcher( repositoryEventDispatcher );
+ }
+
+ public void initService( ServiceLocator locator )
+ {
+ setLoggerFactory( locator.getService( LoggerFactory.class ) );
+ setMetadataResolver( locator.getService( MetadataResolver.class ) );
+ setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
+ setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
+ }
+
+ public DefaultVersionRangeResolver setLoggerFactory( LoggerFactory loggerFactory )
+ {
+ this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
+ return this;
+ }
+
+ void setLogger( LoggerFactory loggerFactory )
+ {
+ // plexus support
+ setLoggerFactory( loggerFactory );
+ }
+
+ public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver )
+ {
+ this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
+ return this;
+ }
+
+ public DefaultVersionRangeResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
+ {
+ this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
+ return this;
+ }
+
+ public DefaultVersionRangeResolver setRepositoryEventDispatcher(
+ RepositoryEventDispatcher repositoryEventDispatcher )
+ {
+ this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
+ "repositoryEventDispatcher cannot be null" );
+ return this;
+ }
+
+ public VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
+ throws VersionRangeResolutionException
+ {
+ VersionRangeResult result = new VersionRangeResult( request );
+
+ VersionScheme versionScheme = new GenericVersionScheme();
+
+ VersionConstraint versionConstraint;
+ try
+ {
+ versionConstraint = versionScheme.parseVersionConstraint( request.getArtifact().getVersion() );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ result.addException( e );
+ throw new VersionRangeResolutionException( result );
+ }
+
+ result.setVersionConstraint( versionConstraint );
+
+ if ( versionConstraint.getRange() == null )
+ {
+ result.addVersion( versionConstraint.getVersion() );
+ }
+ else
+ {
+ Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
+
+ List<Version> versions = new ArrayList<>();
+ for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
+ {
+ try
+ {
+ Version ver = versionScheme.parseVersion( v.getKey() );
+ if ( versionConstraint.containsVersion( ver ) )
+ {
+ versions.add( ver );
+ result.setRepository( ver, v.getValue() );
+ }
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ result.addException( e );
+ }
+ }
+
+ Collections.sort( versions );
+ result.setVersions( versions );
+ }
+
+ return result;
+ }
+
+ private Map<String, ArtifactRepository> getVersions( RepositorySystemSession session, VersionRangeResult result,
+ VersionRangeRequest request )
+ {
+ RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
+
+ Map<String, ArtifactRepository> versionIndex = new HashMap<>();
+
+ Metadata metadata =
+ new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(),
+ MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
+
+ List<MetadataRequest> metadataRequests = new ArrayList<>( request.getRepositories().size() );
+
+ metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
+
+ for ( RemoteRepository repository : request.getRepositories() )
+ {
+ MetadataRequest metadataRequest = new MetadataRequest( metadata, repository, request.getRequestContext() );
+ metadataRequest.setDeleteLocalCopyIfMissing( true );
+ metadataRequest.setTrace( trace );
+ metadataRequests.add( metadataRequest );
+ }
+
+ List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
+
+ WorkspaceReader workspace = session.getWorkspaceReader();
+ if ( workspace != null )
+ {
+ List<String> versions = workspace.findVersions( request.getArtifact() );
+ for ( String version : versions )
+ {
+ versionIndex.put( version, workspace.getRepository() );
+ }
+ }
+
+ for ( MetadataResult metadataResult : metadataResults )
+ {
+ result.addException( metadataResult.getException() );
+
+ ArtifactRepository repository = metadataResult.getRequest().getRepository();
+ if ( repository == null )
+ {
+ repository = session.getLocalRepository();
+ }
+
+ Versioning versioning = readVersions( session, trace, metadataResult.getMetadata(), repository, result );
+ for ( String version : versioning.getVersions() )
+ {
+ if ( !versionIndex.containsKey( version ) )
+ {
+ versionIndex.put( version, repository );
+ }
+ }
+ }
+
+ return versionIndex;
+ }
+
+ private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
+ ArtifactRepository repository, VersionRangeResult result )
+ {
+ Versioning versioning = null;
+
+ FileInputStream fis = null;
+ try
+ {
+ if ( metadata != null )
+ {
+
+ try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
+ {
+ syncContext.acquire( null, Collections.singleton( metadata ) );
+
+ if ( metadata.getFile() != null && metadata.getFile().exists() )
+ {
+ fis = new FileInputStream( metadata.getFile() );
+ org.apache.maven.artifact.repository.metadata.Metadata m =
+ new MetadataXpp3Reader().read( fis, false );
+ versioning = m.getVersioning();
+ }
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ invalidMetadata( session, trace, metadata, repository, e );
+ result.addException( e );
+ }
+ finally
+ {
+ IOUtil.close( fis );
+ }
+
+ return ( versioning != null ) ? versioning : new Versioning();
+ }
+
+ private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
+ ArtifactRepository repository, Exception exception )
+ {
+ RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID );
+ event.setTrace( trace );
+ event.setMetadata( metadata );
+ event.setException( exception );
+ event.setRepository( repository );
+
+ repositoryEventDispatcher.dispatch( event.build() );
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
new file mode 100644
index 0000000..2b0890b
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
@@ -0,0 +1,617 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.commons.lang3.Validate;
+import org.apache.maven.artifact.repository.metadata.Snapshot;
+import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.eclipse.aether.RepositoryCache;
+import org.eclipse.aether.RepositoryEvent;
+import org.eclipse.aether.RepositoryEvent.EventType;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.SyncContext;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.MetadataResolver;
+import org.eclipse.aether.impl.RepositoryEventDispatcher;
+import org.eclipse.aether.impl.SyncContextFactory;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.internal.impl.CacheUtils;
+import org.eclipse.aether.metadata.DefaultMetadata;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.resolution.MetadataRequest;
+import org.eclipse.aether.resolution.MetadataResult;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResolutionException;
+import org.eclipse.aether.resolution.VersionResult;
+import org.eclipse.aether.spi.locator.Service;
+import org.eclipse.aether.spi.locator.ServiceLocator;
+import org.eclipse.aether.spi.log.Logger;
+import org.eclipse.aether.spi.log.LoggerFactory;
+import org.eclipse.aether.spi.log.NullLoggerFactory;
+import org.eclipse.aether.util.ConfigUtils;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Named
+@Component( role = VersionResolver.class )
+public class DefaultVersionResolver
+ implements VersionResolver, Service
+{
+
+ private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
+
+ private static final String RELEASE = "RELEASE";
+
+ private static final String LATEST = "LATEST";
+
+ private static final String SNAPSHOT = "SNAPSHOT";
+
+ @SuppressWarnings( "unused" )
+ @Requirement( role = LoggerFactory.class )
+ private Logger logger = NullLoggerFactory.LOGGER;
+
+ @Requirement
+ private MetadataResolver metadataResolver;
+
+ @Requirement
+ private SyncContextFactory syncContextFactory;
+
+ @Requirement
+ private RepositoryEventDispatcher repositoryEventDispatcher;
+
+ public DefaultVersionResolver()
+ {
+ // enable no-arg constructor
+ }
+
+ @Inject
+ DefaultVersionResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory,
+ RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
+ {
+ setMetadataResolver( metadataResolver );
+ setSyncContextFactory( syncContextFactory );
+ setLoggerFactory( loggerFactory );
+ setRepositoryEventDispatcher( repositoryEventDispatcher );
+ }
+
+ public void initService( ServiceLocator locator )
+ {
+ setLoggerFactory( locator.getService( LoggerFactory.class ) );
+ setMetadataResolver( locator.getService( MetadataResolver.class ) );
+ setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
+ setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
+ }
+
+ public DefaultVersionResolver setLoggerFactory( LoggerFactory loggerFactory )
+ {
+ this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
+ return this;
+ }
+
+ void setLogger( LoggerFactory loggerFactory )
+ {
+ // plexus support
+ setLoggerFactory( loggerFactory );
+ }
+
+ public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver )
+ {
+ this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
+ return this;
+ }
+
+ public DefaultVersionResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
+ {
+ this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
+ return this;
+ }
+
+ public DefaultVersionResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
+ {
+ this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
+ "repositoryEventDispatcher cannot be null" );
+ return this;
+ }
+
+ public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
+ throws VersionResolutionException
+ {
+ RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
+
+ Artifact artifact = request.getArtifact();
+
+ String version = artifact.getVersion();
+
+ VersionResult result = new VersionResult( request );
+
+ Key cacheKey = null;
+ RepositoryCache cache = session.getCache();
+ if ( cache != null && !ConfigUtils.getBoolean( session, false, "aether.versionResolver.noCache" ) )
+ {
+ cacheKey = new Key( session, request );
+
+ Object obj = cache.get( session, cacheKey );
+ if ( obj instanceof Record )
+ {
+ Record record = (Record) obj;
+ result.setVersion( record.version );
+ result.setRepository(
+ CacheUtils.getRepository( session, request.getRepositories(), record.repoClass, record.repoId ) );
+ return result;
+ }
+ }
+
+ Metadata metadata;
+
+ if ( RELEASE.equals( version ) )
+ {
+ metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
+ Metadata.Nature.RELEASE );
+ }
+ else if ( LATEST.equals( version ) )
+ {
+ metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
+ Metadata.Nature.RELEASE_OR_SNAPSHOT );
+ }
+ else if ( version.endsWith( SNAPSHOT ) )
+ {
+ WorkspaceReader workspace = session.getWorkspaceReader();
+ if ( workspace != null && workspace.findVersions( artifact ).contains( version ) )
+ {
+ metadata = null;
+ result.setRepository( workspace.getRepository() );
+ }
+ else
+ {
+ metadata =
+ new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML,
+ Metadata.Nature.SNAPSHOT );
+ }
+ }
+ else
+ {
+ metadata = null;
+ }
+
+ if ( metadata == null )
+ {
+ result.setVersion( version );
+ }
+ else
+ {
+ List<MetadataRequest> metadataReqs = new ArrayList<>( request.getRepositories().size() );
+
+ metadataReqs.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
+
+ for ( RemoteRepository repository : request.getRepositories() )
+ {
+ MetadataRequest metadataRequest =
+ new MetadataRequest( metadata, repository, request.getRequestContext() );
+ metadataRequest.setDeleteLocalCopyIfMissing( true );
+ metadataRequest.setFavorLocalRepository( true );
+ metadataRequest.setTrace( trace );
+ metadataReqs.add( metadataRequest );
+ }
+
+ List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataReqs );
+
+ Map<String, VersionInfo> infos = new HashMap<>();
+
+ for ( MetadataResult metadataResult : metadataResults )
+ {
+ result.addException( metadataResult.getException() );
+
+ ArtifactRepository repository = metadataResult.getRequest().getRepository();
+ if ( repository == null )
+ {
+ repository = session.getLocalRepository();
+ }
+
+ Versioning v = readVersions( session, trace, metadataResult.getMetadata(), repository, result );
+ merge( artifact, infos, v, repository );
+ }
+
+ if ( RELEASE.equals( version ) )
+ {
+ resolve( result, infos, RELEASE );
+ }
+ else if ( LATEST.equals( version ) )
+ {
+ if ( !resolve( result, infos, LATEST ) )
+ {
+ resolve( result, infos, RELEASE );
+ }
+
+ if ( result.getVersion() != null && result.getVersion().endsWith( SNAPSHOT ) )
+ {
+ VersionRequest subRequest = new VersionRequest();
+ subRequest.setArtifact( artifact.setVersion( result.getVersion() ) );
+ if ( result.getRepository() instanceof RemoteRepository )
+ {
+ RemoteRepository r = (RemoteRepository) result.getRepository();
+ subRequest.setRepositories( Collections.singletonList( r ) );
+ }
+ else
+ {
+ subRequest.setRepositories( request.getRepositories() );
+ }
+ VersionResult subResult = resolveVersion( session, subRequest );
+ result.setVersion( subResult.getVersion() );
+ result.setRepository( subResult.getRepository() );
+ for ( Exception exception : subResult.getExceptions() )
+ {
+ result.addException( exception );
+ }
+ }
+ }
+ else
+ {
+ String key = SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() );
+ merge( infos, SNAPSHOT, key );
+ if ( !resolve( result, infos, key ) )
+ {
+ result.setVersion( version );
+ }
+ }
+
+ if ( StringUtils.isEmpty( result.getVersion() ) )
+ {
+ throw new VersionResolutionException( result );
+ }
+ }
+
+ if ( cacheKey != null && metadata != null && isSafelyCacheable( session, artifact ) )
+ {
+ cache.put( session, cacheKey, new Record( result.getVersion(), result.getRepository() ) );
+ }
+
+ return result;
+ }
+
+ private boolean resolve( VersionResult result, Map<String, VersionInfo> infos, String key )
+ {
+ VersionInfo info = infos.get( key );
+ if ( info != null )
+ {
+ result.setVersion( info.version );
+ result.setRepository( info.repository );
+ }
+ return info != null;
+ }
+
+ private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
+ ArtifactRepository repository, VersionResult result )
+ {
+ Versioning versioning = null;
+
+ FileInputStream fis = null;
+ try
+ {
+ if ( metadata != null )
+ {
+
+ try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
+ {
+ syncContext.acquire( null, Collections.singleton( metadata ) );
+
+ if ( metadata.getFile() != null && metadata.getFile().exists() )
+ {
+ fis = new FileInputStream( metadata.getFile() );
+ org.apache.maven.artifact.repository.metadata.Metadata m =
+ new MetadataXpp3Reader().read( fis, false );
+ versioning = m.getVersioning();
+
+ /*
+ * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
+ * of the local repository. This is especially troublesome during snapshot resolution so we try
+ * to handle that gracefully.
+ */
+ if ( versioning != null && repository instanceof LocalRepository )
+ {
+ if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
+ {
+ Versioning repaired = new Versioning();
+ repaired.setLastUpdated( versioning.getLastUpdated() );
+ Snapshot snapshot = new Snapshot();
+ snapshot.setLocalCopy( true );
+ repaired.setSnapshot( snapshot );
+ versioning = repaired;
+
+ throw new IOException( "Snapshot information corrupted with remote repository data"
+ + ", please verify that no remote repository uses the id '"
+ + repository.getId() + "'" );
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ invalidMetadata( session, trace, metadata, repository, e );
+ result.addException( e );
+ }
+ finally
+ {
+ IOUtil.close( fis );
+ }
+
+ return ( versioning != null ) ? versioning : new Versioning();
+ }
+
+ private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
+ ArtifactRepository repository, Exception exception )
+ {
+ RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID );
+ event.setTrace( trace );
+ event.setMetadata( metadata );
+ event.setException( exception );
+ event.setRepository( repository );
+
+ repositoryEventDispatcher.dispatch( event.build() );
+ }
+
+ private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
+ ArtifactRepository repository )
+ {
+ if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
+ {
+ merge( RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository );
+ }
+
+ if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
+ {
+ merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
+ }
+
+ for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
+ {
+ if ( StringUtils.isNotEmpty( sv.getVersion() ) )
+ {
+ String key = getKey( sv.getClassifier(), sv.getExtension() );
+ merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
+ }
+ }
+
+ Snapshot snapshot = versioning.getSnapshot();
+ if ( snapshot != null && versioning.getSnapshotVersions().isEmpty() )
+ {
+ String version = artifact.getVersion();
+ if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
+ {
+ String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
+ version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
+ }
+ merge( SNAPSHOT, infos, versioning.getLastUpdated(), version, repository );
+ }
+ }
+
+ private void merge( String key, Map<String, VersionInfo> infos, String timestamp, String version,
+ ArtifactRepository repository )
+ {
+ VersionInfo info = infos.get( key );
+ if ( info == null )
+ {
+ info = new VersionInfo( timestamp, version, repository );
+ infos.put( key, info );
+ }
+ else if ( info.isOutdated( timestamp ) )
+ {
+ info.version = version;
+ info.repository = repository;
+ info.timestamp = timestamp;
+ }
+ }
+
+ private void merge( Map<String, VersionInfo> infos, String srcKey, String dstKey )
+ {
+ VersionInfo srcInfo = infos.get( srcKey );
+ VersionInfo dstInfo = infos.get( dstKey );
+
+ if ( dstInfo == null || ( srcInfo != null && dstInfo.isOutdated( srcInfo.timestamp )
+ && srcInfo.repository != dstInfo.repository ) )
+ {
+ infos.put( dstKey, srcInfo );
+ }
+ }
+
+ private String getKey( String classifier, String extension )
+ {
+ return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
+ }
+
+ private boolean isSafelyCacheable( RepositorySystemSession session, Artifact artifact )
+ {
+ /*
+ * The workspace/reactor is in flux so we better not assume definitive information for any of its
+ * artifacts/projects.
+ */
+
+ WorkspaceReader workspace = session.getWorkspaceReader();
+ if ( workspace == null )
+ {
+ return true;
+ }
+
+ Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( artifact );
+
+ return workspace.findArtifact( pomArtifact ) == null;
+ }
+
+ private static class VersionInfo
+ {
+
+ String timestamp;
+
+ String version;
+
+ ArtifactRepository repository;
+
+ public VersionInfo( String timestamp, String version, ArtifactRepository repository )
+ {
+ this.timestamp = ( timestamp != null ) ? timestamp : "";
+ this.version = version;
+ this.repository = repository;
+ }
+
+ public boolean isOutdated( String timestamp )
+ {
+ return timestamp != null && timestamp.compareTo( this.timestamp ) > 0;
+ }
+
+ }
+
+ private static class Key
+ {
+
+ private final String groupId;
+
+ private final String artifactId;
+
+ private final String classifier;
+
+ private final String extension;
+
+ private final String version;
+
+ private final String context;
+
+ private final File localRepo;
+
+ private final WorkspaceRepository workspace;
+
+ private final List<RemoteRepository> repositories;
+
+ private final int hashCode;
+
+ public Key( RepositorySystemSession session, VersionRequest request )
+ {
+ Artifact artifact = request.getArtifact();
+ groupId = artifact.getGroupId();
+ artifactId = artifact.getArtifactId();
+ classifier = artifact.getClassifier();
+ extension = artifact.getExtension();
+ version = artifact.getVersion();
+ localRepo = session.getLocalRepository().getBasedir();
+ workspace = CacheUtils.getWorkspace( session );
+ repositories = new ArrayList<>( request.getRepositories().size() );
+ boolean repoMan = false;
+ for ( RemoteRepository repository : request.getRepositories() )
+ {
+ if ( repository.isRepositoryManager() )
+ {
+ repoMan = true;
+ repositories.addAll( repository.getMirroredRepositories() );
+ }
+ else
+ {
+ repositories.add( repository );
+ }
+ }
+ context = repoMan ? request.getRequestContext() : "";
+
+ int hash = 17;
+ hash = hash * 31 + groupId.hashCode();
+ hash = hash * 31 + artifactId.hashCode();
+ hash = hash * 31 + classifier.hashCode();
+ hash = hash * 31 + extension.hashCode();
+ hash = hash * 31 + version.hashCode();
+ hash = hash * 31 + localRepo.hashCode();
+ hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
+ hashCode = hash;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( obj == this )
+ {
+ return true;
+ }
+ else if ( obj == null || !getClass().equals( obj.getClass() ) )
+ {
+ return false;
+ }
+
+ Key that = (Key) obj;
+ return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && classifier.equals(
+ that.classifier ) && extension.equals( that.extension ) && version.equals( that.version )
+ && context.equals( that.context ) && localRepo.equals( that.localRepo )
+ && CacheUtils.eq( workspace, that.workspace )
+ && CacheUtils.repositoriesEquals( repositories, that.repositories );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+ }
+
+ private static class Record
+ {
+ final String version;
+
+ final String repoId;
+
+ final Class<?> repoClass;
+
+ public Record( String version, ArtifactRepository repository )
+ {
+ this.version = version;
+ if ( repository != null )
+ {
+ repoId = repository.getId();
+ repoClass = repository.getClass();
+ }
+ else
+ {
+ repoId = null;
+ repoClass = null;
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
new file mode 100644
index 0000000..a572010
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
@@ -0,0 +1,163 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.Snapshot;
+import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * @author Benjamin Bentmann
+ */
+final class LocalSnapshotMetadata
+ extends MavenMetadata
+{
+
+ private final Collection<Artifact> artifacts = new ArrayList<>();
+
+ private final boolean legacyFormat;
+
+ public LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat )
+ {
+ super( createMetadata( artifact, legacyFormat ), null );
+ this.legacyFormat = legacyFormat;
+ }
+
+ public LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
+ {
+ super( metadata, file );
+ this.legacyFormat = legacyFormat;
+ }
+
+ private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
+ {
+ Snapshot snapshot = new Snapshot();
+ snapshot.setLocalCopy( true );
+ Versioning versioning = new Versioning();
+ versioning.setSnapshot( snapshot );
+
+ Metadata metadata = new Metadata();
+ metadata.setVersioning( versioning );
+ metadata.setGroupId( artifact.getGroupId() );
+ metadata.setArtifactId( artifact.getArtifactId() );
+ metadata.setVersion( artifact.getBaseVersion() );
+
+ if ( !legacyFormat )
+ {
+ metadata.setModelVersion( "1.1.0" );
+ }
+
+ return metadata;
+ }
+
+ public void bind( Artifact artifact )
+ {
+ artifacts.add( artifact );
+ }
+
+ public MavenMetadata setFile( File file )
+ {
+ return new LocalSnapshotMetadata( metadata, file, legacyFormat );
+ }
+
+ public Object getKey()
+ {
+ return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
+ }
+
+ public static Object getKey( Artifact artifact )
+ {
+ return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
+ }
+
+ @Override
+ protected void merge( Metadata recessive )
+ {
+ metadata.getVersioning().updateTimestamp();
+
+ if ( !legacyFormat )
+ {
+ String lastUpdated = metadata.getVersioning().getLastUpdated();
+
+ Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
+
+ for ( Artifact artifact : artifacts )
+ {
+ SnapshotVersion sv = new SnapshotVersion();
+ sv.setClassifier( artifact.getClassifier() );
+ sv.setExtension( artifact.getExtension() );
+ sv.setVersion( getVersion() );
+ sv.setUpdated( lastUpdated );
+ versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
+ }
+
+ Versioning versioning = recessive.getVersioning();
+ if ( versioning != null )
+ {
+ for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
+ {
+ String key = getKey( sv.getClassifier(), sv.getExtension() );
+ if ( !versions.containsKey( key ) )
+ {
+ versions.put( key, sv );
+ }
+ }
+ }
+
+ metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
+ }
+
+ artifacts.clear();
+ }
+
+ private String getKey( String classifier, String extension )
+ {
+ return classifier + ':' + extension;
+ }
+
+ public String getGroupId()
+ {
+ return metadata.getGroupId();
+ }
+
+ public String getArtifactId()
+ {
+ return metadata.getArtifactId();
+ }
+
+ public String getVersion()
+ {
+ return metadata.getVersion();
+ }
+
+ public Nature getNature()
+ {
+ return Nature.SNAPSHOT;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
new file mode 100644
index 0000000..072ba66
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
@@ -0,0 +1,82 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.MetadataGenerator;
+import org.eclipse.aether.installation.InstallRequest;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.util.ConfigUtils;
+
+/**
+ * @author Benjamin Bentmann
+ */
+class LocalSnapshotMetadataGenerator
+ implements MetadataGenerator
+{
+
+ private Map<Object, LocalSnapshotMetadata> snapshots;
+
+ private final boolean legacyFormat;
+
+ public LocalSnapshotMetadataGenerator( RepositorySystemSession session, InstallRequest request )
+ {
+ legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
+
+ snapshots = new LinkedHashMap<>();
+ }
+
+ public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
+ {
+ for ( Artifact artifact : artifacts )
+ {
+ if ( artifact.isSnapshot() )
+ {
+ Object key = LocalSnapshotMetadata.getKey( artifact );
+ LocalSnapshotMetadata snapshotMetadata = snapshots.get( key );
+ if ( snapshotMetadata == null )
+ {
+ snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat );
+ snapshots.put( key, snapshotMetadata );
+ }
+ snapshotMetadata.bind( artifact );
+ }
+ }
+
+ return Collections.emptyList();
+ }
+
+ public Artifact transformArtifact( Artifact artifact )
+ {
+ return artifact;
+ }
+
+ public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
+ {
+ return snapshots.values();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
new file mode 100644
index 0000000..41e98aa
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java
@@ -0,0 +1,80 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.model.building.DefaultModelBuilderFactory;
+import org.apache.maven.model.building.ModelBuilder;
+import org.eclipse.aether.impl.AetherModule;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.name.Names;
+
+/**
+ * @deprecated As of Maven Resolver 1.0.3, please use class {@link MavenResolverModule}.
+ */
+@Deprecated
+public final class MavenAetherModule
+ extends AbstractModule
+{
+
+ @Override
+ protected void configure()
+ {
+ install( new AetherModule() );
+ bind( ArtifactDescriptorReader.class ) //
+ .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
+ bind( VersionResolver.class ) //
+ .to( DefaultVersionResolver.class ).in( Singleton.class );
+ bind( VersionRangeResolver.class ) //
+ .to( DefaultVersionRangeResolver.class ).in( Singleton.class );
+ bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) //
+ .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
+ bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) //
+ .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
+ bind( ModelBuilder.class ) //
+ .toInstance( new DefaultModelBuilderFactory().newInstance() );
+ }
+
+ @Provides
+ @Singleton
+ Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories( @Named( "snapshot" )
+ MetadataGeneratorFactory snapshot,
+ @Named( "versions" )
+ MetadataGeneratorFactory versions )
+ {
+ Set<MetadataGeneratorFactory> factories = new HashSet<>();
+ factories.add( snapshot );
+ factories.add( versions );
+ return Collections.unmodifiableSet( factories );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
new file mode 100644
index 0000000..aef44f6
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
@@ -0,0 +1,137 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.metadata.AbstractMetadata;
+import org.eclipse.aether.metadata.MergeableMetadata;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * @author Benjamin Bentmann
+ */
+abstract class MavenMetadata
+ extends AbstractMetadata
+ implements MergeableMetadata
+{
+
+ static final String MAVEN_METADATA_XML = "maven-metadata.xml";
+
+ private final File file;
+
+ protected Metadata metadata;
+
+ private boolean merged;
+
+ protected MavenMetadata( Metadata metadata, File file )
+ {
+ this.metadata = metadata;
+ this.file = file;
+ }
+
+ public String getType()
+ {
+ return MAVEN_METADATA_XML;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void merge( File existing, File result )
+ throws RepositoryException
+ {
+ Metadata recessive = read( existing );
+
+ merge( recessive );
+
+ write( result, metadata );
+
+ merged = true;
+ }
+
+ public boolean isMerged()
+ {
+ return merged;
+ }
+
+ protected abstract void merge( Metadata recessive );
+
+ static Metadata read( File metadataFile )
+ throws RepositoryException
+ {
+ if ( metadataFile.length() <= 0 )
+ {
+ return new Metadata();
+ }
+
+ try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
+ {
+ return new MetadataXpp3Reader().read( reader, false );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryException( "Could not read metadata " + metadataFile + ": " + e.getMessage(), e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new RepositoryException( "Could not parse metadata " + metadataFile + ": " + e.getMessage(), e );
+ }
+ }
+
+ private void write( File metadataFile, Metadata metadata )
+ throws RepositoryException
+ {
+ metadataFile.getParentFile().mkdirs();
+ try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) )
+ {
+ new MetadataXpp3Writer().write( writer, metadata );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e );
+ }
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public org.eclipse.aether.metadata.Metadata setProperties( Map<String, String> properties )
+ {
+ return this;
+ }
+
+}
[15/15] maven git commit: [MNG-4463] Dependency management import
should support version ranges.
Posted by sc...@apache.org.
[MNG-4463] Dependency management import should support version ranges.
o Extended the 'ModelResolver' interface to support resolving 'Dependency's
in addition to 'Parent's.
Closes #64 without merging. ITs are pending to be committed.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/086ebf06
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/086ebf06
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/086ebf06
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 086ebf0682399c66a268b3f185f71f45a2383815
Parents: 9353ad7
Author: Christian Schulte <sc...@apache.org>
Authored: Sat Jan 30 19:17:34 2016 +0100
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:19:41 2017 +0100
----------------------------------------------------------------------
.../maven/project/ProjectModelResolver.java | 82 +++++++++++++++----
.../model/building/DefaultModelBuilder.java | 20 ++++-
.../maven/model/resolution/ModelResolver.java | 32 ++++++++
.../internal/DefaultModelResolver.java | 84 ++++++++++++++++----
4 files changed, 184 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/086ebf06/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index 184be70..f11e77d 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.maven.model.Dependency;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
@@ -203,24 +204,26 @@ public class ProjectModelResolver
return new FileModelSource( pomFile );
}
- public ModelSource resolveModel( Parent parent )
+ @Override
+ public ModelSource resolveModel( final Parent parent )
throws UnresolvableModelException
{
- Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
- parent.getVersion() );
-
- VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
- versionRangeRequest.setTrace( trace );
-
try
{
- VersionRangeResult versionRangeResult = resolver.resolveVersionRange( session, versionRangeRequest );
+ final Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
+ parent.getVersion() );
+
+ final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
+ versionRangeRequest.setTrace( trace );
+
+ final VersionRangeResult versionRangeResult = resolver.resolveVersionRange( session, versionRangeRequest );
if ( versionRangeResult.getHighestVersion() == null )
{
- throw new UnresolvableModelException( "No versions matched the requested range '" + parent.getVersion()
- + "'", parent.getGroupId(), parent.getArtifactId(),
- parent.getVersion() );
+ throw new UnresolvableModelException(
+ String.format( "No versions matched the requested parent version range '%s'",
+ parent.getVersion() ),
+ parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
@@ -228,21 +231,68 @@ public class ProjectModelResolver
&& versionRangeResult.getVersionConstraint().getRange() != null
&& versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
{
- throw new UnresolvableModelException( "The requested version range '" + parent.getVersion()
- + "' does not specify an upper bound", parent.getGroupId(),
- parent.getArtifactId(), parent.getVersion() );
+ throw new UnresolvableModelException(
+ String.format( "The requested parent version range '%s' does not specify an upper bound",
+ parent.getVersion() ),
+ parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
parent.setVersion( versionRangeResult.getHighestVersion().toString() );
+
+ return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
- catch ( VersionRangeResolutionException e )
+ catch ( final VersionRangeResolutionException e )
{
throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
parent.getVersion(), e );
}
+ }
+
+ @Override
+ public ModelSource resolveModel( final Dependency dependency )
+ throws UnresolvableModelException
+ {
+ try
+ {
+ final Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), "",
+ "pom", dependency.getVersion() );
+
+ final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
+ versionRangeRequest.setTrace( trace );
+
+ final VersionRangeResult versionRangeResult = resolver.resolveVersionRange( session, versionRangeRequest );
+
+ if ( versionRangeResult.getHighestVersion() == null )
+ {
+ throw new UnresolvableModelException(
+ String.format( "No versions matched the requested dependency version range '%s'",
+ dependency.getVersion() ),
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+
+ }
+
+ if ( versionRangeResult.getVersionConstraint() != null
+ && versionRangeResult.getVersionConstraint().getRange() != null
+ && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
+ {
+ throw new UnresolvableModelException(
+ String.format( "The requested dependency version range '%s' does not specify an upper bound",
+ dependency.getVersion() ),
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+
+ }
+
+ dependency.setVersion( versionRangeResult.getHighestVersion().toString() );
+
+ return resolveModel( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+ }
+ catch ( VersionRangeResolutionException e )
+ {
+ throw new UnresolvableModelException( e.getMessage(), dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), e );
- return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
+ }
}
}
http://git-wip-us.apache.org/repos/asf/maven/blob/086ebf06/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 49a1f3c..3532660 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -1208,7 +1208,25 @@ public class DefaultModelBuilder
final ModelSource importSource;
try
{
- importSource = modelResolver.resolveModel( groupId, artifactId, version );
+ dependency = dependency.clone();
+ importSource = modelResolver.resolveModel( dependency );
+ final String resolvedId =
+ dependency.getGroupId() + ':' + dependency.getArtifactId() + ':' + dependency.getVersion();
+
+ if ( !imported.equals( resolvedId ) && importIds.contains( resolvedId ) )
+ {
+ // A version range has been resolved to a cycle.
+ String message = "The dependencies of type=pom and with scope=import form a cycle: ";
+ for ( String modelId : importIds )
+ {
+ message += modelId + " -> ";
+ }
+ message += resolvedId;
+ problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).
+ setMessage( message ) );
+
+ continue;
+ }
}
catch ( UnresolvableModelException e )
{
http://git-wip-us.apache.org/repos/asf/maven/blob/086ebf06/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java
index c81a536..cb2a3ed 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java
@@ -19,6 +19,7 @@ package org.apache.maven.model.resolution;
* under the License.
*/
+import org.apache.maven.model.Dependency;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Repository;
import org.apache.maven.model.building.ModelSource;
@@ -47,16 +48,47 @@ public interface ModelResolver
/**
* Tries to resolve the POM for the specified parent coordinates possibly updating {@code parent}.
+ * <p>
+ * Unlike the {@link #resolveModel(java.lang.String, java.lang.String, java.lang.String)} method, this method
+ * supports version ranges and updates the given {@code parent} instance to match the returned {@code ModelSource}.
+ * If {@code parent} declares a version range, the version corresponding to the returned {@code ModelSource} will
+ * be set on the given {@code parent}.
+ * </p>
*
* @param parent The parent coordinates to resolve, must not be {@code null}.
+ *
* @return The source of the requested POM, never {@code null}.
+ *
* @throws UnresolvableModelException If the POM could not be resolved from any configured repository.
* @since 3.2.2
+ *
+ * @see Parent#clone()
*/
ModelSource resolveModel( Parent parent )
throws UnresolvableModelException;
/**
+ * Tries to resolve the POM for the specified dependency coordinates possibly updating {@code dependency}.
+ * <p>
+ * Unlike the {@link #resolveModel(java.lang.String, java.lang.String, java.lang.String)} method, this method
+ * supports version ranges and updates the given {@code dependency} instance to match the returned
+ * {@code ModelSource}. If {@code dependency} declares a version range, the version corresponding to the returned
+ * {@code ModelSource} will be set on the given {@code dependency}.
+ * </p>
+ *
+ * @param dependency The dependency coordinates to resolve, must not be {@code null}.
+ *
+ * @return The source of the requested POM, never {@code null}.
+ *
+ * @throws UnresolvableModelException If the POM could not be resolved from any configured repository.
+ * @since 3.4
+ *
+ * @see Dependency#clone()
+ */
+ ModelSource resolveModel( Dependency dependency )
+ throws UnresolvableModelException;
+
+ /**
* Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters,
* repositories that were added first should also be searched first. When multiple repositories with the same
* identifier are added, only the first repository being added will be used.
http://git-wip-us.apache.org/repos/asf/maven/blob/086ebf06/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
index f344959..0832a3a 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.maven.model.Dependency;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import org.apache.maven.model.Parent;
@@ -182,25 +183,27 @@ class DefaultModelResolver
return new FileModelSource( pomFile );
}
- public ModelSource resolveModel( Parent parent )
+ @Override
+ public ModelSource resolveModel( final Parent parent )
throws UnresolvableModelException
{
- Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
- parent.getVersion() );
-
- VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
- versionRangeRequest.setTrace( trace );
-
try
{
- VersionRangeResult versionRangeResult =
+ final Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
+ parent.getVersion() );
+
+ final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
+ versionRangeRequest.setTrace( trace );
+
+ final VersionRangeResult versionRangeResult =
versionRangeResolver.resolveVersionRange( session, versionRangeRequest );
if ( versionRangeResult.getHighestVersion() == null )
{
- throw new UnresolvableModelException( "No versions matched the requested range '" + parent.getVersion()
- + "'", parent.getGroupId(), parent.getArtifactId(),
- parent.getVersion() );
+ throw new UnresolvableModelException(
+ String.format( "No versions matched the requested parent version range '%s'",
+ parent.getVersion() ),
+ parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
@@ -208,22 +211,69 @@ class DefaultModelResolver
&& versionRangeResult.getVersionConstraint().getRange() != null
&& versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
{
- throw new UnresolvableModelException( "The requested version range '" + parent.getVersion()
- + "' does not specify an upper bound", parent.getGroupId(),
- parent.getArtifactId(), parent.getVersion() );
+ throw new UnresolvableModelException(
+ String.format( "The requested parent version range '%s' does not specify an upper bound",
+ parent.getVersion() ),
+ parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
parent.setVersion( versionRangeResult.getHighestVersion().toString() );
+
+ return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
- catch ( VersionRangeResolutionException e )
+ catch ( final VersionRangeResolutionException e )
{
throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
parent.getVersion(), e );
}
-
- return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
}
+ @Override
+ public ModelSource resolveModel( final Dependency dependency )
+ throws UnresolvableModelException
+ {
+ try
+ {
+ final Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), "",
+ "pom", dependency.getVersion() );
+
+ final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
+ versionRangeRequest.setTrace( trace );
+
+ final VersionRangeResult versionRangeResult =
+ versionRangeResolver.resolveVersionRange( session, versionRangeRequest );
+
+ if ( versionRangeResult.getHighestVersion() == null )
+ {
+ throw new UnresolvableModelException(
+ String.format( "No versions matched the requested dependency version range '%s'",
+ dependency.getVersion() ),
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+
+ }
+
+ if ( versionRangeResult.getVersionConstraint() != null
+ && versionRangeResult.getVersionConstraint().getRange() != null
+ && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
+ {
+ throw new UnresolvableModelException(
+ String.format( "The requested dependency version range '%s' does not specify an upper bound",
+ dependency.getVersion() ),
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+
+ }
+
+ dependency.setVersion( versionRangeResult.getHighestVersion().toString() );
+
+ return resolveModel( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() );
+ }
+ catch ( VersionRangeResolutionException e )
+ {
+ throw new UnresolvableModelException( e.getMessage(), dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), e );
+
+ }
+ }
}
[12/15] maven git commit: [MNG-5527] Dependency management import
should support relocations.
Posted by sc...@apache.org.
[MNG-5527] Dependency management import should support relocations.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/2279f858
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/2279f858
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/2279f858
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 2279f858108a2372b617a9a43779b467bacf8b85
Parents: 086ebf0
Author: Christian Schulte <sc...@apache.org>
Authored: Tue Jun 21 21:35:40 2016 +0200
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:19:41 2017 +0100
----------------------------------------------------------------------
.../model/building/DefaultModelBuilder.java | 190 ++++++++++++-------
1 file changed, 125 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/2279f858/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 3532660..5ca1623 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -1114,8 +1114,6 @@ public class DefaultModelBuilder
final WorkspaceModelResolver workspaceResolver = request.getWorkspaceModelResolver();
final ModelResolver modelResolver = request.getModelResolver();
- ModelBuildingRequest importRequest = null;
-
List<DependencyManagement> importMngts = null;
for ( Iterator<Dependency> it = depMngt.getDependencies().iterator(); it.hasNext(); )
@@ -1202,75 +1200,15 @@ public class DefaultModelBuilder
}
}
- // no workspace resolver or workspace resolver returned null (i.e. model not in workspace)
if ( importModel == null )
{
- final ModelSource importSource;
- try
- {
- dependency = dependency.clone();
- importSource = modelResolver.resolveModel( dependency );
- final String resolvedId =
- dependency.getGroupId() + ':' + dependency.getArtifactId() + ':' + dependency.getVersion();
+ // no workspace resolver or workspace resolver returned null (i.e. model not in workspace)
+ importModel = this.buildImportModelFromRepository( request, dependency, importIds, problems );
- if ( !imported.equals( resolvedId ) && importIds.contains( resolvedId ) )
- {
- // A version range has been resolved to a cycle.
- String message = "The dependencies of type=pom and with scope=import form a cycle: ";
- for ( String modelId : importIds )
- {
- message += modelId + " -> ";
- }
- message += resolvedId;
- problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).
- setMessage( message ) );
-
- continue;
- }
- }
- catch ( UnresolvableModelException e )
+ if ( importModel == null )
{
- StringBuilder buffer = new StringBuilder( 256 );
- buffer.append( "Non-resolvable import POM" );
- if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
- {
- buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
- }
- buffer.append( ": " ).append( e.getMessage() );
-
- problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
- .setMessage( buffer.toString() ).setLocation( dependency.getLocation( "" ) )
- .setException( e ) );
continue;
}
-
- if ( importRequest == null )
- {
- importRequest = new DefaultModelBuildingRequest();
- importRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
- importRequest.setModelCache( request.getModelCache() );
- importRequest.setSystemProperties( request.getSystemProperties() );
- importRequest.setUserProperties( request.getUserProperties() );
- importRequest.setLocationTracking( request.isLocationTracking() );
- }
-
- importRequest.setModelSource( importSource );
- importRequest.setModelResolver( modelResolver.newCopy() );
-
- final ModelBuildingResult importResult;
- try
- {
- importResult = build( importRequest );
- }
- catch ( ModelBuildingException e )
- {
- problems.addAll( e.getProblems() );
- continue;
- }
-
- problems.addAll( importResult.getProblems() );
-
- importModel = importResult.getEffectiveModel();
}
importMngt = importModel.getDependencyManagement();
@@ -1296,6 +1234,128 @@ public class DefaultModelBuilder
dependencyManagementImporter.importManagement( model, importMngts, request, problems );
}
+ private Model buildImportModelFromRepository( final ModelBuildingRequest targetModelBuildingRequest,
+ final Dependency dependency, final Collection<String> importIds,
+ final DefaultModelProblemCollector problems )
+ {
+ try
+ {
+ final String imported =
+ String.format( "%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion() );
+
+ final Dependency resolvedDependency = dependency.clone();
+ final ModelSource importSource =
+ targetModelBuildingRequest.getModelResolver().resolveModel( resolvedDependency );
+
+ final String resolvedId =
+ String.format( "%s:%s:%s", resolvedDependency.getGroupId(), resolvedDependency.getArtifactId(),
+ resolvedDependency.getVersion() );
+
+ if ( !imported.equals( resolvedId ) && importIds.contains( resolvedId ) )
+ {
+ // A version range has been resolved to a cycle.
+ String message = "The dependencies of type=pom and scope=" + dependency.getScope() + " form a cycle: ";
+ for ( String modelId : importIds )
+ {
+ message += modelId + " -> ";
+ }
+ message += resolvedId;
+ problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ) );
+ }
+ else
+ {
+ final ModelBuildingRequest importRequest = new DefaultModelBuildingRequest();
+ importRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
+ importRequest.setModelCache( targetModelBuildingRequest.getModelCache() );
+ importRequest.setSystemProperties( targetModelBuildingRequest.getSystemProperties() );
+ importRequest.setUserProperties( targetModelBuildingRequest.getUserProperties() );
+ importRequest.setLocationTracking( targetModelBuildingRequest.isLocationTracking() );
+ importRequest.setModelSource( importSource );
+ importRequest.setModelResolver( targetModelBuildingRequest.getModelResolver().newCopy() );
+
+ final ModelBuildingResult importResult = build( importRequest );
+ problems.addAll( importResult.getProblems() );
+
+ Model importModel = importResult.getEffectiveModel();
+
+ if ( importModel.getDistributionManagement() != null
+ && importModel.getDistributionManagement().getRelocation() != null )
+ {
+ final Dependency relocated = dependency.clone();
+ relocated.setGroupId( importModel.getDistributionManagement().getRelocation().getGroupId() );
+ relocated.setArtifactId( importModel.getDistributionManagement().getRelocation().getArtifactId() );
+ relocated.setVersion( importModel.getDistributionManagement().getRelocation().getVersion() );
+
+ String message = String.format(
+ "The dependency of type='%s' and scope='%s' has been relocated to '%s:%s:%s'",
+ dependency.getType(), dependency.getScope(), relocated.getGroupId(),
+ relocated.getArtifactId(), relocated.getVersion() );
+
+ if ( importModel.getDistributionManagement().getRelocation().getMessage() != null )
+ {
+ message += ". " + importModel.getDistributionManagement().getRelocation().getMessage();
+ }
+
+ problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE ).
+ setMessage( message ).
+ setLocation( importModel.getDistributionManagement().getRelocation().getLocation( "" ) ) );
+
+ importModel = this.buildImportModelFromRepository(
+ targetModelBuildingRequest, relocated, importIds, problems );
+
+ }
+
+ return importModel;
+ }
+ }
+ catch ( final UnresolvableModelException e )
+ {
+ final StringBuilder buffer = new StringBuilder( 256 );
+ buffer.append( "Non-resolvable " ).append( dependency.getScope() ).append( " POM" );
+
+ if ( !containsCoordinates( e.getMessage(), dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion() ) )
+ {
+ buffer.append( ' ' ).append( ModelProblemUtils.toId(
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ) );
+
+ }
+
+ buffer.append( ": " ).append( e.getMessage() );
+
+ problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).
+ setMessage( buffer.toString() ).
+ setLocation( dependency.getLocation( "" ) ).
+ setException( e ) );
+
+ }
+ catch ( final ModelBuildingException e )
+ {
+ final StringBuilder buffer = new StringBuilder( 256 );
+ buffer.append( "Failure building " ).append( dependency.getScope() ).append( " POM" );
+
+ if ( !containsCoordinates( e.getMessage(), dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion() ) )
+ {
+ buffer.append( ' ' ).append( ModelProblemUtils.toId(
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ) );
+
+ }
+
+ buffer.append( ": " ).append( e.getMessage() );
+
+ problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).
+ setMessage( buffer.toString() ).
+ setLocation( dependency.getLocation( "" ) ).
+ setException( e ) );
+
+ problems.addAll( e.getProblems() );
+ }
+
+ return null;
+ }
+
private <T> void putCache( ModelCache modelCache, String groupId, String artifactId, String version,
ModelCacheTag<T> tag, T data )
{
[04/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
new file mode 100644
index 0000000..1b11cb3
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
@@ -0,0 +1,145 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.artifact.DefaultArtifactType;
+import org.eclipse.aether.collection.DependencyGraphTransformer;
+import org.eclipse.aether.collection.DependencyManager;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.collection.DependencyTraverser;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
+import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
+import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
+import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.eclipse.aether.util.graph.transformer.ConflictResolver;
+import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
+import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
+import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
+import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
+import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
+import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
+import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
+
+/**
+ * A utility class to assist in setting up a Maven-like repository system. <em>Note:</em> This component is meant to
+ * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead
+ * always use regular dependency injection to acquire the repository system.
+ *
+ * @author Benjamin Bentmann
+ */
+public final class MavenRepositorySystemUtils
+{
+
+ private MavenRepositorySystemUtils()
+ {
+ // hide constructor
+ }
+
+ /**
+ * Creates a new service locator that already knows about all service implementations included in this library. To
+ * acquire a complete repository system, clients need to add some repository connectors for remote transfers.
+ *
+ * @return The new service locator, never {@code null}.
+ */
+ public static DefaultServiceLocator newServiceLocator()
+ {
+ DefaultServiceLocator locator = new DefaultServiceLocator();
+ locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class );
+ locator.addService( VersionResolver.class, DefaultVersionResolver.class );
+ locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class );
+ locator.addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class );
+ locator.addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class );
+ return locator;
+ }
+
+ /**
+ * Creates a new Maven-like repository system session by initializing the session with values typical for
+ * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency
+ * graphs, most other settings remain at their generic default value. Use the various setters to further configure
+ * the session with authentication, mirror, proxy and other information required for your environment.
+ *
+ * @return The new repository system session, never {@code null}.
+ */
+ public static DefaultRepositorySystemSession newSession()
+ {
+ DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
+
+ DependencyTraverser depTraverser = new FatArtifactTraverser();
+ session.setDependencyTraverser( depTraverser );
+
+ DependencyManager depManager = new ClassicDependencyManager();
+ session.setDependencyManager( depManager );
+
+ DependencySelector depFilter =
+ new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
+ new OptionalDependencySelector(), new ExclusionDependencySelector() );
+ session.setDependencySelector( depFilter );
+
+ DependencyGraphTransformer transformer =
+ new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(),
+ new SimpleOptionalitySelector(), new JavaScopeDeriver() );
+ new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() );
+ session.setDependencyGraphTransformer( transformer );
+
+ DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
+ stereotypes.add( new DefaultArtifactType( "pom" ) );
+ stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) );
+ stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) );
+ stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) );
+ stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) );
+ stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) );
+ stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) );
+ session.setArtifactTypeRegistry( stereotypes );
+
+ session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
+
+ final Properties systemProperties = new Properties();
+
+ // MNG-5670 guard against ConcurrentModificationException
+ // MNG-6053 guard against key without value
+ Properties sysProp = System.getProperties();
+ synchronized ( sysProp )
+ {
+ systemProperties.putAll( sysProp );
+ }
+
+ session.setSystemProperties( systemProperties );
+ session.setConfigProperties( systemProperties );
+
+ return session;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
new file mode 100644
index 0000000..070b91c
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
@@ -0,0 +1,70 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.name.Names;
+import org.apache.maven.model.building.DefaultModelBuilderFactory;
+import org.apache.maven.model.building.ModelBuilder;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.impl.guice.AetherModule;
+
+public final class MavenResolverModule
+ extends AbstractModule
+{
+
+ @Override
+ protected void configure()
+ {
+ install( new AetherModule() );
+ bind( ArtifactDescriptorReader.class ).to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
+ bind( VersionResolver.class ).to( DefaultVersionResolver.class ).in( Singleton.class );
+ bind( VersionRangeResolver.class ).to( DefaultVersionRangeResolver.class ).in( Singleton.class );
+ bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) )
+ .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
+
+ bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) )
+ .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
+
+ bind( ModelBuilder.class ).toInstance( new DefaultModelBuilderFactory().newInstance() );
+ }
+
+ @Provides
+ @Singleton
+ Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories(
+ @Named( "snapshot" ) MetadataGeneratorFactory snapshot,
+ @Named( "versions" ) MetadataGeneratorFactory versions )
+ {
+ Set<MetadataGeneratorFactory> factories = new HashSet<>( 2 );
+ factories.add( snapshot );
+ factories.add( versions );
+ return Collections.unmodifiableSet( factories );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
new file mode 100644
index 0000000..e4c9a7e
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
@@ -0,0 +1,100 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * @author Herv� Boutemy
+ */
+abstract class MavenSnapshotMetadata
+ extends MavenMetadata
+{
+ static final String SNAPSHOT = "SNAPSHOT";
+
+ protected final Collection<Artifact> artifacts = new ArrayList<>();
+
+ protected final boolean legacyFormat;
+
+ protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
+ {
+ super( metadata, file );
+ this.legacyFormat = legacyFormat;
+ }
+
+ protected static Metadata createRepositoryMetadata( Artifact artifact, boolean legacyFormat )
+ {
+ Metadata metadata = new Metadata();
+ if ( !legacyFormat )
+ {
+ metadata.setModelVersion( "1.1.0" );
+ }
+ metadata.setGroupId( artifact.getGroupId() );
+ metadata.setArtifactId( artifact.getArtifactId() );
+ metadata.setVersion( artifact.getBaseVersion() );
+
+ return metadata;
+ }
+
+ public void bind( Artifact artifact )
+ {
+ artifacts.add( artifact );
+ }
+
+ public Object getKey()
+ {
+ return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
+ }
+
+ public static Object getKey( Artifact artifact )
+ {
+ return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
+ }
+
+ protected String getKey( String classifier, String extension )
+ {
+ return classifier + ':' + extension;
+ }
+
+ public String getGroupId()
+ {
+ return metadata.getGroupId();
+ }
+
+ public String getArtifactId()
+ {
+ return metadata.getArtifactId();
+ }
+
+ public String getVersion()
+ {
+ return metadata.getVersion();
+ }
+
+ public Nature getNature()
+ {
+ return Nature.SNAPSHOT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
new file mode 100644
index 0000000..270cf58
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenWorkspaceReader.java
@@ -0,0 +1,32 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.model.Model;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+
+public interface MavenWorkspaceReader
+ extends WorkspaceReader
+{
+
+ Model findModel( Artifact artifact );
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
new file mode 100644
index 0000000..c6ef3aa
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java
@@ -0,0 +1,114 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+import org.eclipse.aether.artifact.AbstractArtifact;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * @author Benjamin Bentmann
+ */
+final class RelocatedArtifact
+ extends AbstractArtifact
+{
+
+ private final Artifact artifact;
+
+ private final String groupId;
+
+ private final String artifactId;
+
+ private final String version;
+
+ public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
+ {
+ this.artifact = Validate.notNull( artifact, "artifact cannot be null" );
+ // TODO Use StringUtils here
+ this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null;
+ this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null;
+ this.version = ( version != null && version.length() > 0 ) ? version : null;
+ }
+
+ public String getGroupId()
+ {
+ if ( groupId != null )
+ {
+ return groupId;
+ }
+ else
+ {
+ return artifact.getGroupId();
+ }
+ }
+
+ public String getArtifactId()
+ {
+ if ( artifactId != null )
+ {
+ return artifactId;
+ }
+ else
+ {
+ return artifact.getArtifactId();
+ }
+ }
+
+ public String getVersion()
+ {
+ if ( version != null )
+ {
+ return version;
+ }
+ else
+ {
+ return artifact.getVersion();
+ }
+ }
+
+ public String getClassifier()
+ {
+ return artifact.getClassifier();
+ }
+
+ public String getExtension()
+ {
+ return artifact.getExtension();
+ }
+
+ public File getFile()
+ {
+ return artifact.getFile();
+ }
+
+ public String getProperty( String key, String defaultValue )
+ {
+ return artifact.getProperty( key, defaultValue );
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return artifact.getProperties();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
new file mode 100644
index 0000000..1e791d8
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
@@ -0,0 +1,157 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.Snapshot;
+import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * @author Benjamin Bentmann
+ */
+final class RemoteSnapshotMetadata
+ extends MavenSnapshotMetadata
+{
+ public static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss";
+
+ public static final TimeZone DEFAULT_SNAPSHOT_TIME_ZONE = TimeZone.getTimeZone( "Etc/UTC" );
+
+ private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
+
+ public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat )
+ {
+ super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat );
+ }
+
+ private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
+ {
+ super( metadata, file, legacyFormat );
+ }
+
+ public MavenMetadata setFile( File file )
+ {
+ return new RemoteSnapshotMetadata( metadata, file, legacyFormat );
+ }
+
+ public String getExpandedVersion( Artifact artifact )
+ {
+ String key = getKey( artifact.getClassifier(), artifact.getExtension() );
+ return versions.get( key ).getVersion();
+ }
+
+ @Override
+ protected void merge( Metadata recessive )
+ {
+ Snapshot snapshot;
+ String lastUpdated;
+
+ if ( metadata.getVersioning() == null )
+ {
+ DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT );
+ utcDateFormatter.setCalendar( new GregorianCalendar() );
+ utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE );
+
+ snapshot = new Snapshot();
+ snapshot.setBuildNumber( getBuildNumber( recessive ) + 1 );
+ snapshot.setTimestamp( utcDateFormatter.format( new Date() ) );
+
+ Versioning versioning = new Versioning();
+ versioning.setSnapshot( snapshot );
+ versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) );
+ lastUpdated = versioning.getLastUpdated();
+
+ metadata.setVersioning( versioning );
+ }
+ else
+ {
+ snapshot = metadata.getVersioning().getSnapshot();
+ lastUpdated = metadata.getVersioning().getLastUpdated();
+ }
+
+ for ( Artifact artifact : artifacts )
+ {
+ String version = artifact.getVersion();
+
+ if ( version.endsWith( SNAPSHOT ) )
+ {
+ String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
+ version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
+ }
+
+ SnapshotVersion sv = new SnapshotVersion();
+ sv.setClassifier( artifact.getClassifier() );
+ sv.setExtension( artifact.getExtension() );
+ sv.setVersion( version );
+ sv.setUpdated( lastUpdated );
+
+ versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
+ }
+
+ artifacts.clear();
+
+ Versioning versioning = recessive.getVersioning();
+ if ( versioning != null )
+ {
+ for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
+ {
+ String key = getKey( sv.getClassifier(), sv.getExtension() );
+ if ( !versions.containsKey( key ) )
+ {
+ versions.put( key, sv );
+ }
+ }
+ }
+
+ if ( !legacyFormat )
+ {
+ metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
+ }
+ }
+
+ private static int getBuildNumber( Metadata metadata )
+ {
+ int number = 0;
+
+ Versioning versioning = metadata.getVersioning();
+ if ( versioning != null )
+ {
+ Snapshot snapshot = versioning.getSnapshot();
+ if ( snapshot != null && snapshot.getBuildNumber() > 0 )
+ {
+ number = snapshot.getBuildNumber();
+ }
+ }
+
+ return number;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
new file mode 100644
index 0000000..8258966
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.impl.MetadataGenerator;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.util.ConfigUtils;
+
+/**
+ * @author Benjamin Bentmann
+ */
+class RemoteSnapshotMetadataGenerator
+ implements MetadataGenerator
+{
+
+ private final Map<Object, RemoteSnapshotMetadata> snapshots;
+
+ private final boolean legacyFormat;
+
+ public RemoteSnapshotMetadataGenerator( RepositorySystemSession session, DeployRequest request )
+ {
+ legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
+
+ snapshots = new LinkedHashMap<>();
+
+ /*
+ * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
+ * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the
+ * same timestamp+buildno for the snapshot versions. Allowing the caller to pass in metadata from a previous
+ * deployment allows to re-establish the association between the artifacts of the same project.
+ */
+ for ( Metadata metadata : request.getMetadata() )
+ {
+ if ( metadata instanceof RemoteSnapshotMetadata )
+ {
+ RemoteSnapshotMetadata snapshotMetadata = (RemoteSnapshotMetadata) metadata;
+ snapshots.put( snapshotMetadata.getKey(), snapshotMetadata );
+ }
+ }
+ }
+
+ public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
+ {
+ for ( Artifact artifact : artifacts )
+ {
+ if ( artifact.isSnapshot() )
+ {
+ Object key = RemoteSnapshotMetadata.getKey( artifact );
+ RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
+ if ( snapshotMetadata == null )
+ {
+ snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat );
+ snapshots.put( key, snapshotMetadata );
+ }
+ snapshotMetadata.bind( artifact );
+ }
+ }
+
+ return snapshots.values();
+ }
+
+ public Artifact transformArtifact( Artifact artifact )
+ {
+ if ( artifact.isSnapshot() && artifact.getVersion().equals( artifact.getBaseVersion() ) )
+ {
+ Object key = RemoteSnapshotMetadata.getKey( artifact );
+ RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
+ if ( snapshotMetadata != null )
+ {
+ artifact = artifact.setVersion( snapshotMetadata.getExpandedVersion( artifact ) );
+ }
+ }
+
+ return artifact;
+ }
+
+ public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
+ {
+ return Collections.emptyList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
new file mode 100644
index 0000000..79ffaad
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java
@@ -0,0 +1,52 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.codehaus.plexus.component.annotations.Component;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.impl.MetadataGenerator;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.installation.InstallRequest;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = MetadataGeneratorFactory.class, hint = "snapshot" )
+public class SnapshotMetadataGeneratorFactory
+ implements MetadataGeneratorFactory
+{
+
+ public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request )
+ {
+ return new LocalSnapshotMetadataGenerator( session, request );
+ }
+
+ public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request )
+ {
+ return new RemoteSnapshotMetadataGenerator( session, request );
+ }
+
+ public float getPriority()
+ {
+ return 10;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
new file mode 100644
index 0000000..f5e13be
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
@@ -0,0 +1,133 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactProperties;
+
+/**
+ * @author Benjamin Bentmann
+ */
+final class VersionsMetadata
+ extends MavenMetadata
+{
+
+ private final Artifact artifact;
+
+ public VersionsMetadata( Artifact artifact )
+ {
+ super( createRepositoryMetadata( artifact ), null );
+ this.artifact = artifact;
+ }
+
+ public VersionsMetadata( Artifact artifact, File file )
+ {
+ super( createRepositoryMetadata( artifact ), file );
+ this.artifact = artifact;
+ }
+
+ private static Metadata createRepositoryMetadata( Artifact artifact )
+ {
+ Metadata metadata = new Metadata();
+ metadata.setGroupId( artifact.getGroupId() );
+ metadata.setArtifactId( artifact.getArtifactId() );
+
+ Versioning versioning = new Versioning();
+ versioning.addVersion( artifact.getBaseVersion() );
+ if ( !artifact.isSnapshot() )
+ {
+ versioning.setRelease( artifact.getBaseVersion() );
+ }
+ if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) )
+ {
+ versioning.setLatest( artifact.getBaseVersion() );
+ }
+
+ metadata.setVersioning( versioning );
+
+ return metadata;
+ }
+
+ @Override
+ protected void merge( Metadata recessive )
+ {
+ Versioning versioning = metadata.getVersioning();
+ versioning.updateTimestamp();
+
+ if ( recessive.getVersioning() != null )
+ {
+ if ( versioning.getLatest() == null )
+ {
+ versioning.setLatest( recessive.getVersioning().getLatest() );
+ }
+ if ( versioning.getRelease() == null )
+ {
+ versioning.setRelease( recessive.getVersioning().getRelease() );
+ }
+
+ Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
+ versions.addAll( versioning.getVersions() );
+ versioning.setVersions( new ArrayList<>( versions ) );
+ }
+ }
+
+ public Object getKey()
+ {
+ return getGroupId() + ':' + getArtifactId();
+ }
+
+ public static Object getKey( Artifact artifact )
+ {
+ return artifact.getGroupId() + ':' + artifact.getArtifactId();
+ }
+
+ public MavenMetadata setFile( File file )
+ {
+ return new VersionsMetadata( artifact, file );
+ }
+
+ public String getGroupId()
+ {
+ return artifact.getGroupId();
+ }
+
+ public String getArtifactId()
+ {
+ return artifact.getArtifactId();
+ }
+
+ public String getVersion()
+ {
+ return "";
+ }
+
+ public Nature getNature()
+ {
+ return artifact.isSnapshot() ? Nature.RELEASE_OR_SNAPSHOT : Nature.RELEASE;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
new file mode 100644
index 0000000..5173001
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
@@ -0,0 +1,108 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.impl.MetadataGenerator;
+import org.eclipse.aether.installation.InstallRequest;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * @author Benjamin Bentmann
+ */
+class VersionsMetadataGenerator
+ implements MetadataGenerator
+{
+
+ private Map<Object, VersionsMetadata> versions;
+
+ private Map<Object, VersionsMetadata> processedVersions;
+
+ public VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request )
+ {
+ this( session, request.getMetadata() );
+ }
+
+ public VersionsMetadataGenerator( RepositorySystemSession session, DeployRequest request )
+ {
+ this( session, request.getMetadata() );
+ }
+
+ private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas )
+ {
+ versions = new LinkedHashMap<>();
+ processedVersions = new LinkedHashMap<>();
+
+ /*
+ * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
+ * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the
+ * same version index. Allowing the caller to pass in metadata from a previous deployment allows to re-establish
+ * the association between the artifacts of the same project.
+ */
+ for ( Iterator<? extends Metadata> it = metadatas.iterator(); it.hasNext(); )
+ {
+ Metadata metadata = it.next();
+ if ( metadata instanceof VersionsMetadata )
+ {
+ it.remove();
+ VersionsMetadata versionsMetadata = (VersionsMetadata) metadata;
+ processedVersions.put( versionsMetadata.getKey(), versionsMetadata );
+ }
+ }
+ }
+
+ public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
+ {
+ return Collections.emptyList();
+ }
+
+ public Artifact transformArtifact( Artifact artifact )
+ {
+ return artifact;
+ }
+
+ public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
+ {
+ for ( Artifact artifact : artifacts )
+ {
+ Object key = VersionsMetadata.getKey( artifact );
+ if ( processedVersions.get( key ) == null )
+ {
+ VersionsMetadata versionsMetadata = versions.get( key );
+ if ( versionsMetadata == null )
+ {
+ versionsMetadata = new VersionsMetadata( artifact );
+ versions.put( key, versionsMetadata );
+ }
+ }
+ }
+
+ return versions.values();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
new file mode 100644
index 0000000..47ef360
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java
@@ -0,0 +1,52 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.codehaus.plexus.component.annotations.Component;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.impl.MetadataGenerator;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.installation.InstallRequest;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = MetadataGeneratorFactory.class, hint = "versions" )
+public class VersionsMetadataGeneratorFactory
+ implements MetadataGeneratorFactory
+{
+
+ public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request )
+ {
+ return new VersionsMetadataGenerator( session, request );
+ }
+
+ public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request )
+ {
+ return new VersionsMetadataGenerator( session, request );
+ }
+
+ public float getPriority()
+ {
+ return 5;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
new file mode 100644
index 0000000..7309c2b
--- /dev/null
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/package-info.java
@@ -0,0 +1,25 @@
+// CHECKSTYLE_OFF: RegexpHeader
+/**
+ * <a href="https://maven.apache.org/resolver/">Maven Resolver</a> extensions for utilizing the Maven POM and Maven
+ * repository metadata.
+ */
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.
+ */
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/site/apt/index.apt b/maven-resolver-provider/src/site/apt/index.apt
new file mode 100644
index 0000000..b50ea1d
--- /dev/null
+++ b/maven-resolver-provider/src/site/apt/index.apt
@@ -0,0 +1,33 @@
+~~ 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.
+
+ -----
+ Introduction
+ -----
+ Herv� Boutemy
+ -----
+ 2012-09-29
+ -----
+
+Maven Artifact Resolver Provider
+
+ Maven Artifact Resolver Provider is a {{{/resolver/}Maven Artifact Resolver}} extension to support
+ Maven POMs and local+remote repositories.
+
+ Main component is <<<MavenRepositorySystemUtils>>>
+ ({{{./apidocs/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}javadoc}},
+ {{{./xref/org/apache/maven/repository/internal/MavenRepositorySystemUtils.html}source}}).
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/site/site.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/site/site.xml b/maven-resolver-provider/src/site/site.xml
new file mode 100644
index 0000000..3a16bf9
--- /dev/null
+++ b/maven-resolver-provider/src/site/site.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+ <body>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="JavaDocs" href="apidocs/index.html"/>
+ <item name="Source Xref" href="xref/index.html"/>
+ <!--item name="FAQ" href="faq.html"/-->
+ </menu>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
new file mode 100644
index 0000000..b81450c
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
@@ -0,0 +1,87 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.MalformedURLException;
+
+import org.apache.maven.repository.internal.util.ConsoleRepositoryListener;
+import org.apache.maven.repository.internal.util.ConsoleTransferListener;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+
+public abstract class AbstractRepositoryTestCase
+ extends PlexusTestCase
+{
+ protected RepositorySystem system;
+
+ protected RepositorySystemSession session;
+
+ @Override
+ protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
+ {
+ super.customizeContainerConfiguration( containerConfiguration );
+ containerConfiguration.setAutoWiring( true );
+ containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ system = lookup( RepositorySystem.class );
+ session = newMavenRepositorySystemSession( system );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ session = null;
+ system = null;
+ super.tearDown();
+ }
+
+ public static RepositorySystemSession newMavenRepositorySystemSession( RepositorySystem system )
+ {
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+
+ LocalRepository localRepo = new LocalRepository( "target/local-repo" );
+ session.setLocalRepositoryManager( system.newLocalRepositoryManager( session, localRepo ) );
+
+ session.setTransferListener( new ConsoleTransferListener() );
+ session.setRepositoryListener( new ConsoleRepositoryListener() );
+
+ return session;
+ }
+
+ public static RemoteRepository newTestRepository()
+ throws MalformedURLException
+ {
+ return new RemoteRepository.Builder( "repo", "default",
+ getTestFile( "target/test-classes/repo" ).toURI().toURL().toString() ).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
new file mode 100644
index 0000000..e873138
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
@@ -0,0 +1,77 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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 static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.eclipse.aether.RepositoryEvent;
+import org.eclipse.aether.RepositoryEvent.EventType;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.RepositoryEventDispatcher;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.mockito.ArgumentCaptor;
+
+public class DefaultArtifactDescriptorReaderTest
+ extends AbstractRepositoryTestCase
+{
+
+ public void testMng5459()
+ throws Exception
+ {
+ // prepare
+ DefaultArtifactDescriptorReader reader = (DefaultArtifactDescriptorReader) lookup( ArtifactDescriptorReader.class );
+
+ RepositoryEventDispatcher eventDispatcher = mock( RepositoryEventDispatcher.class );
+
+ ArgumentCaptor<RepositoryEvent> event = ArgumentCaptor.forClass( RepositoryEvent.class );
+
+ reader.setRepositoryEventDispatcher( eventDispatcher );
+
+ ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
+
+ request.addRepository( newTestRepository() );
+
+ request.setArtifact( new DefaultArtifact( "org.apache.maven.its", "dep-mng5459", "jar", "0.4.0-SNAPSHOT" ) );
+
+ // execute
+ reader.readArtifactDescriptor( session, request );
+
+ // verify
+ verify( eventDispatcher ).dispatch( event.capture() );
+
+ boolean missingArtifactDescriptor = false;
+
+ for( RepositoryEvent evt : event.getAllValues() )
+ {
+ if ( EventType.ARTIFACT_DESCRIPTOR_MISSING.equals( evt.getType() ) )
+ {
+ assertEquals( "Could not find artifact org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2 in repo (" + newTestRepository().getUrl() + ")", evt.getException().getMessage() );
+ missingArtifactDescriptor = true;
+ }
+ }
+
+ if( !missingArtifactDescriptor )
+ {
+ fail( "Expected missing artifact descriptor for org.apache.maven.its:dep-mng5459:pom:0.4.0-20130404.090532-2" );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
new file mode 100644
index 0000000..90dd6a4
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
@@ -0,0 +1,96 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResult;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class DefaultVersionResolverTest
+ extends AbstractRepositoryTestCase
+{
+ private DefaultVersionResolver versionResolver;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ // be sure we're testing the right class, i.e. DefaultVersionResolver.class
+ versionResolver = (DefaultVersionResolver) lookup( VersionResolver.class, "default" );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ versionResolver = null;
+ super.tearDown();
+ }
+
+ public void testResolveSeparateInstalledClassifiedNonUniqueVersionedArtifacts()
+ throws Exception
+ {
+ VersionRequest requestB = new VersionRequest();
+ requestB.addRepository( newTestRepository() );
+ Artifact artifactB =
+ new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", "07.20.3-SNAPSHOT" );
+ requestB.setArtifact( artifactB );
+
+ VersionResult resultB = versionResolver.resolveVersion( session, requestB );
+ assertEquals( "07.20.3-20120809.112920-97", resultB.getVersion() );
+
+ VersionRequest requestA = new VersionRequest();
+ requestA.addRepository( newTestRepository() );
+
+ Artifact artifactA =
+ new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", "07.20.3-SNAPSHOT" );
+ requestA.setArtifact( artifactA );
+
+ VersionResult resultA = versionResolver.resolveVersion( session, requestA );
+ assertEquals( "07.20.3-20120809.112124-88", resultA.getVersion() );
+ }
+
+ public void testResolveSeparateInstalledClassifiedNonVersionedArtifacts()
+ throws Exception
+ {
+ VersionRequest requestA = new VersionRequest();
+ requestA.addRepository( newTestRepository() );
+ String versionA = "07.20.3-20120809.112124-88";
+ Artifact artifactA =
+ new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", versionA );
+ requestA.setArtifact( artifactA );
+
+ VersionResult resultA = versionResolver.resolveVersion( session, requestA );
+ assertEquals( versionA, resultA.getVersion() );
+
+ VersionRequest requestB = new VersionRequest();
+ requestB.addRepository( newTestRepository() );
+ String versionB = "07.20.3-20120809.112920-97";
+ Artifact artifactB =
+ new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", versionB );
+ requestB.setArtifact( artifactB );
+
+ VersionResult resultB = versionResolver.resolveVersion( session, requestB );
+ assertEquals( versionB, resultB.getVersion() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
new file mode 100644
index 0000000..768835a
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java
@@ -0,0 +1,45 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.spi.locator.ServiceLocator;
+
+import junit.framework.TestCase;
+
+public class MavenRepositorySystemUtilsTest
+ extends TestCase
+{
+
+ public void testGetRepositorySystem()
+ {
+ ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
+ RepositorySystem repoSys = locator.getService( RepositorySystem.class );
+ assertNotNull( repoSys );
+ }
+
+ public void testGetMetadataGeneratorFactories()
+ {
+ ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
+ assertEquals( 2, locator.getServices( MetadataGeneratorFactory.class ).size() );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
new file mode 100644
index 0000000..278231f
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java
@@ -0,0 +1,82 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RemoteSnapshotMetadataTest
+{
+ private Locale defaultLocale;
+
+ @Before
+ public void setLocaleToUseBuddhistCalendar()
+ {
+ defaultLocale = Locale.getDefault();
+ Locale.setDefault( new Locale( "th", "TH" ) );
+ }
+
+ @After
+ public void restoreLocale()
+ {
+ Locale.setDefault( defaultLocale );
+ }
+
+ static String gregorianDate()
+ {
+ SimpleDateFormat df = new SimpleDateFormat( "yyyyMMdd" );
+ df.setCalendar( new GregorianCalendar() );
+ df.setTimeZone( RemoteSnapshotMetadata.DEFAULT_SNAPSHOT_TIME_ZONE );
+ return df.format( new Date() );
+ }
+
+ @Test
+ public void gregorianCalendarIsUsed()
+ {
+ String dateBefore = gregorianDate();
+
+ RemoteSnapshotMetadata metadata = new RemoteSnapshotMetadata(
+ new DefaultArtifact( "a:b:1-SNAPSHOT" ), false);
+ metadata.merge( new Metadata() );
+
+ String dateAfter = gregorianDate();
+
+ String ts = metadata.metadata.getVersioning().getSnapshot().getTimestamp();
+ String datePart = ts.replaceAll( "\\..*", "" );
+
+ /* Allow for this test running across midnight */
+ Set<String> expected = new HashSet<String>( Arrays.asList( dateBefore, dateAfter ) );
+ assertTrue( "Expected " + datePart + " to be in " + expected,
+ expected.contains( datePart ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
new file mode 100644
index 0000000..db77a44
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
@@ -0,0 +1,220 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class RepositorySystemTest
+ extends AbstractRepositoryTestCase
+{
+ public void testResolveVersionRange()
+ throws Exception
+ {
+ //VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
+ // throws VersionRangeResolutionException;
+
+ }
+
+ public void testResolveVersion()
+ throws Exception
+ {
+ //VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
+ // throws VersionResolutionException;
+ }
+
+ public void testReadArtifactDescriptor()
+ throws Exception
+ {
+ Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
+
+ ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
+ request.setArtifact( artifact );
+ request.addRepository( newTestRepository() );
+
+ ArtifactDescriptorResult result = system.readArtifactDescriptor( session, request );
+
+ List<Dependency> deps = result.getDependencies();
+ assertEquals( 2, deps.size() );
+ checkUtSimpleArtifactDependencies( deps.get( 0 ), deps.get( 1 ) );
+ }
+
+ /**
+ * check ut.simple:artifact:1.0 dependencies
+ */
+ private void checkUtSimpleArtifactDependencies( Dependency dep1, Dependency dep2 )
+ {
+ assertEquals( "compile", dep1.getScope() );
+ assertFalse( dep1.isOptional() );
+ assertEquals( 0, dep1.getExclusions().size() );
+ Artifact depArtifact = dep1.getArtifact();
+ assertEquals( "ut.simple", depArtifact.getGroupId() );
+ assertEquals( "dependency", depArtifact.getArtifactId() );
+ assertEquals( "1.0", depArtifact.getVersion() );
+ assertEquals( "1.0", depArtifact.getBaseVersion() );
+ assertNull( depArtifact.getFile() );
+ assertFalse( depArtifact.isSnapshot() );
+ assertEquals( "", depArtifact.getClassifier() );
+ assertEquals( "jar", depArtifact.getExtension() );
+ assertEquals( "java", depArtifact.getProperty( "language", null ) );
+ assertEquals( "jar", depArtifact.getProperty( "type", null ) );
+ assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) );
+ assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
+ assertEquals( 4, depArtifact.getProperties().size() );
+
+ assertEquals( "compile", dep2.getScope() );
+ assertFalse( dep2.isOptional() );
+ assertEquals( 0, dep2.getExclusions().size() );
+ depArtifact = dep2.getArtifact();
+ assertEquals( "ut.simple", depArtifact.getGroupId() );
+ assertEquals( "dependency", depArtifact.getArtifactId() );
+ assertEquals( "1.0", depArtifact.getVersion() );
+ assertEquals( "1.0", depArtifact.getBaseVersion() );
+ assertNull( depArtifact.getFile() );
+ assertFalse( depArtifact.isSnapshot() );
+ assertEquals( "sources", depArtifact.getClassifier() );
+ assertEquals( "jar", depArtifact.getExtension() );
+ assertEquals( "java", depArtifact.getProperty( "language", null ) );
+ assertEquals( "jar", depArtifact.getProperty( "type", null ) ); // shouldn't it be java-sources given the classifier?
+ assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); // shouldn't it be false given the classifier?
+ assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
+ assertEquals( 4, depArtifact.getProperties().size() );
+ }
+
+ public void testCollectDependencies()
+ throws Exception
+ {
+ Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
+ // notice: extension and classifier not really used in this test...
+
+ CollectRequest collectRequest = new CollectRequest();
+ collectRequest.setRoot( new Dependency( artifact, null ) );
+ collectRequest.addRepository( newTestRepository() );
+
+ CollectResult collectResult = system.collectDependencies( session, collectRequest );
+
+ List<DependencyNode> nodes = collectResult.getRoot().getChildren();
+ assertEquals( 2, nodes.size() );
+ checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
+ }
+
+ public void testResolveArtifact()
+ throws Exception
+ {
+ Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" );
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact( artifact );
+ artifactRequest.addRepository( newTestRepository() );
+
+ ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
+ checkArtifactResult( artifactResult, "artifact-1.0.jar" );
+
+ artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" );
+ artifactRequest.setArtifact( artifact );
+ artifactResult = system.resolveArtifact( session, artifactRequest );
+ checkArtifactResult( artifactResult, "artifact-1.0.zip" );
+
+ artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" );
+ artifactRequest.setArtifact( artifact );
+ artifactResult = system.resolveArtifact( session, artifactRequest );
+ checkArtifactResult( artifactResult, "artifact-1.0-classifier.zip" );
+ }
+
+ private void checkArtifactResult( ArtifactResult result, String filename )
+ {
+ assertFalse( result.isMissing() );
+ assertTrue( result.isResolved() );
+ Artifact artifact = result.getArtifact();
+ assertNotNull( artifact.getFile() );
+ assertEquals( filename, artifact.getFile().getName() );
+ }
+
+ public void testResolveArtifacts()
+ throws Exception
+ {
+ ArtifactRequest req1 = new ArtifactRequest();
+ req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) );
+ req1.addRepository( newTestRepository() );
+
+ ArtifactRequest req2 = new ArtifactRequest();
+ req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) );
+ req2.addRepository( newTestRepository() );
+
+ ArtifactRequest req3 = new ArtifactRequest();
+ req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) );
+ req3.addRepository( newTestRepository() );
+
+ List<ArtifactRequest> requests = Arrays.asList( req1, req2, req3 );
+
+ List<ArtifactResult> results = system.resolveArtifacts( session, requests );
+
+ assertEquals( 3, results.size() );
+ checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" );
+ checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" );
+ checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" );
+ }
+
+ public void testResolveMetadata()
+ throws Exception
+ {
+ //List<MetadataResult> resolveMetadata( RepositorySystemSession session,
+ // Collection<? extends MetadataRequest> requests );
+ }
+
+ public void testInstall()
+ throws Exception
+ {
+ //InstallResult install( RepositorySystemSession session, InstallRequest request )
+ // throws InstallationException;
+ // release, snapshot unique ou non unique, attachement
+ }
+
+ public void testDeploy()
+ throws Exception
+ {
+ //DeployResult deploy( RepositorySystemSession session, DeployRequest request )
+ // throws DeploymentException;
+ }
+
+ public void testNewLocalRepositoryManager()
+ throws Exception
+ {
+ //LocalRepositoryManager newLocalRepositoryManager( LocalRepository localRepository );
+ }
+
+ public void testNewSyncContext()
+ throws Exception
+ {
+ //SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
new file mode 100644
index 0000000..2879a9f
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
@@ -0,0 +1,132 @@
+package org.apache.maven.repository.internal.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.PrintStream;
+
+import org.eclipse.aether.AbstractRepositoryListener;
+import org.eclipse.aether.RepositoryEvent;
+
+public class ConsoleRepositoryListener
+ extends AbstractRepositoryListener
+{
+
+ private PrintStream out;
+
+ public ConsoleRepositoryListener()
+ {
+ this( null );
+ }
+
+ public ConsoleRepositoryListener( PrintStream out )
+ {
+ this.out = ( out != null ) ? out : System.out;
+ }
+
+ public void artifactDeployed( RepositoryEvent event )
+ {
+ println( "artifactDeployed", event.getArtifact() + " to " + event.getRepository() );
+ }
+
+ public void artifactDeploying( RepositoryEvent event )
+ {
+ println( "artifactDeploying", event.getArtifact() + " to " + event.getRepository() );
+ }
+
+ public void artifactDescriptorInvalid( RepositoryEvent event )
+ {
+ println( "artifactDescriptorInvalid", "for " + event.getArtifact() + ": " + event.getException().getMessage() );
+ }
+
+ public void artifactDescriptorMissing( RepositoryEvent event )
+ {
+ println( "artifactDescriptorMissing", "for " + event.getArtifact() );
+ }
+
+ public void artifactInstalled( RepositoryEvent event )
+ {
+ println( "artifactInstalled", event.getArtifact() + " to " + event.getFile() );
+ }
+
+ public void artifactInstalling( RepositoryEvent event )
+ {
+ println( "artifactInstalling", event.getArtifact() + " to " + event.getFile() );
+ }
+
+ public void artifactResolved( RepositoryEvent event )
+ {
+ println( "artifactResolved", event.getArtifact() + " from " + event.getRepository() );
+ }
+
+ public void artifactDownloading( RepositoryEvent event )
+ {
+ println( "artifactDownloading", event.getArtifact() + " from " + event.getRepository() );
+ }
+
+ public void artifactDownloaded( RepositoryEvent event )
+ {
+ println( "artifactDownloaded", event.getArtifact() + " from " + event.getRepository() );
+ }
+
+ public void artifactResolving( RepositoryEvent event )
+ {
+ println( "artifactResolving", event.getArtifact().toString() );
+ }
+
+ public void metadataDeployed( RepositoryEvent event )
+ {
+ println( "metadataDeployed", event.getMetadata() + " to " + event.getRepository() );
+ }
+
+ public void metadataDeploying( RepositoryEvent event )
+ {
+ println( "metadataDeploying", event.getMetadata() + " to " + event.getRepository() );
+ }
+
+ public void metadataInstalled( RepositoryEvent event )
+ {
+ println( "metadataInstalled", event.getMetadata() + " to " + event.getFile() );
+ }
+
+ public void metadataInstalling( RepositoryEvent event )
+ {
+ println( "metadataInstalling", event.getMetadata() + " to " + event.getFile() );
+ }
+
+ public void metadataInvalid( RepositoryEvent event )
+ {
+ println( "metadataInvalid", event.getMetadata().toString() );
+ }
+
+ public void metadataResolved( RepositoryEvent event )
+ {
+ println( "metadataResolved", event.getMetadata() + " from " + event.getRepository() );
+ }
+
+ public void metadataResolving( RepositoryEvent event )
+ {
+ println( "metadataResolving", event.getMetadata() + " from " + event.getRepository() );
+ }
+
+ private void println( String event, String message )
+ {
+ out.println( "Aether Repository - " + event + ": " + message );
+ }
+}
[13/15] maven git commit: o Updated to 3.5.1-SNAPSHOT to make the ITs
run.
Posted by sc...@apache.org.
o Updated to 3.5.1-SNAPSHOT to make the ITs run.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/84dc4488
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/84dc4488
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/84dc4488
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 84dc4488158aeac24ac7db79b050a295de0990a6
Parents: 0e0a3fb
Author: Christian Schulte <sc...@apache.org>
Authored: Tue Jan 31 03:17:58 2017 +0100
Committer: Christian Schulte <sc...@apache.org>
Committed: Wed Feb 1 21:19:41 2017 +0100
----------------------------------------------------------------------
apache-maven/pom.xml | 2 +-
maven-artifact/pom.xml | 2 +-
maven-builder-support/pom.xml | 2 +-
maven-compat/pom.xml | 2 +-
maven-core/pom.xml | 2 +-
maven-embedder/pom.xml | 2 +-
maven-model-builder/pom.xml | 2 +-
maven-model/pom.xml | 2 +-
maven-plugin-api/pom.xml | 2 +-
maven-repository-metadata/pom.xml | 2 +-
maven-resolver-provider/pom.xml | 2 +-
maven-settings-builder/pom.xml | 2 +-
maven-settings/pom.xml | 2 +-
maven-slf4j-provider/pom.xml | 2 +-
pom.xml | 2 +-
15 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/apache-maven/pom.xml
----------------------------------------------------------------------
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index 6fc5a73..d313f80 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>apache-maven</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-artifact/pom.xml
----------------------------------------------------------------------
diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index e3943c9..b13482b 100644
--- a/maven-artifact/pom.xml
+++ b/maven-artifact/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-artifact</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-builder-support/pom.xml
----------------------------------------------------------------------
diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml
index 39eb161..5eb7903 100644
--- a/maven-builder-support/pom.xml
+++ b/maven-builder-support/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-builder-support</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-compat/pom.xml
----------------------------------------------------------------------
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index c740504..5e28de4 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-compat</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-core/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index 95162bd..b10b329 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-core</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 30ad2ce..66e09a3 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-embedder</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-model-builder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml
index fbfd417..7cef99b 100644
--- a/maven-model-builder/pom.xml
+++ b/maven-model-builder/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-model-builder</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-model/pom.xml
----------------------------------------------------------------------
diff --git a/maven-model/pom.xml b/maven-model/pom.xml
index 41cf168..aabb25d 100644
--- a/maven-model/pom.xml
+++ b/maven-model/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-model</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-plugin-api/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml
index d8f802d..1596a41 100644
--- a/maven-plugin-api/pom.xml
+++ b/maven-plugin-api/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-api</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-repository-metadata/pom.xml
----------------------------------------------------------------------
diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml
index 7480de7..dcc6a22 100644
--- a/maven-repository-metadata/pom.xml
+++ b/maven-repository-metadata/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-repository-metadata</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-resolver-provider/pom.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml
index 7d71e33..1540f9b 100644
--- a/maven-resolver-provider/pom.xml
+++ b/maven-resolver-provider/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-resolver-provider</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-settings-builder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml
index 2d415c9..904b085 100644
--- a/maven-settings-builder/pom.xml
+++ b/maven-settings-builder/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-settings-builder</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-settings/pom.xml
----------------------------------------------------------------------
diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml
index 133ee32..eb4ad22 100644
--- a/maven-settings/pom.xml
+++ b/maven-settings/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-settings</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/maven-slf4j-provider/pom.xml
----------------------------------------------------------------------
diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml
index 81af382..315b9a7 100644
--- a/maven-slf4j-provider/pom.xml
+++ b/maven-slf4j-provider/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
</parent>
<artifactId>maven-slf4j-provider</artifactId>
http://git-wip-us.apache.org/repos/asf/maven/blob/84dc4488/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 75bdb87..5b70125 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
</parent>
<artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Apache Maven</name>
[08/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
[MNG-6110] renamed 'maven-aether-provider' to 'maven-resolver-provider'
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/8972072e
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/8972072e
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/8972072e
Branch: refs/heads/DEPMGMT-IMPORT
Commit: 8972072e3200e2ecfe2acb6d0b2dc40b10a6bc31
Parents: 4d6c929
Author: Christian Schulte <sc...@apache.org>
Authored: Sun Dec 11 23:36:04 2016 +0100
Committer: Herv� Boutemy <hb...@apache.org>
Committed: Wed Feb 1 07:59:53 2017 +0100
----------------------------------------------------------------------
maven-aether-provider/pom.xml | 128 ----
.../ArtifactDescriptorReaderDelegate.java | 153 -----
.../internal/ArtifactDescriptorUtils.java | 81 ---
.../DefaultArtifactDescriptorReader.java | 415 -------------
.../repository/internal/DefaultModelCache.java | 119 ----
.../internal/DefaultModelResolver.java | 229 -------
.../internal/DefaultVersionRangeResolver.java | 307 ---------
.../internal/DefaultVersionResolver.java | 617 -------------------
.../internal/LocalSnapshotMetadata.java | 163 -----
.../LocalSnapshotMetadataGenerator.java | 82 ---
.../repository/internal/MavenAetherModule.java | 76 ---
.../repository/internal/MavenMetadata.java | 137 ----
.../internal/MavenRepositorySystemUtils.java | 145 -----
.../internal/MavenSnapshotMetadata.java | 100 ---
.../internal/MavenWorkspaceReader.java | 32 -
.../repository/internal/RelocatedArtifact.java | 114 ----
.../internal/RemoteSnapshotMetadata.java | 157 -----
.../RemoteSnapshotMetadataGenerator.java | 107 ----
.../SnapshotMetadataGeneratorFactory.java | 52 --
.../repository/internal/VersionsMetadata.java | 133 ----
.../internal/VersionsMetadataGenerator.java | 108 ----
.../VersionsMetadataGeneratorFactory.java | 52 --
.../maven/repository/internal/package-info.java | 25 -
maven-aether-provider/src/site/apt/index.apt | 33 -
maven-aether-provider/src/site/site.xml | 36 --
.../internal/AbstractRepositoryTestCase.java | 87 ---
.../DefaultArtifactDescriptorReaderTest.java | 77 ---
.../internal/DefaultVersionResolverTest.java | 96 ---
.../MavenRepositorySystemUtilsTest.java | 45 --
.../internal/RemoteSnapshotMetadataTest.java | 82 ---
.../internal/RepositorySystemTest.java | 220 -------
.../util/ConsoleRepositoryListener.java | 132 ----
.../internal/util/ConsoleTransferListener.java | 186 ------
.../07.20.3-SNAPSHOT/maven-metadata.xml | 49 --
.../0.4.0-SNAPSHOT/maven-metadata.xml | 47 --
.../artifact/1.0/artifact-1.0-classifier.zip | 0
.../ut/simple/artifact/1.0/artifact-1.0.jar | 0
.../ut/simple/artifact/1.0/artifact-1.0.pom | 48 --
.../ut/simple/artifact/1.0/artifact-1.0.zip | 0
.../repo/ut/simple/artifact/maven-metadata.xml | 34 -
.../dependency/1.0/dependency-1.0-sources.jar | 0
.../ut/simple/dependency/1.0/dependency-1.0.jar | 0
.../ut/simple/dependency/1.0/dependency-1.0.pom | 31 -
.../ut/simple/dependency/maven-metadata.xml | 34 -
.../repo/ut/simple/parent/1.0/parent-1.0.pom | 43 --
.../repo/ut/simple/parent/maven-metadata.xml | 34 -
maven-compat/pom.xml | 2 +-
maven-core/pom.xml | 2 +-
.../main/resources/META-INF/maven/extension.xml | 13 +-
maven-resolver-provider/pom.xml | 128 ++++
.../ArtifactDescriptorReaderDelegate.java | 153 +++++
.../internal/ArtifactDescriptorUtils.java | 81 +++
.../DefaultArtifactDescriptorReader.java | 415 +++++++++++++
.../repository/internal/DefaultModelCache.java | 119 ++++
.../internal/DefaultModelResolver.java | 229 +++++++
.../internal/DefaultVersionRangeResolver.java | 307 +++++++++
.../internal/DefaultVersionResolver.java | 617 +++++++++++++++++++
.../internal/LocalSnapshotMetadata.java | 163 +++++
.../LocalSnapshotMetadataGenerator.java | 82 +++
.../repository/internal/MavenAetherModule.java | 80 +++
.../repository/internal/MavenMetadata.java | 137 ++++
.../internal/MavenRepositorySystemUtils.java | 145 +++++
.../internal/MavenResolverModule.java | 70 +++
.../internal/MavenSnapshotMetadata.java | 100 +++
.../internal/MavenWorkspaceReader.java | 32 +
.../repository/internal/RelocatedArtifact.java | 114 ++++
.../internal/RemoteSnapshotMetadata.java | 157 +++++
.../RemoteSnapshotMetadataGenerator.java | 107 ++++
.../SnapshotMetadataGeneratorFactory.java | 52 ++
.../repository/internal/VersionsMetadata.java | 133 ++++
.../internal/VersionsMetadataGenerator.java | 108 ++++
.../VersionsMetadataGeneratorFactory.java | 52 ++
.../maven/repository/internal/package-info.java | 25 +
maven-resolver-provider/src/site/apt/index.apt | 33 +
maven-resolver-provider/src/site/site.xml | 36 ++
.../internal/AbstractRepositoryTestCase.java | 87 +++
.../DefaultArtifactDescriptorReaderTest.java | 77 +++
.../internal/DefaultVersionResolverTest.java | 96 +++
.../MavenRepositorySystemUtilsTest.java | 45 ++
.../internal/RemoteSnapshotMetadataTest.java | 82 +++
.../internal/RepositorySystemTest.java | 220 +++++++
.../util/ConsoleRepositoryListener.java | 132 ++++
.../internal/util/ConsoleTransferListener.java | 186 ++++++
.../07.20.3-SNAPSHOT/maven-metadata.xml | 49 ++
.../0.4.0-SNAPSHOT/maven-metadata.xml | 47 ++
.../artifact/1.0/artifact-1.0-classifier.zip | 0
.../ut/simple/artifact/1.0/artifact-1.0.jar | 0
.../ut/simple/artifact/1.0/artifact-1.0.pom | 48 ++
.../ut/simple/artifact/1.0/artifact-1.0.zip | 0
.../repo/ut/simple/artifact/maven-metadata.xml | 34 +
.../dependency/1.0/dependency-1.0-sources.jar | 0
.../ut/simple/dependency/1.0/dependency-1.0.jar | 0
.../ut/simple/dependency/1.0/dependency-1.0.pom | 31 +
.../ut/simple/dependency/maven-metadata.xml | 34 +
.../repo/ut/simple/parent/1.0/parent-1.0.pom | 43 ++
.../repo/ut/simple/parent/maven-metadata.xml | 34 +
pom.xml | 4 +-
97 files changed, 4932 insertions(+), 4855 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/pom.xml
----------------------------------------------------------------------
diff --git a/maven-aether-provider/pom.xml b/maven-aether-provider/pom.xml
deleted file mode 100644
index 91d1ae7..0000000
--- a/maven-aether-provider/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-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.
--->
-
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven</artifactId>
- <version>3.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>maven-aether-provider</artifactId>
-
- <name>Maven Aether Provider</name>
- <description>Extensions to Maven Resolver for utilizing Maven POM and repository metadata.</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model-builder</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-repository-metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <classifier>no_aop</classifier>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <!-- Testing -->
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-connector-basic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-transport-wagon</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-file</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>org.eclipse.sisu.plexus</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.9.5</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
-
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
deleted file mode 100644
index 2395b36..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.License;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Prerequisites;
-import org.apache.maven.model.Repository;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.ArtifactProperties;
-import org.eclipse.aether.artifact.ArtifactType;
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.artifact.DefaultArtifactType;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.Exclusion;
-import org.eclipse.aether.resolution.ArtifactDescriptorResult;
-
-/**
- * Populates Aether {@link ArtifactDescriptorResult} from Maven project {@link Model}.
- *
- * @since 3.2.4
- * @provisional This class is part of work in progress and can be changed or removed without notice.
- */
-public class ArtifactDescriptorReaderDelegate
-{
- public void populateResult( RepositorySystemSession session, ArtifactDescriptorResult result, Model model )
- {
- ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
-
- for ( Repository r : model.getRepositories() )
- {
- result.addRepository( ArtifactDescriptorUtils.toRemoteRepository( r ) );
- }
-
- for ( org.apache.maven.model.Dependency dependency : model.getDependencies() )
- {
- result.addDependency( convert( dependency, stereotypes ) );
- }
-
- DependencyManagement mngt = model.getDependencyManagement();
- if ( mngt != null )
- {
- for ( org.apache.maven.model.Dependency dependency : mngt.getDependencies() )
- {
- result.addManagedDependency( convert( dependency, stereotypes ) );
- }
- }
-
- Map<String, Object> properties = new LinkedHashMap<>();
-
- Prerequisites prerequisites = model.getPrerequisites();
- if ( prerequisites != null )
- {
- properties.put( "prerequisites.maven", prerequisites.getMaven() );
- }
-
- List<License> licenses = model.getLicenses();
- properties.put( "license.count", licenses.size() );
- for ( int i = 0; i < licenses.size(); i++ )
- {
- License license = licenses.get( i );
- properties.put( "license." + i + ".name", license.getName() );
- properties.put( "license." + i + ".url", license.getUrl() );
- properties.put( "license." + i + ".comments", license.getComments() );
- properties.put( "license." + i + ".distribution", license.getDistribution() );
- }
-
- result.setProperties( properties );
-
- setArtifactProperties( result, model );
- }
-
- private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes )
- {
- ArtifactType stereotype = stereotypes.get( dependency.getType() );
- if ( stereotype == null )
- {
- stereotype = new DefaultArtifactType( dependency.getType() );
- }
-
- boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0;
-
- Map<String, String> props = null;
- if ( system )
- {
- props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() );
- }
-
- Artifact artifact =
- new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
- dependency.getVersion(), props, stereotype );
-
- List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() );
- for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
- {
- exclusions.add( convert( exclusion ) );
- }
-
- Dependency result = new Dependency( artifact, dependency.getScope(), dependency.isOptional(), exclusions );
-
- return result;
- }
-
- private Exclusion convert( org.apache.maven.model.Exclusion exclusion )
- {
- return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" );
- }
-
- private void setArtifactProperties( ArtifactDescriptorResult result, Model model )
- {
- String downloadUrl = null;
- DistributionManagement distMngt = model.getDistributionManagement();
- if ( distMngt != null )
- {
- downloadUrl = distMngt.getDownloadUrl();
- }
- if ( downloadUrl != null && downloadUrl.length() > 0 )
- {
- Artifact artifact = result.getArtifact();
- Map<String, String> props = new HashMap<>( artifact.getProperties() );
- props.put( ArtifactProperties.DOWNLOAD_URL, downloadUrl );
- result.setArtifact( artifact.setProperties( props ) );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
deleted file mode 100644
index 7d4ede8..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.model.Repository;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-
-/**
- * <strong>Warning:</strong> This is an internal utility class that is only public for technical reasons, it is not part
- * of the public API. In particular, this class can be changed or deleted without prior notice.
- *
- * @author Benjamin Bentmann
- */
-public class ArtifactDescriptorUtils
-{
-
- public static Artifact toPomArtifact( Artifact artifact )
- {
- Artifact pomArtifact = artifact;
-
- if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
- {
- pomArtifact =
- new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion() );
- }
-
- return pomArtifact;
- }
-
- public static RemoteRepository toRemoteRepository( Repository repository )
- {
- RemoteRepository.Builder builder =
- new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() );
- builder.setSnapshotPolicy( toRepositoryPolicy( repository.getSnapshots() ) );
- builder.setReleasePolicy( toRepositoryPolicy( repository.getReleases() ) );
- return builder.build();
- }
-
- public static RepositoryPolicy toRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy )
- {
- boolean enabled = true;
- String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN;
- String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
-
- if ( policy != null )
- {
- enabled = policy.isEnabled();
- if ( policy.getUpdatePolicy() != null )
- {
- updates = policy.getUpdatePolicy();
- }
- if ( policy.getChecksumPolicy() != null )
- {
- checksums = policy.getChecksumPolicy();
- }
- }
-
- return new RepositoryPolicy( enabled, updates, checksums );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
deleted file mode 100644
index 0f31330..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
+++ /dev/null
@@ -1,415 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.commons.lang3.Validate;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Relocation;
-import org.apache.maven.model.building.DefaultModelBuilderFactory;
-import org.apache.maven.model.building.DefaultModelBuildingRequest;
-import org.apache.maven.model.building.FileModelSource;
-import org.apache.maven.model.building.ModelBuilder;
-import org.apache.maven.model.building.ModelBuildingException;
-import org.apache.maven.model.building.ModelBuildingRequest;
-import org.apache.maven.model.building.ModelProblem;
-import org.apache.maven.model.resolution.UnresolvableModelException;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.eclipse.aether.RepositoryEvent;
-import org.eclipse.aether.RepositoryEvent.EventType;
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.ArtifactResolver;
-import org.eclipse.aether.impl.RemoteRepositoryManager;
-import org.eclipse.aether.impl.RepositoryEventDispatcher;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.repository.WorkspaceRepository;
-import org.eclipse.aether.resolution.ArtifactDescriptorException;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicyRequest;
-import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
-import org.eclipse.aether.resolution.ArtifactDescriptorResult;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.resolution.VersionRequest;
-import org.eclipse.aether.resolution.VersionResolutionException;
-import org.eclipse.aether.resolution.VersionResult;
-import org.eclipse.aether.spi.locator.Service;
-import org.eclipse.aether.spi.locator.ServiceLocator;
-import org.eclipse.aether.spi.log.Logger;
-import org.eclipse.aether.spi.log.LoggerFactory;
-import org.eclipse.aether.spi.log.NullLoggerFactory;
-import org.eclipse.aether.transfer.ArtifactNotFoundException;
-
-/**
- * @author Benjamin Bentmann
- */
-@Named
-@Component( role = ArtifactDescriptorReader.class )
-public class DefaultArtifactDescriptorReader
- implements ArtifactDescriptorReader, Service
-{
-
- @SuppressWarnings( "unused" )
- @Requirement( role = LoggerFactory.class )
- private Logger logger = NullLoggerFactory.LOGGER;
-
- @Requirement
- private RemoteRepositoryManager remoteRepositoryManager;
-
- @Requirement
- private VersionResolver versionResolver;
-
- @Requirement
- private VersionRangeResolver versionRangeResolver;
-
- @Requirement
- private ArtifactResolver artifactResolver;
-
- @Requirement
- private RepositoryEventDispatcher repositoryEventDispatcher;
-
- @Requirement
- private ModelBuilder modelBuilder;
-
- public DefaultArtifactDescriptorReader()
- {
- // enable no-arg constructor
- }
-
- @Inject
- DefaultArtifactDescriptorReader( RemoteRepositoryManager remoteRepositoryManager, VersionResolver versionResolver,
- ArtifactResolver artifactResolver, ModelBuilder modelBuilder,
- RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
- {
- setRemoteRepositoryManager( remoteRepositoryManager );
- setVersionResolver( versionResolver );
- setArtifactResolver( artifactResolver );
- setModelBuilder( modelBuilder );
- setLoggerFactory( loggerFactory );
- setRepositoryEventDispatcher( repositoryEventDispatcher );
- }
-
- public void initService( ServiceLocator locator )
- {
- setLoggerFactory( locator.getService( LoggerFactory.class ) );
- setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
- setVersionResolver( locator.getService( VersionResolver.class ) );
- setVersionRangeResolver( locator.getService( VersionRangeResolver.class ) );
- setArtifactResolver( locator.getService( ArtifactResolver.class ) );
- setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
- modelBuilder = locator.getService( ModelBuilder.class );
- if ( modelBuilder == null )
- {
- setModelBuilder( new DefaultModelBuilderFactory().newInstance() );
- }
- }
-
- public DefaultArtifactDescriptorReader setLoggerFactory( LoggerFactory loggerFactory )
- {
- this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
- return this;
- }
-
- void setLogger( LoggerFactory loggerFactory )
- {
- // plexus support
- setLoggerFactory( loggerFactory );
- }
-
- public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager )
- {
- this.remoteRepositoryManager = Validate.notNull( remoteRepositoryManager,
- "remoteRepositoryManager cannot be null" );
- return this;
- }
-
- public DefaultArtifactDescriptorReader setVersionResolver( VersionResolver versionResolver )
- {
- this.versionResolver = Validate.notNull( versionResolver, "versionResolver cannot be null" );
- return this;
- }
-
- /** @since 3.2.2 */
- public DefaultArtifactDescriptorReader setVersionRangeResolver( VersionRangeResolver versionRangeResolver )
- {
- this.versionRangeResolver = Validate.notNull( versionRangeResolver, "versionRangeResolver cannot be null" );
- return this;
- }
-
- public DefaultArtifactDescriptorReader setArtifactResolver( ArtifactResolver artifactResolver )
- {
- this.artifactResolver = Validate.notNull( artifactResolver, "artifactResolver cannot be null" );
- return this;
- }
-
- public DefaultArtifactDescriptorReader setRepositoryEventDispatcher(
- RepositoryEventDispatcher repositoryEventDispatcher )
- {
- this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
- "repositoryEventDispatcher cannot be null" );
- return this;
- }
-
- public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder )
- {
- this.modelBuilder = Validate.notNull( modelBuilder, "modelBuilder cannot be null" );
- return this;
- }
-
- public ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session,
- ArtifactDescriptorRequest request )
- throws ArtifactDescriptorException
- {
- ArtifactDescriptorResult result = new ArtifactDescriptorResult( request );
-
- Model model = loadPom( session, request, result );
- if ( model != null )
- {
- Map<String, Object> config = session.getConfigProperties();
- ArtifactDescriptorReaderDelegate delegate =
- (ArtifactDescriptorReaderDelegate) config.get( ArtifactDescriptorReaderDelegate.class.getName() );
-
- if ( delegate == null )
- {
- delegate = new ArtifactDescriptorReaderDelegate();
- }
-
- delegate.populateResult( session, result, model );
- }
-
- return result;
- }
-
- private Model loadPom( RepositorySystemSession session, ArtifactDescriptorRequest request,
- ArtifactDescriptorResult result )
- throws ArtifactDescriptorException
- {
- RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
-
- Set<String> visited = new LinkedHashSet<>();
- for ( Artifact a = request.getArtifact();; )
- {
- Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( a );
- try
- {
- VersionRequest versionRequest =
- new VersionRequest( a, request.getRepositories(), request.getRequestContext() );
- versionRequest.setTrace( trace );
- VersionResult versionResult = versionResolver.resolveVersion( session, versionRequest );
-
- a = a.setVersion( versionResult.getVersion() );
-
- versionRequest =
- new VersionRequest( pomArtifact, request.getRepositories(), request.getRequestContext() );
- versionRequest.setTrace( trace );
- versionResult = versionResolver.resolveVersion( session, versionRequest );
-
- pomArtifact = pomArtifact.setVersion( versionResult.getVersion() );
- }
- catch ( VersionResolutionException e )
- {
- result.addException( e );
- throw new ArtifactDescriptorException( result );
- }
-
- if ( !visited.add( a.getGroupId() + ':' + a.getArtifactId() + ':' + a.getBaseVersion() ) )
- {
- RepositoryException exception =
- new RepositoryException( "Artifact relocations form a cycle: " + visited );
- invalidDescriptor( session, trace, a, exception );
- if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 )
- {
- return null;
- }
- result.addException( exception );
- throw new ArtifactDescriptorException( result );
- }
-
- ArtifactResult resolveResult;
- try
- {
- ArtifactRequest resolveRequest =
- new ArtifactRequest( pomArtifact, request.getRepositories(), request.getRequestContext() );
- resolveRequest.setTrace( trace );
- resolveResult = artifactResolver.resolveArtifact( session, resolveRequest );
- pomArtifact = resolveResult.getArtifact();
- result.setRepository( resolveResult.getRepository() );
- }
- catch ( ArtifactResolutionException e )
- {
- if ( e.getCause() instanceof ArtifactNotFoundException )
- {
- missingDescriptor( session, trace, a, (Exception) e.getCause() );
- if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_MISSING ) != 0 )
- {
- return null;
- }
- }
- result.addException( e );
- throw new ArtifactDescriptorException( result );
- }
-
- Model model;
-
- // hack: don't rebuild model if it was already loaded during reactor resolution
- final WorkspaceReader workspace = session.getWorkspaceReader();
- if ( workspace instanceof MavenWorkspaceReader )
- {
- model = ( (MavenWorkspaceReader) workspace ).findModel( pomArtifact );
- if ( model != null )
- {
- return model;
- }
- }
-
- try
- {
- ModelBuildingRequest modelRequest = new DefaultModelBuildingRequest();
- modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
- modelRequest.setProcessPlugins( false );
- modelRequest.setTwoPhaseBuilding( false );
- modelRequest.setSystemProperties( toProperties( session.getUserProperties(),
- session.getSystemProperties() ) );
- modelRequest.setModelCache( DefaultModelCache.newInstance( session ) );
- modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ),
- request.getRequestContext(), artifactResolver,
- versionRangeResolver, remoteRepositoryManager,
- request.getRepositories() ) );
- if ( resolveResult.getRepository() instanceof WorkspaceRepository )
- {
- modelRequest.setPomFile( pomArtifact.getFile() );
- }
- else
- {
- modelRequest.setModelSource( new FileModelSource( pomArtifact.getFile() ) );
- }
-
- model = modelBuilder.build( modelRequest ).getEffectiveModel();
- }
- catch ( ModelBuildingException e )
- {
- for ( ModelProblem problem : e.getProblems() )
- {
- if ( problem.getException() instanceof UnresolvableModelException )
- {
- result.addException( problem.getException() );
- throw new ArtifactDescriptorException( result );
- }
- }
- invalidDescriptor( session, trace, a, e );
- if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 )
- {
- return null;
- }
- result.addException( e );
- throw new ArtifactDescriptorException( result );
- }
-
- Relocation relocation = getRelocation( model );
-
- if ( relocation != null )
- {
- result.addRelocation( a );
- a =
- new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(),
- relocation.getVersion() );
- result.setArtifact( a );
- }
- else
- {
- return model;
- }
- }
- }
-
- private Properties toProperties( Map<String, String> dominant, Map<String, String> recessive )
- {
- Properties props = new Properties();
- if ( recessive != null )
- {
- props.putAll( recessive );
- }
- if ( dominant != null )
- {
- props.putAll( dominant );
- }
- return props;
- }
-
- private Relocation getRelocation( Model model )
- {
- Relocation relocation = null;
- DistributionManagement distMngt = model.getDistributionManagement();
- if ( distMngt != null )
- {
- relocation = distMngt.getRelocation();
- }
- return relocation;
- }
-
- private void missingDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
- Exception exception )
- {
- RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_MISSING );
- event.setTrace( trace );
- event.setArtifact( artifact );
- event.setException( exception );
-
- repositoryEventDispatcher.dispatch( event.build() );
- }
-
- private void invalidDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
- Exception exception )
- {
- RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_INVALID );
- event.setTrace( trace );
- event.setArtifact( artifact );
- event.setException( exception );
-
- repositoryEventDispatcher.dispatch( event.build() );
- }
-
- private int getPolicy( RepositorySystemSession session, Artifact a, ArtifactDescriptorRequest request )
- {
- ArtifactDescriptorPolicy policy = session.getArtifactDescriptorPolicy();
- if ( policy == null )
- {
- return ArtifactDescriptorPolicy.STRICT;
- }
- return policy.getPolicy( session, new ArtifactDescriptorPolicyRequest( a, request.getRequestContext() ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
deleted file mode 100644
index f13495d..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.model.building.ModelCache;
-import org.eclipse.aether.RepositoryCache;
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A model builder cache backed by the repository system cache.
- *
- * @author Benjamin Bentmann
- */
-class DefaultModelCache
- implements ModelCache
-{
-
- private final RepositorySystemSession session;
-
- private final RepositoryCache cache;
-
- public static ModelCache newInstance( RepositorySystemSession session )
- {
- if ( session.getCache() == null )
- {
- return null;
- }
- else
- {
- return new DefaultModelCache( session );
- }
- }
-
- private DefaultModelCache( RepositorySystemSession session )
- {
- this.session = session;
- this.cache = session.getCache();
- }
-
- public Object get( String groupId, String artifactId, String version, String tag )
- {
- return cache.get( session, new Key( groupId, artifactId, version, tag ) );
- }
-
- public void put( String groupId, String artifactId, String version, String tag, Object data )
- {
- cache.put( session, new Key( groupId, artifactId, version, tag ), data );
- }
-
- static class Key
- {
-
- private final String groupId;
-
- private final String artifactId;
-
- private final String version;
-
- private final String tag;
-
- private final int hash;
-
- public Key( String groupId, String artifactId, String version, String tag )
- {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.version = version;
- this.tag = tag;
-
- int h = 17;
- h = h * 31 + this.groupId.hashCode();
- h = h * 31 + this.artifactId.hashCode();
- h = h * 31 + this.version.hashCode();
- h = h * 31 + this.tag.hashCode();
- hash = h;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( null == obj || !getClass().equals( obj.getClass() ) )
- {
- return false;
- }
-
- Key that = (Key) obj;
- return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
- && version.equals( that.version ) && tag.equals( that.tag );
- }
-
- @Override
- public int hashCode()
- {
- return hash;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
deleted file mode 100644
index f344959..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Repository;
-import org.apache.maven.model.building.FileModelSource;
-import org.apache.maven.model.building.ModelSource;
-import org.apache.maven.model.resolution.InvalidRepositoryException;
-import org.apache.maven.model.resolution.ModelResolver;
-import org.apache.maven.model.resolution.UnresolvableModelException;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.impl.ArtifactResolver;
-import org.eclipse.aether.impl.RemoteRepositoryManager;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResolutionException;
-import org.eclipse.aether.resolution.VersionRangeResult;
-
-/**
- * A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have
- * been initially specified and repositories discovered in dependency POMs are recessively merged into the search chain.
- *
- * @author Benjamin Bentmann
- * @see DefaultArtifactDescriptorReader
- */
-class DefaultModelResolver
- implements ModelResolver
-{
-
- private final RepositorySystemSession session;
-
- private final RequestTrace trace;
-
- private final String context;
-
- private List<RemoteRepository> repositories;
-
- private final List<RemoteRepository> externalRepositories;
-
- private final ArtifactResolver resolver;
-
- private final VersionRangeResolver versionRangeResolver;
-
- private final RemoteRepositoryManager remoteRepositoryManager;
-
- private final Set<String> repositoryIds;
-
- public DefaultModelResolver( RepositorySystemSession session, RequestTrace trace, String context,
- ArtifactResolver resolver, VersionRangeResolver versionRangeResolver,
- RemoteRepositoryManager remoteRepositoryManager, List<RemoteRepository> repositories )
- {
- this.session = session;
- this.trace = trace;
- this.context = context;
- this.resolver = resolver;
- this.versionRangeResolver = versionRangeResolver;
- this.remoteRepositoryManager = remoteRepositoryManager;
- this.repositories = repositories;
- List<RemoteRepository> externalRepositories = new ArrayList<>();
- externalRepositories.addAll( repositories );
- this.externalRepositories = Collections.unmodifiableList( externalRepositories );
-
- this.repositoryIds = new HashSet<>();
- }
-
- private DefaultModelResolver( DefaultModelResolver original )
- {
- this.session = original.session;
- this.trace = original.trace;
- this.context = original.context;
- this.resolver = original.resolver;
- this.versionRangeResolver = original.versionRangeResolver;
- this.remoteRepositoryManager = original.remoteRepositoryManager;
- this.repositories = new ArrayList<>( original.repositories );
- this.externalRepositories = original.externalRepositories;
- this.repositoryIds = new HashSet<>( original.repositoryIds );
- }
-
- @Override
- public void addRepository( Repository repository )
- throws InvalidRepositoryException
- {
- addRepository( repository, false );
- }
-
- @Override
- public void addRepository( final Repository repository, boolean replace )
- throws InvalidRepositoryException
- {
- if ( session.isIgnoreArtifactDescriptorRepositories() )
- {
- return;
- }
-
- if ( !repositoryIds.add( repository.getId() ) )
- {
- if ( !replace )
- {
- return;
- }
-
- removeMatchingRepository( repositories, repository.getId() );
- }
-
- List<RemoteRepository> newRepositories =
- Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );
-
- this.repositories =
- remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true );
- }
-
- private static void removeMatchingRepository( Iterable<RemoteRepository> repositories, final String id )
- {
- Iterables.removeIf( repositories, new Predicate<RemoteRepository>()
- {
- @Override
- public boolean apply( RemoteRepository remoteRepository )
- {
- return remoteRepository.getId().equals( id );
- }
- } );
- }
-
- @Override
- public ModelResolver newCopy()
- {
- return new DefaultModelResolver( this );
- }
-
- @Override
- public ModelSource resolveModel( String groupId, String artifactId, String version )
- throws UnresolvableModelException
- {
- Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
-
- try
- {
- ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
- request.setTrace( trace );
- pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
- }
- catch ( ArtifactResolutionException e )
- {
- throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
- }
-
- File pomFile = pomArtifact.getFile();
-
- return new FileModelSource( pomFile );
- }
-
- public ModelSource resolveModel( Parent parent )
- throws UnresolvableModelException
- {
- Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom",
- parent.getVersion() );
-
- VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
- versionRangeRequest.setTrace( trace );
-
- try
- {
- VersionRangeResult versionRangeResult =
- versionRangeResolver.resolveVersionRange( session, versionRangeRequest );
-
- if ( versionRangeResult.getHighestVersion() == null )
- {
- throw new UnresolvableModelException( "No versions matched the requested range '" + parent.getVersion()
- + "'", parent.getGroupId(), parent.getArtifactId(),
- parent.getVersion() );
-
- }
-
- if ( versionRangeResult.getVersionConstraint() != null
- && versionRangeResult.getVersionConstraint().getRange() != null
- && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
- {
- throw new UnresolvableModelException( "The requested version range '" + parent.getVersion()
- + "' does not specify an upper bound", parent.getGroupId(),
- parent.getArtifactId(), parent.getVersion() );
-
- }
-
- parent.setVersion( versionRangeResult.getHighestVersion().toString() );
- }
- catch ( VersionRangeResolutionException e )
- {
- throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
- parent.getVersion(), e );
-
- }
-
- return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
deleted file mode 100644
index ddd3e97..0000000
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
+++ /dev/null
@@ -1,307 +0,0 @@
-package org.apache.maven.repository.internal;
-
-/*
- * 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.commons.lang3.Validate;
-import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.util.IOUtil;
-import org.eclipse.aether.RepositoryEvent;
-import org.eclipse.aether.RepositoryEvent.EventType;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.SyncContext;
-import org.eclipse.aether.impl.MetadataResolver;
-import org.eclipse.aether.impl.RepositoryEventDispatcher;
-import org.eclipse.aether.impl.SyncContextFactory;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.metadata.DefaultMetadata;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.resolution.MetadataRequest;
-import org.eclipse.aether.resolution.MetadataResult;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResolutionException;
-import org.eclipse.aether.resolution.VersionRangeResult;
-import org.eclipse.aether.spi.locator.Service;
-import org.eclipse.aether.spi.locator.ServiceLocator;
-import org.eclipse.aether.spi.log.Logger;
-import org.eclipse.aether.spi.log.LoggerFactory;
-import org.eclipse.aether.spi.log.NullLoggerFactory;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-import org.eclipse.aether.version.VersionScheme;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Benjamin Bentmann
- */
-@Named
-@Component( role = VersionRangeResolver.class )
-public class DefaultVersionRangeResolver
- implements VersionRangeResolver, Service
-{
-
- private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
-
- @SuppressWarnings( "unused" )
- @Requirement( role = LoggerFactory.class )
- private Logger logger = NullLoggerFactory.LOGGER;
-
- @Requirement
- private MetadataResolver metadataResolver;
-
- @Requirement
- private SyncContextFactory syncContextFactory;
-
- @Requirement
- private RepositoryEventDispatcher repositoryEventDispatcher;
-
- public DefaultVersionRangeResolver()
- {
- // enable default constructor
- }
-
- @Inject
- DefaultVersionRangeResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory,
- RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
- {
- setMetadataResolver( metadataResolver );
- setSyncContextFactory( syncContextFactory );
- setLoggerFactory( loggerFactory );
- setRepositoryEventDispatcher( repositoryEventDispatcher );
- }
-
- public void initService( ServiceLocator locator )
- {
- setLoggerFactory( locator.getService( LoggerFactory.class ) );
- setMetadataResolver( locator.getService( MetadataResolver.class ) );
- setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
- setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
- }
-
- public DefaultVersionRangeResolver setLoggerFactory( LoggerFactory loggerFactory )
- {
- this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() );
- return this;
- }
-
- void setLogger( LoggerFactory loggerFactory )
- {
- // plexus support
- setLoggerFactory( loggerFactory );
- }
-
- public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver )
- {
- this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
- return this;
- }
-
- public DefaultVersionRangeResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
- {
- this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
- return this;
- }
-
- public DefaultVersionRangeResolver setRepositoryEventDispatcher(
- RepositoryEventDispatcher repositoryEventDispatcher )
- {
- this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
- "repositoryEventDispatcher cannot be null" );
- return this;
- }
-
- public VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
- throws VersionRangeResolutionException
- {
- VersionRangeResult result = new VersionRangeResult( request );
-
- VersionScheme versionScheme = new GenericVersionScheme();
-
- VersionConstraint versionConstraint;
- try
- {
- versionConstraint = versionScheme.parseVersionConstraint( request.getArtifact().getVersion() );
- }
- catch ( InvalidVersionSpecificationException e )
- {
- result.addException( e );
- throw new VersionRangeResolutionException( result );
- }
-
- result.setVersionConstraint( versionConstraint );
-
- if ( versionConstraint.getRange() == null )
- {
- result.addVersion( versionConstraint.getVersion() );
- }
- else
- {
- Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
-
- List<Version> versions = new ArrayList<>();
- for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
- {
- try
- {
- Version ver = versionScheme.parseVersion( v.getKey() );
- if ( versionConstraint.containsVersion( ver ) )
- {
- versions.add( ver );
- result.setRepository( ver, v.getValue() );
- }
- }
- catch ( InvalidVersionSpecificationException e )
- {
- result.addException( e );
- }
- }
-
- Collections.sort( versions );
- result.setVersions( versions );
- }
-
- return result;
- }
-
- private Map<String, ArtifactRepository> getVersions( RepositorySystemSession session, VersionRangeResult result,
- VersionRangeRequest request )
- {
- RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
-
- Map<String, ArtifactRepository> versionIndex = new HashMap<>();
-
- Metadata metadata =
- new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(),
- MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
-
- List<MetadataRequest> metadataRequests = new ArrayList<>( request.getRepositories().size() );
-
- metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
-
- for ( RemoteRepository repository : request.getRepositories() )
- {
- MetadataRequest metadataRequest = new MetadataRequest( metadata, repository, request.getRequestContext() );
- metadataRequest.setDeleteLocalCopyIfMissing( true );
- metadataRequest.setTrace( trace );
- metadataRequests.add( metadataRequest );
- }
-
- List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
-
- WorkspaceReader workspace = session.getWorkspaceReader();
- if ( workspace != null )
- {
- List<String> versions = workspace.findVersions( request.getArtifact() );
- for ( String version : versions )
- {
- versionIndex.put( version, workspace.getRepository() );
- }
- }
-
- for ( MetadataResult metadataResult : metadataResults )
- {
- result.addException( metadataResult.getException() );
-
- ArtifactRepository repository = metadataResult.getRequest().getRepository();
- if ( repository == null )
- {
- repository = session.getLocalRepository();
- }
-
- Versioning versioning = readVersions( session, trace, metadataResult.getMetadata(), repository, result );
- for ( String version : versioning.getVersions() )
- {
- if ( !versionIndex.containsKey( version ) )
- {
- versionIndex.put( version, repository );
- }
- }
- }
-
- return versionIndex;
- }
-
- private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
- ArtifactRepository repository, VersionRangeResult result )
- {
- Versioning versioning = null;
-
- FileInputStream fis = null;
- try
- {
- if ( metadata != null )
- {
-
- try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
- {
- syncContext.acquire( null, Collections.singleton( metadata ) );
-
- if ( metadata.getFile() != null && metadata.getFile().exists() )
- {
- fis = new FileInputStream( metadata.getFile() );
- org.apache.maven.artifact.repository.metadata.Metadata m =
- new MetadataXpp3Reader().read( fis, false );
- versioning = m.getVersioning();
- }
- }
- }
- }
- catch ( Exception e )
- {
- invalidMetadata( session, trace, metadata, repository, e );
- result.addException( e );
- }
- finally
- {
- IOUtil.close( fis );
- }
-
- return ( versioning != null ) ? versioning : new Versioning();
- }
-
- private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
- ArtifactRepository repository, Exception exception )
- {
- RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID );
- event.setTrace( trace );
- event.setMetadata( metadata );
- event.setException( exception );
- event.setRepository( repository );
-
- repositoryEventDispatcher.dispatch( event.build() );
- }
-
-}
\ No newline at end of file
[03/15] maven git commit: [MNG-6110] renamed 'maven-aether-provider'
to 'maven-resolver-provider'
Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
new file mode 100644
index 0000000..cf587d8
--- /dev/null
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
@@ -0,0 +1,186 @@
+package org.apache.maven.repository.internal.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.PrintStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.aether.transfer.AbstractTransferListener;
+import org.eclipse.aether.transfer.TransferEvent;
+import org.eclipse.aether.transfer.TransferResource;
+
+public class ConsoleTransferListener
+ extends AbstractTransferListener
+{
+
+ private PrintStream out;
+
+ private Map<TransferResource, Long> downloads = new ConcurrentHashMap<>();
+
+ private int lastLength;
+
+ public ConsoleTransferListener()
+ {
+ this( null );
+ }
+
+ public ConsoleTransferListener( PrintStream out )
+ {
+ this.out = ( out != null ) ? out : System.out;
+ }
+
+ @Override
+ public void transferInitiated( TransferEvent event )
+ {
+ String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
+
+ println( "transferInitiated", message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
+ }
+
+ @Override
+ public void transferProgressed( TransferEvent event )
+ {
+ TransferResource resource = event.getResource();
+ downloads.put( resource, event.getTransferredBytes() );
+
+ StringBuilder buffer = new StringBuilder( 64 );
+
+ for ( Map.Entry<TransferResource, Long> entry : downloads.entrySet() )
+ {
+ long total = entry.getKey().getContentLength();
+ long complete = entry.getValue();
+
+ buffer.append( getStatus( complete, total ) ).append( " " );
+ }
+
+ int pad = lastLength - buffer.length();
+ lastLength = buffer.length();
+ pad( buffer, pad );
+ buffer.append( '\r' );
+
+ print( "transferProgressed", buffer.toString() );
+ }
+
+ private String getStatus( long complete, long total )
+ {
+ if ( total >= 1024 )
+ {
+ return toKB( complete ) + "/" + toKB( total ) + " KB ";
+ }
+ else if ( total >= 0 )
+ {
+ return complete + "/" + total + " B ";
+ }
+ else if ( complete >= 1024 )
+ {
+ return toKB( complete ) + " KB ";
+ }
+ else
+ {
+ return complete + " B ";
+ }
+ }
+
+ private void pad( StringBuilder buffer, int spaces )
+ {
+ String block = " ";
+ while ( spaces > 0 )
+ {
+ int n = Math.min( spaces, block.length() );
+ buffer.append( block, 0, n );
+ spaces -= n;
+ }
+ }
+
+ @Override
+ public void transferSucceeded( TransferEvent event )
+ {
+ transferCompleted( event );
+
+ TransferResource resource = event.getResource();
+ long contentLength = event.getTransferredBytes();
+ if ( contentLength >= 0 )
+ {
+ String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" );
+ String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
+
+ String throughput = "";
+ long duration = System.currentTimeMillis() - resource.getTransferStartTime();
+ if ( duration > 0 )
+ {
+ DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) );
+ double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 );
+ throughput = " at " + format.format( kbPerSec ) + " KB/sec";
+ }
+
+ println( "transferSucceeded", type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " ("
+ + len + throughput + ")" );
+ }
+ }
+
+ @Override
+ public void transferFailed( TransferEvent event )
+ {
+ transferCompleted( event );
+
+ println( "transferFailed", event.getException().getClass() + ": " + event.getException().getMessage() );
+ }
+
+ private void transferCompleted( TransferEvent event )
+ {
+ downloads.remove( event.getResource() );
+
+ StringBuilder buffer = new StringBuilder( 64 );
+ pad( buffer, lastLength );
+ buffer.append( '\r' );
+ out.println( buffer );
+ }
+
+ @Override
+ public void transferCorrupted( TransferEvent event )
+ {
+ println( "transferCorrupted", event.getException().getClass() + ": " + event.getException().getMessage() );
+ }
+
+ protected long toKB( long bytes )
+ {
+ return ( bytes + 1023 ) / 1024;
+ }
+
+ private void println( String event, String message )
+ {
+ print( event, message );
+ out.println();
+ }
+
+ private void print( String event, String message )
+ {
+ out.print( "Aether Transfer - " + event );
+ if ( message != null )
+ {
+ out.print( ": " );
+ out.print( message );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml b/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
new file mode 100644
index 0000000..9f0a7fe
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd"
+ modelVersion="1.1.0">
+ <groupId>org.apache.maven.its</groupId>
+ <artifactId>dep-mng5324</artifactId>
+ <version>07.20.3-SNAPSHOT</version><!-- metadata for artifact snapshot -->
+ <versioning>
+ <snapshot>
+ <timestamp>20120809.112920</timestamp>
+ <buildNumber>97</buildNumber>
+ </snapshot>
+ <lastUpdated>20120809112920</lastUpdated>
+ <snapshotVersions>
+ <snapshotVersion>
+ <classifier>classifierA</classifier>
+ <extension>jar</extension>
+ <value>07.20.3-20120809.112124-88</value>
+ <updated>20120809112124</updated>
+ </snapshotVersion>
+ <snapshotVersion>
+ <classifier>classifierB</classifier>
+ <extension>jar</extension>
+ <value>07.20.3-20120809.112920-97</value>
+ <updated>20120809112920</updated>
+ </snapshotVersion>
+ </snapshotVersions>
+ </versioning>
+</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml b/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
new file mode 100644
index 0000000..923f26f
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5459/0.4.0-SNAPSHOT/maven-metadata.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd"
+ modelVersion="1.1.0">
+ <groupId>org.apache.maven.its</groupId>
+ <artifactId>dep-mng5459</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20130404.090532</timestamp>
+ <buildNumber>2</buildNumber>
+ </snapshot>
+ <lastUpdated>20130404093657</lastUpdated>
+ <snapshotVersions>
+ <snapshotVersion>
+ <extension>pom</extension>
+ <value>0.4.0-20130404.090532-2</value>
+ <updated>20130404090532</updated>
+ </snapshotVersion>
+ <snapshotVersion>
+ <extension>jar</extension>
+ <value>0.4.0-20130404.093655-3</value>
+ <updated>20130404093655</updated>
+ </snapshotVersion>
+ </snapshotVersions>
+ </versioning>
+</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0-classifier.zip
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.jar
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
new file mode 100644
index 0000000..f8b72af
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.pom
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>ut.simple</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <artifactId>artifact</artifactId>
+
+ <name>Simple Unit Test Artifact</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>ut.simple</groupId>
+ <artifactId>dependency</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ut.simple</groupId>
+ <artifactId>dependency</artifactId>
+ <version>1.0</version>
+ <classifier>sources</classifier>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/1.0/artifact-1.0.zip
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
new file mode 100644
index 0000000..2de7ecc
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/artifact/maven-metadata.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
+ <groupId>ut.simple</groupId>
+ <artifactId>artifact</artifactId>
+ <versioning>
+ <latest>1.0</latest>
+ <release>1.0</release>
+ <versions>
+ <version>1.0</version>
+ </versions>
+ <lastUpdated>20111123122038</lastUpdated>
+ </versioning>
+</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0-sources.jar
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.jar
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
new file mode 100644
index 0000000..c021dfa
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/1.0/dependency-1.0.pom
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>ut.simple</groupId>
+ <artifactId>dependency</artifactId>
+ <version>1.0</version>
+
+ <name>Simple Unit Test Dependency</name>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
new file mode 100644
index 0000000..8a97c34
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/dependency/maven-metadata.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
+ <groupId>ut.simple</groupId>
+ <artifactId>dependency</artifactId>
+ <versioning>
+ <latest>1.0</latest>
+ <release>1.0</release>
+ <versions>
+ <version>1.0</version>
+ </versions>
+ <lastUpdated>20111123122038</lastUpdated>
+ </versioning>
+</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom b/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
new file mode 100644
index 0000000..ed64c9e
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/1.0/parent-1.0.pom
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>ut.simple</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+
+ <name>Simple Unit Test Parent</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>ut.simple</groupId>
+ <artifactId>dependency</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml b/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
new file mode 100644
index 0000000..7199d52
--- /dev/null
+++ b/maven-resolver-provider/src/test/resources/repo/ut/simple/parent/maven-metadata.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+-->
+
+<metadata xmlns="http://maven.apache.org/METADATA/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd">
+ <groupId>ut.simple</groupId>
+ <artifactId>parent</artifactId>
+ <versioning>
+ <latest>1.0</latest>
+ <release>1.0</release>
+ <versions>
+ <version>1.0</version>
+ </versions>
+ <lastUpdated>20111123122038</lastUpdated>
+ </versioning>
+</metadata>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/8972072e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0e3b9a7..36bdf5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@ under the License.
<module>maven-settings</module>
<module>maven-settings-builder</module>
<module>maven-artifact</module>
- <module>maven-aether-provider</module>
+ <module>maven-resolver-provider</module>
<module>maven-repository-metadata</module>
<module>maven-slf4j-provider</module>
<module>maven-embedder</module>
@@ -209,7 +209,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
+ <artifactId>maven-resolver-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>