You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/12/26 14:59:34 UTC
[maven-artifact-transfer] 01/02: [MSHARED-944] Drop support for
Maven 3.0. Require 3.1.1
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MSHARED-944
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git
commit 7ee2f748af7d44a9f105f85dd7f2c777fe51f0db
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Dec 26 15:49:36 2020 +0100
[MSHARED-944] Drop support for Maven 3.0. Require 3.1.1
---
pom.xml | 49 +---
src/it/maven-artifact-deployer-plugin/pom.xml | 4 +-
.../artifact/deployer/ArtifactDeployerTest.java | 4 +-
src/it/maven-artifact-installer-plugin/pom.xml | 4 +-
.../artifact/installer/ArtifactInstallerTest.java | 4 +-
src/it/maven-dependency-collector-plugin/pom.xml | 4 +-
.../collector/DependencyCollectorTest.java | 4 +-
src/it/maven-project-deployer-plugin/pom.xml | 4 +-
.../plugin/project/deploy/ProjectDeployerTest.java | 4 +-
src/it/maven-project-installer-plugin/pom.xml | 4 +-
.../project/install/ProjectInstallerTest.java | 2 +-
.../deploy/internal/DefaultArtifactDeployer.java | 40 +---
.../deploy/internal/Maven30ArtifactDeployer.java | 150 ------------
.../install/internal/DefaultArtifactInstaller.java | 40 +---
.../install/internal/Maven30ArtifactInstaller.java | 105 --------
.../resolve/internal/DefaultArtifactResolver.java | 50 +---
.../resolve/internal/Maven30ArtifactResolver.java | 107 ---------
.../resolve/internal/Maven30ArtifactResult.java | 57 -----
.../internal/DefaultDependencyCollector.java | 52 +---
.../internal/Maven30ArtifactRepositoryAdapter.java | 265 --------------------
.../collection/internal/Maven30CollectResult.java | 68 ------
.../internal/Maven30DependencyCollector.java | 167 -------------
.../internal/Maven30DependencyNodeAdapter.java | 163 -------------
.../internal/Maven31ArtifactRepositoryAdapter.java | 29 +++
.../internal/DefaultDependencyCollector.java | 52 +---
.../internal/Maven30ArtifactRepositoryAdapter.java | 266 ---------------------
.../collect/internal/Maven30CollectorResult.java | 85 -------
.../internal/Maven30DependencyCollector.java | 160 -------------
.../internal/Maven30DependencyNodeAdapter.java | 163 -------------
.../internal/Maven31ArtifactRepositoryAdapter.java | 29 +++
.../internal/DefaultDependencyResolver.java | 52 +---
.../resolve/internal/Maven30ArtifactResult.java | 57 -----
.../internal/Maven30DependencyResolver.java | 247 -------------------
.../Maven30DependencyResolverException.java | 61 -----
.../metadata/internal/Maven30MetadataBridge.java | 107 ---------
.../internal/DefaultRepositoryManager.java | 61 +----
.../internal/Maven302RepositoryManager.java | 55 -----
.../internal/Maven30RepositoryManager.java | 172 -------------
.../internal/Maven31RepositoryManager.java | 7 +-
src/site/apt/index.apt.vm | 2 +-
.../internal/DefaultArtifactDeployerTest.java | 9 +-
.../internal/Maven30ArtifactInstallerTest.java | 77 ------
.../internal/Maven30RepositoryManagerTest.java | 83 -------
43 files changed, 138 insertions(+), 2987 deletions(-)
diff --git a/pom.xml b/pom.xml
index f6459e9..5dce620 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
<version>34</version>
- <relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
+ <relativePath />
</parent>
<artifactId>maven-artifact-transfer</artifactId>
@@ -165,12 +165,12 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>3.0</version>
+ <version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
- <version>3.0</version>
+ <version>3.1.1</version>
</dependency>
<dependency>
@@ -188,47 +188,6 @@
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
</dependency>
-
- <!-- Maven 3.0.x -->
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>1.7</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>1.7</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Maven 3.1.x and above -->
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>0.9.0.M2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>0.9.0.M2</version>
- <!-- provided scoped dependencies aren't shaded -->
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>0.9.0.M2</version>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -293,12 +252,12 @@
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
</filterProperties>
<extraArtifacts>
- <extraArtifact>org.apache.maven:apache-maven:3.0.5:tar.gz:bin</extraArtifact>
<extraArtifact>org.apache.maven:apache-maven:3.1.1:tar.gz:bin</extraArtifact>
<extraArtifact>org.apache.maven:apache-maven:3.2.5:tar.gz:bin</extraArtifact>
<extraArtifact>org.apache.maven:apache-maven:3.3.1:tar.gz:bin</extraArtifact>
<extraArtifact>org.apache.maven:apache-maven:3.3.9:tar.gz:bin</extraArtifact>
<extraArtifact>org.apache.maven:apache-maven:3.5.0:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.6.3:tar.gz:bin</extraArtifact>
</extraArtifacts>
</configuration>
<executions>
diff --git a/src/it/maven-artifact-deployer-plugin/pom.xml b/src/it/maven-artifact-deployer-plugin/pom.xml
index d0e4a2c..90c40f0 100644
--- a/src/it/maven-artifact-deployer-plugin/pom.xml
+++ b/src/it/maven-artifact-deployer-plugin/pom.xml
@@ -43,8 +43,8 @@
</prerequisites>
<properties>
- <surefire.version>2.21.0</surefire.version>
- <mavenVersion>3.0</mavenVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <mavenVersion>3.1.1</mavenVersion>
<javaVersion>8</javaVersion>
</properties>
diff --git a/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java b/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
index b5fd7f9..486667b 100644
--- a/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
+++ b/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
@@ -35,7 +35,7 @@ import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
/**
- * This will check if the ArtifactInstaller works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
+ * This will check if the ArtifactInstaller works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
* 3.5.2, 3.5.3. This is done by using the test plugin <code>maven-artifact-deployer-plugin</code> which uses the
* ArtifactInstaller as component. By using this way we get a real runtime environment which supports all Maven
* versions.
@@ -43,7 +43,7 @@ import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
+@MavenVersions( { "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
public class ArtifactDeployerTest
{
diff --git a/src/it/maven-artifact-installer-plugin/pom.xml b/src/it/maven-artifact-installer-plugin/pom.xml
index 18b2338..34343ff 100644
--- a/src/it/maven-artifact-installer-plugin/pom.xml
+++ b/src/it/maven-artifact-installer-plugin/pom.xml
@@ -44,8 +44,8 @@
</prerequisites>
<properties>
- <surefire.version>2.21.0</surefire.version>
- <mavenVersion>3.0</mavenVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <mavenVersion>3.1.1</mavenVersion>
<javaVersion>8</javaVersion>
</properties>
diff --git a/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java b/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
index 5655dce..13c000e 100644
--- a/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
+++ b/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
@@ -36,7 +36,7 @@ import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
/**
- * This will check if the ArtifactInstaller works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
+ * This will check if the ArtifactInstaller works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
* 3.5.2, 3.5.3. This is done by using the test plugin <code>maven-artifact-installer-plugin</code> which uses the
* ArtifactInstaller as component. By using this way we get a real runtime environment which supports all Maven
* versions.
@@ -44,7 +44,7 @@ import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
+@MavenVersions( { "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
public class ArtifactInstallerTest
{
diff --git a/src/it/maven-dependency-collector-plugin/pom.xml b/src/it/maven-dependency-collector-plugin/pom.xml
index b1e1392..bf967e2 100644
--- a/src/it/maven-dependency-collector-plugin/pom.xml
+++ b/src/it/maven-dependency-collector-plugin/pom.xml
@@ -44,8 +44,8 @@
</prerequisites>
<properties>
- <surefire.version>2.21.0</surefire.version>
- <mavenVersion>3.0</mavenVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <mavenVersion>3.1.1</mavenVersion>
<javaVersion>8</javaVersion>
</properties>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java b/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
index 512d530..b574683 100644
--- a/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
+++ b/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
@@ -36,7 +36,7 @@ import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
/**
- * This will check if the DependencyCollector works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
+ * This will check if the DependencyCollector works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
* 3.5.4, 3.6.3. This is done by using the test plugin <code>maven-artifact-installer-plugin</code> which uses the
* ArtifactInstaller as component. By using this way we get a real runtime environment which supports all Maven
* versions.
@@ -44,7 +44,7 @@ import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
+@MavenVersions( { "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
public class DependencyCollectorTest
{
diff --git a/src/it/maven-project-deployer-plugin/pom.xml b/src/it/maven-project-deployer-plugin/pom.xml
index 163b6a9..2e03f59 100644
--- a/src/it/maven-project-deployer-plugin/pom.xml
+++ b/src/it/maven-project-deployer-plugin/pom.xml
@@ -43,8 +43,8 @@
</prerequisites>
<properties>
- <surefire.version>2.21.0</surefire.version>
- <mavenVersion>3.0</mavenVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <mavenVersion>3.1.1</mavenVersion>
<javaVersion>8</javaVersion>
</properties>
diff --git a/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java b/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
index 9390398..c46e735 100644
--- a/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
+++ b/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
@@ -35,14 +35,14 @@ import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
/**
- * This will check if the ProjectDeployer works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0, 3.5.2,
+ * This will check if the ProjectDeployer works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0, 3.5.2,
* 3.5.3. This is done by using the test plugin <code>maven-project-deployer-plugin</code> which uses the
* ProjectDeplyoer as component. By using this way we get a real runtime environment which supports all Maven versions.
*
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
+@MavenVersions( { "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
public class ProjectDeployerTest
{
diff --git a/src/it/maven-project-installer-plugin/pom.xml b/src/it/maven-project-installer-plugin/pom.xml
index f644f52..af86d2f 100644
--- a/src/it/maven-project-installer-plugin/pom.xml
+++ b/src/it/maven-project-installer-plugin/pom.xml
@@ -43,8 +43,8 @@
</prerequisites>
<properties>
- <surefire.version>2.21.0</surefire.version>
- <mavenVersion>3.0</mavenVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <mavenVersion>3.1.1</mavenVersion>
<javaVersion>8</javaVersion>
</properties>
diff --git a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
index 126caaa..5d23fd0 100644
--- a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
+++ b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
@@ -36,7 +36,7 @@ import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
/**
- * This will check if the ProjectInstaller works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0, 3.5.2,
+ * This will check if the ProjectInstaller works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0, 3.5.2,
* 3.5.3. This is done by using the test plugin <code>maven-project-installer-plugin</code> which uses the
* ProjectInstaller as component. By using this way we get a real runtime environment which supports all Maven versions.
*
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java b/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java
index 11a268c..e51e784 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java
+++ b/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java
@@ -33,6 +33,8 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
/**
*
@@ -91,23 +93,6 @@ class DefaultArtifactDeployer implements ArtifactDeployer, Contextualizable
}
/**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
- /**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
@@ -121,25 +106,10 @@ class DefaultArtifactDeployer implements ArtifactDeployer, Contextualizable
private MavenArtifactDeployer getMavenArtifactDeployer( ProjectBuildingRequest buildingRequest )
throws ComponentLookupException, ArtifactDeployerException
{
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem repositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem repositorySystem = container.lookup( RepositorySystem.class );
- return new Maven31ArtifactDeployer( repositorySystem, session );
- }
- else
- {
- org.sonatype.aether.RepositorySystem repositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- return new Maven30ArtifactDeployer( repositorySystem, session );
- }
+ return new Maven31ArtifactDeployer( repositorySystem, session );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java b/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
deleted file mode 100644
index 611eb4c..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package org.apache.maven.shared.transfer.artifact.deploy.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 org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
-import org.apache.maven.shared.transfer.metadata.internal.Maven30MetadataBridge;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.deployment.DeployRequest;
-import org.sonatype.aether.deployment.DeploymentException;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.util.artifact.SubArtifact;
-
-/**
- *
- */
-class Maven30ArtifactDeployer
- implements MavenArtifactDeployer
-{
-
- private final RepositorySystem repositorySystem;
-
- private final RepositorySystemSession session;
-
- Maven30ArtifactDeployer( RepositorySystem repositorySystem, RepositorySystemSession session )
- {
- this.repositorySystem = repositorySystem;
- this.session = session;
- }
-
- @Override
- public void deploy( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactDeployerException
- {
- deploy( null, mavenArtifacts );
- }
-
- @Override
- public void deploy( ArtifactRepository remoteRepository,
- Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactDeployerException
- {
- // prepare request
- DeployRequest request = new DeployRequest();
-
- RemoteRepository defaultRepository = null;
-
- if ( remoteRepository != null )
- {
- defaultRepository = getRemoteRepository( session, remoteRepository );
- }
-
- // transform artifacts
- for ( org.apache.maven.artifact.Artifact mavenArtifact : mavenArtifacts )
- {
- Artifact aetherArtifact = Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.apache.maven.artifact.Artifact.class, mavenArtifact );
- request.addArtifact( aetherArtifact );
-
- RemoteRepository aetherRepository;
- if ( remoteRepository == null )
- {
- aetherRepository = getRemoteRepository( session, mavenArtifact.getRepository() );
- }
- else
- {
- aetherRepository = defaultRepository;
- }
-
- request.setRepository( aetherRepository );
-
- for ( ArtifactMetadata metadata : mavenArtifact.getMetadataList() )
- {
- if ( metadata instanceof ProjectArtifactMetadata )
- {
- Artifact pomArtifact = new SubArtifact( aetherArtifact, "", "pom" );
- pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
- request.addArtifact( pomArtifact );
- }
- else if ( // metadata instanceof SnapshotArtifactRepositoryMetadata ||
- metadata instanceof ArtifactRepositoryMetadata )
- {
- // eaten, handled by repo system
- }
- else if ( metadata instanceof org.apache.maven.shared.transfer.metadata.ArtifactMetadata )
- {
- org.apache.maven.shared.transfer.metadata.ArtifactMetadata transferMedata =
- ( org.apache.maven.shared.transfer.metadata.ArtifactMetadata ) metadata;
-
- request.addMetadata( new Maven30MetadataBridge( metadata ).setFile( transferMedata.getFile() ) );
- }
- }
- }
-
- // deploy
- try
- {
- repositorySystem.deploy( session, request );
- }
- catch ( DeploymentException e )
- {
- throw new ArtifactDeployerException( e.getMessage(), e );
- }
- }
-
- private RemoteRepository getRemoteRepository( RepositorySystemSession session, ArtifactRepository remoteRepository )
- throws ArtifactDeployerException
- {
- RemoteRepository aetherRepo = Invoker.invoke( RepositoryUtils.class, "toRepo",
- ArtifactRepository.class,
- remoteRepository );
-
- if ( aetherRepo.getAuthentication() == null )
- {
- aetherRepo.setAuthentication( session.getAuthenticationSelector().getAuthentication( aetherRepo ) );
- }
-
- if ( aetherRepo.getProxy() == null )
- {
- aetherRepo.setProxy( session.getProxySelector().getProxy( aetherRepo ) );
- }
-
- return aetherRepo;
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java b/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java
index 238e814..bd963a7 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java
+++ b/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java
@@ -35,6 +35,8 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
/**
*
@@ -108,23 +110,6 @@ class DefaultArtifactInstaller implements ArtifactInstaller, Contextualizable
}
/**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
- /**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
@@ -138,25 +123,10 @@ class DefaultArtifactInstaller implements ArtifactInstaller, Contextualizable
private MavenArtifactInstaller getMavenArtifactInstaller( ProjectBuildingRequest buildingRequest )
throws ComponentLookupException, ArtifactInstallerException
{
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem repositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem repositorySystem = container.lookup( RepositorySystem.class );
- return new Maven31ArtifactInstaller( repositorySystem, session );
- }
- else
- {
- org.sonatype.aether.RepositorySystem repositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- return new Maven30ArtifactInstaller( repositorySystem, session );
- }
+ return new Maven31ArtifactInstaller( repositorySystem, session );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java b/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
deleted file mode 100644
index fbff698..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.maven.shared.transfer.artifact.install.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 org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
-import org.apache.maven.shared.transfer.metadata.internal.Maven30MetadataBridge;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.installation.InstallRequest;
-import org.sonatype.aether.installation.InstallationException;
-import org.sonatype.aether.util.artifact.SubArtifact;
-
-/**
- *
- */
-class Maven30ArtifactInstaller
- implements MavenArtifactInstaller
-{
- private final RepositorySystem repositorySystem;
-
- private final RepositorySystemSession session;
-
- Maven30ArtifactInstaller( RepositorySystem repositorySystem, RepositorySystemSession session )
- {
- this.repositorySystem = repositorySystem;
- this.session = session;
- }
-
- @Override
- public void install( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactInstallerException
- {
- // prepare installRequest
- InstallRequest request = new InstallRequest();
-
- // transform artifacts
- for ( org.apache.maven.artifact.Artifact mavenArtifact : mavenArtifacts )
- {
- Artifact mainArtifact = Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.apache.maven.artifact.Artifact.class, mavenArtifact );
- request.addArtifact( mainArtifact );
-
- for ( ArtifactMetadata metadata : mavenArtifact.getMetadataList() )
- {
- if ( metadata instanceof ProjectArtifactMetadata )
- {
- Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
- pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
- request.addArtifact( pomArtifact );
- }
- else if ( // metadata instanceof SnapshotArtifactRepositoryMetadata ||
- metadata instanceof ArtifactRepositoryMetadata )
- {
- // eaten, handled by repo system
- }
- else if ( metadata instanceof org.apache.maven.shared.transfer.metadata.ArtifactMetadata )
- {
- org.apache.maven.shared.transfer.metadata.ArtifactMetadata transferMedata =
- ( org.apache.maven.shared.transfer.metadata.ArtifactMetadata ) metadata;
-
- request.addMetadata( new Maven30MetadataBridge( metadata ).setFile( transferMedata.getFile() ) );
- }
- }
- }
-
-// if ( localRepository != null )
-// {
-// buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepository );
-// }
-
- // install
- try
- {
- repositorySystem.install( session, request );
- }
- catch ( InstallationException e )
- {
- throw new ArtifactInstallerException( e.getMessage(), e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java b/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java
index 83d7517..c6d1407 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java
+++ b/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java
@@ -35,6 +35,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
@@ -100,23 +103,6 @@ class DefaultArtifactResolver implements ArtifactResolver, Contextualizable
}
/**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
- /**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
@@ -130,34 +116,14 @@ class DefaultArtifactResolver implements ArtifactResolver, Contextualizable
private MavenArtifactResolver getMavenArtifactResolver( ProjectBuildingRequest buildingRequest )
throws ComponentLookupException, ArtifactResolverException
{
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem repositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- List<org.eclipse.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem repositorySystem = container.lookup( RepositorySystem.class );
- return new Maven31ArtifactResolver( repositorySystem, aetherRepositories, session );
+ List<RemoteRepository> aetherRepositories = Invoker.invoke(
+ RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
- }
- else
- {
- org.sonatype.aether.RepositorySystem repositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
-
- List<org.sonatype.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
-
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- return new Maven30ArtifactResolver( repositorySystem, aetherRepositories, session );
- }
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
+ return new Maven31ArtifactResolver( repositorySystem, aetherRepositories, session );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java b/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java
deleted file mode 100644
index 95a6dc5..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.maven.shared.transfer.artifact.resolve.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.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
-import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactDescriptorException;
-import org.sonatype.aether.resolution.ArtifactDescriptorRequest;
-import org.sonatype.aether.resolution.ArtifactDescriptorResult;
-import org.sonatype.aether.resolution.ArtifactRequest;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-/**
- *
- */
-class Maven30ArtifactResolver
- implements MavenArtifactResolver
-{
- private final RepositorySystem repositorySystem;
-
- private final List<RemoteRepository> aetherRepositories;
-
- private final RepositorySystemSession session;
-
- Maven30ArtifactResolver( RepositorySystem repositorySystem, List<RemoteRepository> aetherRepositories,
- RepositorySystemSession session )
- {
- this.repositorySystem = repositorySystem;
- this.aetherRepositories = aetherRepositories;
- this.session = session;
- }
-
- @Override
- // CHECKSTYLE_OFF: LineLength
- public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact( org.apache.maven.artifact.Artifact mavenArtifact )
- throws ArtifactResolverException
- // CHECKSTYLE_ON: LineLength
- {
- Artifact aetherArtifact = Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.apache.maven.artifact.Artifact.class, mavenArtifact );
-
- return resolveArtifact( aetherArtifact );
- }
-
- @Override
- // CHECKSTYLE_OFF: LineLength
- public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact( ArtifactCoordinate coordinate )
- throws ArtifactResolverException
- // CHECKSTYLE_ON: LineLength
- {
- Artifact aetherArtifact =
- new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
- coordinate.getExtension(), coordinate.getVersion() );
-
- return resolveArtifact( aetherArtifact );
- }
-
- // CHECKSTYLE_OFF: LineLength
- private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact( Artifact aetherArtifact )
- throws ArtifactResolverException
- // CHECKSTYLE_ON: LineLength
- {
- try
- {
- // use descriptor to respect relocation
- ArtifactDescriptorRequest descriptorRequest =
- new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null );
-
- ArtifactDescriptorResult descriptorResult =
- repositorySystem.readArtifactDescriptor( session, descriptorRequest );
-
- ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null );
-
- return new Maven30ArtifactResult( repositorySystem.resolveArtifact( session, request ) );
- }
- catch ( ArtifactDescriptorException | ArtifactResolutionException e )
- {
- throw new ArtifactResolverException( e.getMessage(), e );
- }
- }
-
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java b/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
deleted file mode 100644
index 3bbea28..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.maven.shared.transfer.artifact.resolve.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.RepositoryUtils;
-import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.resolution.ArtifactResult;
-
-/**
- * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
- *
- * @author Robert Scholte
- * @since 3.0
- */
-class Maven30ArtifactResult implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
-{
- private final ArtifactResult artifactResult;
-
- /**
- * @param artifactResult {@link ArtifactResult}
- */
- Maven30ArtifactResult( ArtifactResult artifactResult )
- {
- this.artifactResult = artifactResult;
- }
-
- @Override
- public org.apache.maven.artifact.Artifact getArtifact()
- {
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact", Artifact.class, artifactResult.getArtifact() );
- }
- catch ( ArtifactResolverException e )
- {
- throw new RuntimeException( e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java
index e6ce50e..df2a248 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java
@@ -38,6 +38,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* This DependencyCollector passes the request to the proper Maven 3.x implementation
@@ -128,23 +131,6 @@ class DefaultDependencyCollector implements DependencyCollector, Contextualizabl
Objects.requireNonNull( root, "The parameter root is not allowed to be null." );
}
- /**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
/**
* Injects the Plexus content.
*
@@ -161,35 +147,15 @@ class DefaultDependencyCollector implements DependencyCollector, Contextualizabl
{
ArtifactHandlerManager artifactHandlerManager = container.lookup( ArtifactHandlerManager.class );
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem m31RepositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem m31RepositorySystem = container.lookup( RepositorySystem.class );
- List<org.eclipse.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- return new Maven31DependencyCollector( m31RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
- }
- else
- {
- org.sonatype.aether.RepositorySystem m30RepositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
-
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- List<org.sonatype.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
-
- return new Maven30DependencyCollector( m30RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
- }
+ List<RemoteRepository> aetherRepositories = Invoker.invoke(
+ RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
+ return new Maven31DependencyCollector( m31RepositorySystem, artifactHandlerManager, session,
+ aetherRepositories );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
deleted file mode 100644
index 40d9143..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
+++ /dev/null
@@ -1,265 +0,0 @@
-package org.apache.maven.shared.transfer.collection.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.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.Authentication;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.repository.Proxy;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.repository.RepositoryPolicy;
-
-/**
- * ArtifactRepository wrapper around {@link RemoteRepository}
- *
- * @author Robert Scholte
- *
- */
-class Maven30ArtifactRepositoryAdapter implements ArtifactRepository
-{
- private static final String LS = System.lineSeparator();
- private RemoteRepository remoteRepository;
-
- /**
- * @param remoteRepository {@link RemoteRepository}
- */
- Maven30ArtifactRepositoryAdapter( RemoteRepository remoteRepository )
- {
- this.remoteRepository = remoteRepository;
- }
-
- @Override
- public String pathOf( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getUrl()
- {
- return remoteRepository.getUrl();
- }
-
- @Override
- public void setUrl( String url )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getBasedir()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getProtocol()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getId()
- {
- return remoteRepository.getId();
- }
-
- @Override
- public void setId( String id )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryPolicy getSnapshots()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryPolicy getReleases()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryLayout getLayout()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setLayout( ArtifactRepositoryLayout layout )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getKey()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isUniqueVersion()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isBlacklisted()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setBlacklisted( boolean blackListed )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Artifact find( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<String> findVersions( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isProjectAware()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setAuthentication( Authentication authentication )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Authentication getAuthentication()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setProxy( Proxy proxy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Proxy getProxy()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( " id: " ).append( getId() ).append( LS );
- sb.append( " url: " ).append( getUrl() ).append( LS );
- sb.append( " layout: " ).append( "default" ).append( LS );
-
- RepositoryPolicy snapshotPolicy = remoteRepository.getPolicy( true );
- sb.append( "snapshots: [enabled => " ).append( snapshotPolicy.isEnabled() );
- sb.append( ", update => " ).append( snapshotPolicy.getUpdatePolicy() ).append( "]" ).append( LS );
-
- RepositoryPolicy releasePolicy = remoteRepository.getPolicy( false );
- sb.append( " releases: [enabled => " ).append( releasePolicy.isEnabled() );
- sb.append( ", update => " ).append( releasePolicy.getUpdatePolicy() ).append( "]" ).append( LS );
-
- return sb.toString();
- }
-
- @Override
- public int hashCode()
- {
- return remoteRepository.hashCode();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
-
- Maven30ArtifactRepositoryAdapter other = (Maven30ArtifactRepositoryAdapter) obj;
- if ( remoteRepository == null )
- {
- if ( other.remoteRepository != null )
- {
- return false;
- }
- }
- else if ( !remoteRepository.equals( other.remoteRepository ) )
- {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java
deleted file mode 100644
index c5e6c90..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.maven.shared.transfer.collection.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.List;
-
-import org.apache.maven.shared.transfer.collection.CollectResult;
-import org.apache.maven.shared.transfer.graph.DependencyNode;
-
-
-/**
- * CollectResult wrapper around {@link CollectResult}
- *
- * @author Pim Moerenhout
- *
- */
-class Maven30CollectResult implements CollectResult
-{
- private final org.sonatype.aether.collection.CollectResult collectResult;
-
- /**
- * @param collectResult {@link CollectResult}
- */
- Maven30CollectResult( org.sonatype.aether.collection.CollectResult collectResult )
- {
- this.collectResult = collectResult;
- }
-
- @Override
- public List<Exception> getExceptions()
- {
- return collectResult.getExceptions();
- }
-
- /**
- * Gets the root node of the dependency graph.
- *
- * @return The root node of the dependency graph or {@code null} if none.
- */
- @Override
- public DependencyNode getRoot()
- {
- return new Maven30DependencyNodeAdapter( collectResult.getRoot() );
- }
-
- @Override
- public String toString()
- {
- return String.valueOf( getRoot() );
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
deleted file mode 100644
index 108db21..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.apache.maven.shared.transfer.collection.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.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.model.Model;
-import org.apache.maven.shared.transfer.collection.CollectResult;
-import org.apache.maven.shared.transfer.collection.DependencyCollectionException;
-import org.apache.maven.shared.transfer.collection.DependencyCollector;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.artifact.ArtifactTypeRegistry;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-/**
- * Maven 3.0 implementation of the {@link DependencyCollector}
- *
- * @author Robert Scholte
- *
- */
-class Maven30DependencyCollector
- implements MavenDependencyCollector
-{
- private final RepositorySystem repositorySystem;
-
- private final ArtifactHandlerManager artifactHandlerManager;
-
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> aetherRepositories;
-
- Maven30DependencyCollector( RepositorySystem repositorySystem, ArtifactHandlerManager artifactHandlerManager,
- RepositorySystemSession session, List<RemoteRepository> aetherRepositories )
- {
- super();
- this.repositorySystem = repositorySystem;
- this.artifactHandlerManager = artifactHandlerManager;
- this.session = session;
- this.aetherRepositories = aetherRepositories;
- }
-
- @Override
- public CollectResult collectDependencies( org.apache.maven.model.Dependency root )
- throws DependencyCollectionException
- {
- ArtifactTypeRegistry typeRegistry = Invoker
- .invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( toDependency( root, typeRegistry ) );
-
- return collectDependencies( request );
- }
-
- @Override
- public CollectResult collectDependencies( DependableCoordinate root )
- throws DependencyCollectionException
- {
- ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getType() );
-
- String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
-
- Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), root.getClassifier(),
- extension, root.getVersion() );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( new Dependency( aetherArtifact, null ) );
-
- return collectDependencies( request );
- }
-
- @Override
- public CollectResult collectDependencies( Model root )
- throws DependencyCollectionException
- {
- // Are there examples where packaging and type are NOT in sync
- ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getPackaging() );
-
- String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
-
- Artifact aetherArtifact =
- new DefaultArtifact( root.getGroupId(), root.getArtifactId(), extension, root.getVersion() );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( new Dependency( aetherArtifact, null ) );
-
- ArtifactTypeRegistry typeRegistry = Invoker
- .invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
-
- List<Dependency> aetherDependencies = new ArrayList<>( root.getDependencies().size() );
- for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencies() )
- {
- aetherDependencies.add( toDependency( mavenDependency, typeRegistry ) );
- }
- request.setDependencies( aetherDependencies );
-
- if ( root.getDependencyManagement() != null )
- {
- List<Dependency> aetherManagerDependencies = new ArrayList<>(
- root.getDependencyManagement().getDependencies().size() );
-
- for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencyManagement().getDependencies() )
- {
- aetherManagerDependencies.add( toDependency( mavenDependency, typeRegistry ) );
- }
-
- request.setManagedDependencies( aetherManagerDependencies );
- }
-
- return collectDependencies( request );
- }
-
- private CollectResult collectDependencies( CollectRequest request )
- throws DependencyCollectionException
- {
- request.setRepositories( aetherRepositories );
-
- try
- {
- return new Maven30CollectResult( repositorySystem.collectDependencies( session, request ) );
- }
- catch ( org.sonatype.aether.collection.DependencyCollectionException e )
- {
- throw new DependencyCollectionException( e.getMessage(), e );
- }
- }
-
- private static Dependency toDependency( org.apache.maven.model.Dependency mavenDependency,
- ArtifactTypeRegistry typeRegistry )
- throws DependencyCollectionException
- {
- Class<?>[] argClasses = new Class<?>[] { org.apache.maven.model.Dependency.class, ArtifactTypeRegistry.class };
-
- Object[] args = new Object[] { mavenDependency, typeRegistry };
-
- return Invoker.invoke( RepositoryUtils.class, "toDependency", argClasses, args );
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
deleted file mode 100644
index fa96b35..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.apache.maven.shared.transfer.collection.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.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.shared.transfer.collection.DependencyCollectionException;
-import org.apache.maven.shared.transfer.graph.DependencyNode;
-import org.apache.maven.shared.transfer.graph.DependencyVisitor;
-import org.sonatype.aether.repository.RemoteRepository;
-
-/**
- * DependencyCollectorNode wrapper around {@link org.sonatype.aether.graph.DependencyNode}
- *
- * @author Pim Moerenhout
- *
- */
-class Maven30DependencyNodeAdapter implements DependencyNode
-{
-
- private org.sonatype.aether.graph.DependencyNode dependencyNode;
-
- /**
- * @param dependencyNode {@link org.sonatype.aether.graph.DependencyNode}
- */
- Maven30DependencyNodeAdapter( org.sonatype.aether.graph.DependencyNode dependencyNode )
- {
- this.dependencyNode = dependencyNode;
- }
-
- @Override
- public Artifact getArtifact()
- {
- return getArtifact( dependencyNode.getDependency().getArtifact() );
- }
-
- @Override
- public List<DependencyNode> getChildren()
- {
- List<org.sonatype.aether.graph.DependencyNode> aetherChildren = dependencyNode.getChildren();
- List<DependencyNode> children = new ArrayList<>( aetherChildren.size() );
- for ( org.sonatype.aether.graph.DependencyNode aetherChild : aetherChildren )
- {
- children.add( new Maven30DependencyNodeAdapter( aetherChild ) );
- }
- return children;
- }
-
- @Override
- public List<ArtifactRepository> getRemoteRepositories()
- {
- List<RemoteRepository> aetherRepositories = dependencyNode.getRepositories();
- List<ArtifactRepository> mavenRepositories = new ArrayList<>( aetherRepositories.size() );
-
- for ( RemoteRepository aetherRepository : aetherRepositories )
- {
- mavenRepositories.add( new Maven30ArtifactRepositoryAdapter( aetherRepository ) );
- }
-
- return mavenRepositories;
- }
-
- @Override
- public Boolean getOptional()
- {
- return dependencyNode.getDependency().isOptional();
- }
-
- @Override
- public String getScope()
- {
- return dependencyNode.getDependency().getScope();
- }
-
- @Override
- public boolean accept( DependencyVisitor visitor )
- {
- if ( visitor.visitEnter( this ) )
- {
- for ( org.sonatype.aether.graph.DependencyNode aetherNode : dependencyNode.getChildren() )
- {
- DependencyNode child = new Maven30DependencyNodeAdapter( aetherNode );
- if ( !child.accept( visitor ) )
- {
- break;
- }
- }
- }
-
- return visitor.visitLeave( this );
- }
-
- @Override
- public int hashCode()
- {
- return dependencyNode.hashCode();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
-
- Maven30DependencyNodeAdapter other = (Maven30DependencyNodeAdapter) obj;
- if ( dependencyNode == null )
- {
- if ( other.dependencyNode != null )
- {
- return false;
- }
- }
- else if ( !dependencyNode.equals( other.dependencyNode ) )
- {
- return false;
- }
- return true;
- }
-
- private Artifact getArtifact( org.sonatype.aether.artifact.Artifact aetherArtifact )
- {
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.sonatype.aether.artifact.Artifact.class, aetherArtifact );
- }
- catch ( DependencyCollectionException e )
- {
- throw new RuntimeException( e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
index d53a452..860fef0 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
+++ b/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
@@ -19,6 +19,7 @@ package org.apache.maven.shared.transfer.collection.internal;
* under the License.
*/
+import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
@@ -41,6 +42,7 @@ class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
{
private static final String LS = System.lineSeparator();
private RemoteRepository remoteRepository;
+ private List<ArtifactRepository> mirroredRepositories = Collections.emptyList();
/**
* @param remoteRepository {@link RemoteRepository}
@@ -206,6 +208,33 @@ class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
throw new UnsupportedOperationException();
}
+ /**
+ * @return the repositories mirrored by the actual one
+ * @since 3.0.3
+ */
+ @Override
+ public List<ArtifactRepository> getMirroredRepositories()
+ {
+ return mirroredRepositories;
+ }
+
+ /**
+ * @param mirroredRepositories the repositories that the actual one mirrors
+ * @since 3.0.3
+ */
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ if ( mirroredRepositories != null )
+ {
+ this.mirroredRepositories = mirroredRepositories;
+ }
+ else
+ {
+ this.mirroredRepositories = Collections.emptyList();
+ }
+ }
+
@Override
public String toString()
{
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
index fb1e498..160dca3 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
@@ -37,6 +37,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* This DependencyCollector passes the request to the proper Maven 3.x implementation
@@ -131,23 +134,6 @@ class DefaultDependencyCollector implements DependencyCollector, Contextualizabl
}
/**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
- /**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
@@ -163,35 +149,15 @@ class DefaultDependencyCollector implements DependencyCollector, Contextualizabl
{
ArtifactHandlerManager artifactHandlerManager = container.lookup( ArtifactHandlerManager.class );
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem m31RepositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem m31RepositorySystem = container.lookup( RepositorySystem.class );
- List<org.eclipse.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- return new Maven31DependencyCollector( m31RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
- }
- else
- {
+ List<RemoteRepository> aetherRepositories = Invoker.invoke(
+ RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
- org.sonatype.aether.RepositorySystem m30RepositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
-
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- List<org.sonatype.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
-
- return new Maven30DependencyCollector( m30RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
- }
+ return new Maven31DependencyCollector( m31RepositorySystem, artifactHandlerManager, session,
+ aetherRepositories );
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
deleted file mode 100644
index b09ccd4..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
+++ /dev/null
@@ -1,266 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.collect.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.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.Authentication;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.repository.Proxy;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.repository.RepositoryPolicy;
-
-/**
- * ArtifactRepository wrapper around {@link RemoteRepository}
- *
- * @author Robert Scholte
- *
- */
-class Maven30ArtifactRepositoryAdapter implements ArtifactRepository
-{
-
- private RemoteRepository remoteRepository;
-
- /**
- * @param remoteRepository {@link RemoteRepository}
- */
- Maven30ArtifactRepositoryAdapter( RemoteRepository remoteRepository )
- {
- this.remoteRepository = remoteRepository;
- }
-
- @Override
- public String pathOf( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getUrl()
- {
- return remoteRepository.getUrl();
- }
-
- @Override
- public void setUrl( String url )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getBasedir()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getProtocol()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getId()
- {
- return remoteRepository.getId();
- }
-
- @Override
- public void setId( String id )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryPolicy getSnapshots()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryPolicy getReleases()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ArtifactRepositoryLayout getLayout()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setLayout( ArtifactRepositoryLayout layout )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getKey()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isUniqueVersion()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isBlacklisted()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setBlacklisted( boolean blackListed )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Artifact find( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<String> findVersions( Artifact artifact )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isProjectAware()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setAuthentication( Authentication authentication )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Authentication getAuthentication()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setProxy( Proxy proxy )
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Proxy getProxy()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( " id: " ).append( getId() ).append( "\n" );
- sb.append( " url: " ).append( getUrl() ).append( "\n" );
- sb.append( " layout: " ).append( "default" ).append( "\n" );
-
- RepositoryPolicy snapshotPolicy = remoteRepository.getPolicy( true );
- sb.append( "snapshots: [enabled => " ).append( snapshotPolicy.isEnabled() );
- sb.append( ", update => " ).append( snapshotPolicy.getUpdatePolicy() ).append( "]\n" );
-
- RepositoryPolicy releasePolicy = remoteRepository.getPolicy( false );
- sb.append( " releases: [enabled => " ).append( releasePolicy.isEnabled() );
- sb.append( ", update => " ).append( releasePolicy.getUpdatePolicy() ).append( "]\n" );
-
- return sb.toString();
- }
-
-
- @Override
- public int hashCode()
- {
- return remoteRepository.hashCode();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
-
- Maven30ArtifactRepositoryAdapter other = (Maven30ArtifactRepositoryAdapter) obj;
- if ( remoteRepository == null )
- {
- if ( other.remoteRepository != null )
- {
- return false;
- }
- }
- else if ( !remoteRepository.equals( other.remoteRepository ) )
- {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
deleted file mode 100644
index 081dd66..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.collect.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.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult;
-import org.sonatype.aether.collection.CollectResult;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.graph.DependencyVisitor;
-import org.sonatype.aether.repository.RemoteRepository;
-
-/**
- * CollectorResult wrapper around {@link CollectResult}
- *
- * @author Robert Scholte
- *
- */
-class Maven30CollectorResult implements CollectorResult
-{
- private final CollectResult collectResult;
-
- /**
- * @param collectResult {@link CollectorResult}
- */
- Maven30CollectorResult( CollectResult collectResult )
- {
- this.collectResult = collectResult;
- }
-
- @Override
- public List<ArtifactRepository> getRemoteRepositories()
- {
- final Set<RemoteRepository> aetherRepositories = new HashSet<>();
-
- DependencyVisitor visitor = new DependencyVisitor()
- {
- @Override
- public boolean visitEnter( DependencyNode node )
- {
- aetherRepositories.addAll( node.getRepositories() );
- return true;
- }
-
- @Override
- public boolean visitLeave( DependencyNode node )
- {
- return true;
- }
- };
-
- collectResult.getRoot().accept( visitor );
-
- List<ArtifactRepository> mavenRepositories = new ArrayList<>( aetherRepositories.size() );
-
- for ( RemoteRepository aetherRepository : aetherRepositories )
- {
- mavenRepositories.add( new Maven30ArtifactRepositoryAdapter( aetherRepository ) );
- }
-
- return mavenRepositories;
- }
-
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
deleted file mode 100644
index 8a85003..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.collect.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.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.model.Model;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult;
-import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector;
-import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.artifact.ArtifactTypeRegistry;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.collection.DependencyCollectionException;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-/**
- * Maven 3.0 implementation of the {@link DependencyCollector}
- *
- * @author Robert Scholte
- */
-class Maven30DependencyCollector implements MavenDependencyCollector
-{
- private final RepositorySystem repositorySystem;
-
- private final ArtifactHandlerManager artifactHandlerManager;
-
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> aetherRepositories;
-
- Maven30DependencyCollector( RepositorySystem repositorySystem, ArtifactHandlerManager artifactHandlerManager,
- RepositorySystemSession session, List<RemoteRepository> aetherRepositories )
- {
- super();
- this.repositorySystem = repositorySystem;
- this.artifactHandlerManager = artifactHandlerManager;
- this.session = session;
- this.aetherRepositories = aetherRepositories;
- }
-
- private static Dependency toDependency( org.apache.maven.model.Dependency mavenDependency,
- ArtifactTypeRegistry typeRegistry ) throws DependencyCollectorException
- {
- Class<?>[] argClasses = new Class<?>[] {org.apache.maven.model.Dependency.class, ArtifactTypeRegistry.class};
-
- Object[] args = new Object[] {mavenDependency, typeRegistry};
-
- return Invoker.invoke( RepositoryUtils.class, "toDependency", argClasses, args );
- }
-
- @Override
- public CollectorResult collectDependencies( org.apache.maven.model.Dependency root )
- throws DependencyCollectorException
- {
- ArtifactTypeRegistry typeRegistry = Invoker.invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( toDependency( root, typeRegistry ) );
-
- return collectDependencies( request );
- }
-
- @Override
- public CollectorResult collectDependencies( DependableCoordinate root ) throws DependencyCollectorException
- {
- ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getType() );
-
- String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
-
- Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), root.getClassifier(),
- extension, root.getVersion() );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( new Dependency( aetherArtifact, null ) );
-
- return collectDependencies( request );
- }
-
- @Override
- public CollectorResult collectDependencies( Model root ) throws DependencyCollectorException
- {
- // Are there examples where packaging and type are NOT in sync
- ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getPackaging() );
-
- String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
-
- Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), extension,
- root.getVersion() );
-
- CollectRequest request = new CollectRequest();
- request.setRoot( new Dependency( aetherArtifact, null ) );
-
- ArtifactTypeRegistry typeRegistry = Invoker.invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
-
- List<Dependency> aetherDependencies = new ArrayList<>( root.getDependencies().size() );
- for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencies() )
- {
- aetherDependencies.add( toDependency( mavenDependency, typeRegistry ) );
- }
- request.setDependencies( aetherDependencies );
-
- if ( root.getDependencyManagement() != null )
- {
- List<Dependency> aetherManagerDependencies = new ArrayList<>(
- root.getDependencyManagement().getDependencies().size() );
-
- for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencyManagement().getDependencies() )
- {
- aetherManagerDependencies.add( toDependency( mavenDependency, typeRegistry ) );
- }
-
- request.setManagedDependencies( aetherManagerDependencies );
- }
-
- return collectDependencies( request );
- }
-
- private CollectorResult collectDependencies( CollectRequest request ) throws DependencyCollectorException
- {
- request.setRepositories( aetherRepositories );
-
- try
- {
- return new Maven30CollectorResult( repositorySystem.collectDependencies( session, request ) );
- }
- catch ( DependencyCollectionException e )
- {
- throw new DependencyCollectorException( e.getMessage(), e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
deleted file mode 100644
index 87a10f8..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.collect.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.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException;
-import org.apache.maven.shared.transfer.graph.DependencyNode;
-import org.apache.maven.shared.transfer.graph.DependencyVisitor;
-import org.sonatype.aether.repository.RemoteRepository;
-
-/**
- * DependencyCollectorNode wrapper around {@link org.sonatype.aether.graph.DependencyNode}
- *
- * @author Pim Moerenhout
- *
- */
-class Maven30DependencyNodeAdapter implements DependencyNode
-{
-
- private org.sonatype.aether.graph.DependencyNode dependencyNode;
-
- /**
- * @param dependencyNode {@link org.sonatype.aether.graph.DependencyNode}
- */
- Maven30DependencyNodeAdapter( org.sonatype.aether.graph.DependencyNode dependencyNode )
- {
- this.dependencyNode = dependencyNode;
- }
-
- @Override
- public Artifact getArtifact()
- {
- return getArtifact( dependencyNode.getDependency().getArtifact() );
- }
-
- @Override
- public List<DependencyNode> getChildren()
- {
- List<org.sonatype.aether.graph.DependencyNode> aetherChildren = dependencyNode.getChildren();
- List<DependencyNode> children = new ArrayList<>( aetherChildren.size() );
- for ( org.sonatype.aether.graph.DependencyNode aetherChild : aetherChildren )
- {
- children.add( new Maven30DependencyNodeAdapter( aetherChild ) );
- }
- return children;
- }
-
- @Override
- public List<ArtifactRepository> getRemoteRepositories()
- {
- List<RemoteRepository> aetherRepositories = dependencyNode.getRepositories();
- List<ArtifactRepository> mavenRepositories = new ArrayList<>( aetherRepositories.size() );
-
- for ( RemoteRepository aetherRepository : aetherRepositories )
- {
- mavenRepositories.add( new Maven30ArtifactRepositoryAdapter( aetherRepository ) );
- }
-
- return mavenRepositories;
- }
-
- @Override
- public Boolean getOptional()
- {
- return dependencyNode.getDependency().isOptional();
- }
-
- @Override
- public String getScope()
- {
- return dependencyNode.getDependency().getScope();
- }
-
- @Override
- public boolean accept( DependencyVisitor visitor )
- {
- if ( visitor.visitEnter( this ) )
- {
- for ( org.sonatype.aether.graph.DependencyNode child : dependencyNode.getChildren() )
- {
- DependencyNode node = new Maven30DependencyNodeAdapter( child );
- if ( !node.accept( visitor ) )
- {
- break;
- }
- }
- }
-
- return visitor.visitLeave( this );
- }
-
- @Override
- public int hashCode()
- {
- return dependencyNode.hashCode();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
-
- Maven30DependencyNodeAdapter other = (Maven30DependencyNodeAdapter) obj;
- if ( dependencyNode == null )
- {
- if ( other.dependencyNode != null )
- {
- return false;
- }
- }
- else if ( !dependencyNode.equals( other.dependencyNode ) )
- {
- return false;
- }
- return true;
- }
-
- private Artifact getArtifact( org.sonatype.aether.artifact.Artifact aetherArtifact )
- {
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.sonatype.aether.artifact.Artifact.class, aetherArtifact );
- }
- catch ( DependencyCollectorException e )
- {
- throw new RuntimeException( e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
index 854cf4a..3f01342 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
@@ -19,6 +19,7 @@ package org.apache.maven.shared.transfer.dependencies.collect.internal;
* under the License.
*/
+import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
@@ -41,6 +42,7 @@ class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
{
private RemoteRepository remoteRepository;
+ private List<ArtifactRepository> mirroredRepositories = Collections.emptyList();
/**
* @param remoteRepository {@link RemoteRepository}
@@ -206,6 +208,33 @@ class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
throw new UnsupportedOperationException();
}
+ /**
+ * @return the repositories mirrored by the actual one
+ * @since 3.0.3
+ */
+ @Override
+ public List<ArtifactRepository> getMirroredRepositories()
+ {
+ return mirroredRepositories;
+ }
+
+ /**
+ * @param mirroredRepositories the repositories that the actual one mirrors
+ * @since 3.0.3
+ */
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ if ( mirroredRepositories != null )
+ {
+ this.mirroredRepositories = mirroredRepositories;
+ }
+ else
+ {
+ this.mirroredRepositories = Collections.emptyList();
+ }
+ }
+
@Override
public String toString()
{
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/DefaultDependencyResolver.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/DefaultDependencyResolver.java
index 7718c19..5d51e97 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/DefaultDependencyResolver.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/DefaultDependencyResolver.java
@@ -39,6 +39,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
*
@@ -97,23 +100,6 @@ class DefaultDependencyResolver implements DependencyResolver, Contextualizable
}
/**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- try
- {
- // Maven 3.1 specific
- Thread.currentThread().getContextClassLoader().loadClass( "org.eclipse.aether.artifact.Artifact" );
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
-
- /**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
@@ -148,35 +134,15 @@ class DefaultDependencyResolver implements DependencyResolver, Contextualizable
{
ArtifactHandlerManager artifactHandlerManager = container.lookup( ArtifactHandlerManager.class );
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem m31RepositorySystem = container.lookup(
- org.eclipse.aether.RepositorySystem.class );
-
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystem m31RepositorySystem = container.lookup( RepositorySystem.class );
- List<org.eclipse.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- return new Maven31DependencyResolver( m31RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
- }
- else
- {
- org.sonatype.aether.RepositorySystem m30RepositorySystem = container.lookup(
- org.sonatype.aether.RepositorySystem.class );
+ List<RemoteRepository> aetherRepositories = Invoker.invoke(
+ RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- List<org.sonatype.aether.repository.RemoteRepository> aetherRepositories = Invoker.invoke(
- RepositoryUtils.class, "toRepos", List.class, buildingRequest.getRemoteRepositories() );
-
- return new Maven30DependencyResolver( m30RepositorySystem, artifactHandlerManager, session,
- aetherRepositories );
-
- }
+ return new Maven31DependencyResolver( m31RepositorySystem, artifactHandlerManager, session,
+ aetherRepositories );
}
private void validateBuildingRequest( ProjectBuildingRequest buildingRequest )
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
deleted file mode 100644
index b9f37d9..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.resolve.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.RepositoryUtils;
-import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.resolution.ArtifactResult;
-
-/**
- * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
- *
- * @author Robert Scholte
- * @since 3.0
- */
-class Maven30ArtifactResult implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
-{
- private final ArtifactResult artifactResult;
-
- /**
- * @param artifactResult {@link ArtifactResult}
- */
- Maven30ArtifactResult( ArtifactResult artifactResult )
- {
- this.artifactResult = artifactResult;
- }
-
- @Override
- public org.apache.maven.artifact.Artifact getArtifact()
- {
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact", Artifact.class, artifactResult.getArtifact() );
- }
- catch ( DependencyResolverException e )
- {
- throw new RuntimeException( e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
deleted file mode 100644
index 031d604..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.resolve.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.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.Model;
-import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
-import org.apache.maven.shared.artifact.filter.resolve.transform.SonatypeAetherFilterTransformer;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.artifact.ArtifactType;
-import org.sonatype.aether.artifact.ArtifactTypeRegistry;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.collection.DependencyCollectionException;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.DefaultArtifactType;
-
-/**
- *
- */
-class Maven30DependencyResolver implements MavenDependencyResolver
-{
- private static final Class<?>[] ARG_CLASSES = new Class<?>[] {org.apache.maven.model.Dependency.class,
- ArtifactTypeRegistry.class};
- private final RepositorySystem repositorySystem;
- private final ArtifactHandlerManager artifactHandlerManager;
- private final RepositorySystemSession session;
- private final List<RemoteRepository> aetherRepositories;
-
- Maven30DependencyResolver( RepositorySystem repositorySystem, ArtifactHandlerManager artifactHandlerManager,
- RepositorySystemSession session, List<RemoteRepository> aetherRepositories )
- {
- super();
- this.repositorySystem = repositorySystem;
- this.artifactHandlerManager = artifactHandlerManager;
- this.session = session;
- this.aetherRepositories = aetherRepositories;
- }
-
- /**
- * Based on RepositoryUtils#toDependency(org.apache.maven.model.Dependency, ArtifactTypeRegistry)
- *
- * @param coordinate {@link DependableCoordinate}
- * @param stereotypes {@link org.eclipse.aether.artifact.ArtifactTypeRegistry
- * @return as Aether Dependency
- */
- private static Dependency toDependency( DependableCoordinate coordinate, ArtifactTypeRegistry stereotypes )
- {
- ArtifactType stereotype = stereotypes.get( coordinate.getType() );
- if ( stereotype == null )
- {
- stereotype = new DefaultArtifactType( coordinate.getType() );
- }
-
- Artifact artifact = new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(),
- coordinate.getClassifier(), null, coordinate.getVersion(), null, stereotype );
-
- return new Dependency( artifact, null );
- }
-
- private static Dependency toDependency( org.apache.maven.model.Dependency mavenDependency,
- ArtifactTypeRegistry typeRegistry ) throws DependencyResolverException
- {
- Object[] args = new Object[] {mavenDependency, typeRegistry};
-
- return Invoker.invoke( RepositoryUtils.class, "toDependency", ARG_CLASSES, args );
- }
-
- @Override
- // CHECKSTYLE_OFF: LineLength
- public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
- DependableCoordinate coordinate, TransformableFilter dependencyFilter )
- // CHECKSTYLE_ON: LineLength
- throws DependencyResolverException
- {
- ArtifactTypeRegistry typeRegistry = createTypeRegistry();
-
- Dependency aetherRoot = toDependency( coordinate, typeRegistry );
-
- CollectRequest request = new CollectRequest( aetherRoot, aetherRepositories );
-
- return resolveDependencies( dependencyFilter, request );
- }
-
- private ArtifactTypeRegistry createTypeRegistry() throws DependencyResolverException
- {
- return Invoker.invoke( RepositoryUtils.class, "newArtifactTypeRegistry", ArtifactHandlerManager.class,
- artifactHandlerManager );
- }
-
- @Override
- // CHECKSTYLE_OFF: LineLength
- public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies( Model model,
- TransformableFilter dependencyFilter )
- // CHECKSTYLE_ON: LineLength
- throws DependencyResolverException
- {
- // Are there examples where packaging and type are NOT in sync
- ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( model.getPackaging() );
-
- String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
-
- Artifact aetherArtifact = new DefaultArtifact( model.getGroupId(), model.getArtifactId(), extension,
- model.getVersion() );
-
- Dependency aetherRoot = new Dependency( aetherArtifact, null );
-
- CollectRequest request = new CollectRequest( aetherRoot, aetherRepositories );
-
- request.setDependencies( resolveDependencies( model.getDependencies() ) );
-
- DependencyManagement mavenDependencyManagement = model.getDependencyManagement();
- if ( mavenDependencyManagement != null )
- {
- request.setManagedDependencies( resolveDependencies( mavenDependencyManagement.getDependencies() ) );
- }
-
- return resolveDependencies( dependencyFilter, request );
- }
-
- /**
- * @param mavenDependencies {@link org.apache.maven.model.Dependency} can be {@code null}.
- * @return List of resolved dependencies.
- * @throws DependencyResolverException in case of a failure of the typeRegistry error.
- */
- // CHECKSTYLE_OFF: LineLength
- private List<Dependency> resolveDependencies( Collection<org.apache.maven.model.Dependency> mavenDependencies )
- throws DependencyResolverException
- // CHECKSTYLE_ON: LineLength
- {
- if ( mavenDependencies == null )
- {
- return Collections.emptyList();
- }
-
- ArtifactTypeRegistry typeRegistry = createTypeRegistry();
-
- List<Dependency> aetherDependencies = new ArrayList<>( mavenDependencies.size() );
-
- for ( org.apache.maven.model.Dependency mavenDependency : mavenDependencies )
- {
- aetherDependencies.add( toDependency( mavenDependency, typeRegistry ) );
- }
-
- return aetherDependencies;
- }
-
- @Override
- // CHECKSTYLE_OFF: LineLength
- public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
- Collection<org.apache.maven.model.Dependency> mavenDependencies,
- Collection<org.apache.maven.model.Dependency> managedMavenDependencies, TransformableFilter filter )
- // CHECKSTYLE_ON: LineLength
- throws DependencyResolverException
- {
-
- List<Dependency> aetherDependencies = resolveDependencies( mavenDependencies );
-
- List<Dependency> aetherManagedDependencies = resolveDependencies( managedMavenDependencies );
-
- CollectRequest request = new CollectRequest( aetherDependencies, aetherManagedDependencies,
- aetherRepositories );
-
- return resolveDependencies( filter, request );
- }
-
- // CHECKSTYLE_OFF: LineLength
- private Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
- TransformableFilter dependencyFilter, CollectRequest request ) throws DependencyResolverException
- // CHECKSTYLE_ON :LineLength
- {
- try
- {
- DependencyFilter depFilter = null;
- if ( dependencyFilter != null )
- {
- depFilter = dependencyFilter.transform( new SonatypeAetherFilterTransformer() );
- }
-
- final List<ArtifactResult> dependencyResults = repositorySystem.resolveDependencies( session, request,
- depFilter );
-
- // Keep it lazy! Often artifactsResults aren't used, so transforming up front is too expensive
- return new Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult>()
- {
- @Override
- public Iterator<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> iterator()
- {
- // CHECKSTYLE_OFF: LineLength
- Collection<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> artResults =
- new ArrayList<>(
- dependencyResults.size() );
- // CHECKSTYLE_ON: LineLength
-
- for ( ArtifactResult artifactResult : dependencyResults )
- {
- artResults.add( new Maven30ArtifactResult( artifactResult ) );
- }
-
- return artResults.iterator();
- }
- };
- }
- catch ( ArtifactResolutionException e )
- {
- throw new Maven30DependencyResolverException( e );
- }
- catch ( DependencyCollectionException e )
- {
- throw new Maven30DependencyResolverException( e );
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
deleted file mode 100644
index 699903b..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.apache.maven.shared.transfer.dependencies.resolve.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.List;
-
-import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
-import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResult;
-import org.sonatype.aether.collection.DependencyCollectionException;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-
-/**
- *
- * @author Robert Scholte
- *
- */
-class Maven30DependencyResolverException extends DependencyResolverException
-{
- private DependencyCollectionException dce;
-
- protected Maven30DependencyResolverException( DependencyCollectionException e )
- {
- super( e );
- this.dce = e;
- }
-
- Maven30DependencyResolverException( ArtifactResolutionException e )
- {
- super( e );
- }
-
- @Override
- public DependencyResult getResult()
- {
- return new DependencyResult()
- {
- @Override
- public List<Exception> getCollectorExceptions()
- {
- return dce.getResult().getExceptions();
- }
- };
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java b/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java
deleted file mode 100644
index fde00a8..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.maven.shared.transfer.metadata.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 org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
-import org.sonatype.aether.metadata.Metadata;
-
-/**
- * A MetadataBridge for Maven 3.0
- *
- * @author Robert Scholte
- *
- */
-public class Maven30MetadataBridge implements Metadata
-{
- private ArtifactMetadata metadata;
-
- private File file;
-
- public Maven30MetadataBridge( ArtifactMetadata metadata )
- {
- this.metadata = metadata;
- }
-
- @Override
- public String getGroupId()
- {
- return emptify( metadata.getGroupId() );
- }
-
- @Override
- public String getArtifactId()
- {
- return metadata.storedInGroupDirectory() ? "" : emptify( metadata.getArtifactId() );
- }
-
- @Override
- public String getVersion()
- {
- return metadata.storedInArtifactVersionDirectory() ? emptify( metadata.getBaseVersion() ) : "";
- }
-
- @Override
- public String getType()
- {
- return metadata.getRemoteFilename();
- }
-
- private String emptify( String string )
- {
- return ( string != null ) ? string : "";
- }
-
- @Override
- public File getFile()
- {
- return file;
- }
-
- @Override
- public Maven30MetadataBridge setFile( File file )
- {
- this.file = file;
- return this;
- }
-
- @Override
- public Nature getNature()
- {
- if ( metadata instanceof RepositoryMetadata )
- {
- switch ( ( (RepositoryMetadata) metadata ).getNature() )
- {
- case RepositoryMetadata.RELEASE_OR_SNAPSHOT:
- return Nature.RELEASE_OR_SNAPSHOT;
- case RepositoryMetadata.SNAPSHOT:
- return Nature.SNAPSHOT;
- default:
- return Nature.RELEASE;
- }
- }
- else
- {
- return Nature.RELEASE;
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/repository/internal/DefaultRepositoryManager.java b/src/main/java/org/apache/maven/shared/transfer/repository/internal/DefaultRepositoryManager.java
index c29cc08..c1ee372 100644
--- a/src/main/java/org/apache/maven/shared/transfer/repository/internal/DefaultRepositoryManager.java
+++ b/src/main/java/org/apache/maven/shared/transfer/repository/internal/DefaultRepositoryManager.java
@@ -36,6 +36,8 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
/**
*
@@ -120,68 +122,15 @@ class DefaultRepositoryManager
throw new IllegalStateException( e.getMessage(), e );
}
}
-
- /**
- * @return true if the current Maven version is Maven 3.1.
- */
- private boolean isMaven31()
- {
- return canFindCoreClass( "org.eclipse.aether.artifact.Artifact" ); // Maven 3.1 specific
- }
-
- /**
- * @return true if the current Maven version is Maven 3.0.2
- */
- private boolean isMaven302()
- {
- return canFindCoreClass( "org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory" );
- }
-
- private boolean canFindCoreClass( String className )
- {
- try
- {
- Thread.currentThread().getContextClassLoader().loadClass( className );
-
- return true;
- }
- catch ( ClassNotFoundException e )
- {
- return false;
- }
- }
private MavenRepositoryManager getMavenRepositoryManager( ProjectBuildingRequest buildingRequest )
throws ComponentLookupException, RepositoryManagerException
{
- if ( isMaven31() )
- {
- org.eclipse.aether.RepositorySystem m31RepositorySystem =
- container.lookup( org.eclipse.aether.RepositorySystem.class );
+ RepositorySystem m31RepositorySystem = container.lookup( RepositorySystem.class );
- org.eclipse.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
+ RepositorySystemSession session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- return new Maven31RepositoryManager( m31RepositorySystem, session );
- }
- else
- {
- org.sonatype.aether.RepositorySystem m30RepositorySystem =
- container.lookup( org.sonatype.aether.RepositorySystem.class );
-
- org.sonatype.aether.RepositorySystemSession session = Invoker.invoke( buildingRequest,
- "getRepositorySession" );
-
- if ( isMaven302() )
- {
- return new Maven302RepositoryManager( m30RepositorySystem, session );
-
- }
- else
- {
- return new Maven30RepositoryManager( m30RepositorySystem, session );
- }
- }
+ return new Maven31RepositoryManager( m31RepositorySystem, session );
}
public void contextualize( Context context ) throws ContextException
diff --git a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven302RepositoryManager.java b/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven302RepositoryManager.java
deleted file mode 100644
index 29178f4..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven302RepositoryManager.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.maven.shared.transfer.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.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.LocalRepository;
-
-/**
- *
- */
-class Maven302RepositoryManager
- extends Maven30RepositoryManager
-{
- Maven302RepositoryManager( RepositorySystem repositorySystem, RepositorySystemSession session )
- {
- super( repositorySystem, session );
- }
-
- /**
- * Aether-1.9+ (i.e. M3.0.2+) expects "default", not "enhanced" as repositoryType
- */
- @Override
- protected String resolveRepositoryType( LocalRepository localRepository )
- {
- String repositoryType;
- if ( "enhanced".equals( localRepository.getContentType() ) )
- {
- repositoryType = "default";
- }
- else
- {
- // this should be "simple"
- repositoryType = localRepository.getContentType();
- }
- return repositoryType;
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java b/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java
deleted file mode 100644
index b7b9214..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package org.apache.maven.shared.transfer.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 org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
-import org.apache.maven.shared.transfer.repository.RepositoryManagerException;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.metadata.Metadata;
-import org.sonatype.aether.metadata.Metadata.Nature;
-import org.sonatype.aether.repository.LocalRepository;
-import org.sonatype.aether.repository.LocalRepositoryManager;
-import org.sonatype.aether.util.DefaultRepositoryCache;
-import org.sonatype.aether.util.DefaultRepositorySystemSession;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.metadata.DefaultMetadata;
-
-/**
- *
- */
-class Maven30RepositoryManager
- implements MavenRepositoryManager
-{
- private final RepositorySystem repositorySystem;
-
- private final RepositorySystemSession session;
-
- Maven30RepositoryManager( RepositorySystem repositorySystem, RepositorySystemSession session )
- {
- this.repositorySystem = repositorySystem;
- this.session = session;
- }
-
- @Override
- public String getPathForLocalArtifact( org.apache.maven.artifact.Artifact mavenArtifact )
- {
- Artifact aetherArtifact;
-
- // LRM.getPathForLocalArtifact() won't throw an Exception, so translate reflection error to RuntimeException
- try
- {
- aetherArtifact = (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.apache.maven.artifact.Artifact.class, mavenArtifact );
- }
- catch ( RepositoryManagerException e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
-
- return session.getLocalRepositoryManager().getPathForLocalArtifact( aetherArtifact );
- }
-
- @Override
- public String getPathForLocalArtifact( ArtifactCoordinate coordinate )
- {
- Artifact aetherArtifact = toArtifact( coordinate );
-
- // LRM.getPathForLocalArtifact() won't throw an Exception, so translate reflection error to RuntimeException
-
- return session.getLocalRepositoryManager().getPathForLocalArtifact( aetherArtifact );
- }
-
- @Override
- public String getPathForLocalMetadata( ArtifactMetadata metadata )
- {
- Metadata aetherMetadata =
- new DefaultMetadata( metadata.getGroupId(),
- metadata.storedInGroupDirectory() ? null : metadata.getArtifactId(),
- metadata.storedInArtifactVersionDirectory() ? metadata.getBaseVersion() : null,
- "maven-metadata.xml", Nature.RELEASE_OR_SNAPSHOT );
-
- return session.getLocalRepositoryManager().getPathForLocalMetadata( aetherMetadata );
- }
-
- @Override
- public ProjectBuildingRequest setLocalRepositoryBasedir( ProjectBuildingRequest buildingRequest, File basedir )
- {
- ProjectBuildingRequest newRequest = new DefaultProjectBuildingRequest( buildingRequest );
-
- RepositorySystemSession session;
- try
- {
- session = Invoker.invoke( buildingRequest, "getRepositorySession" );
- }
- catch ( RepositoryManagerException e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
-
- // "clone" session and replace localRepository
- DefaultRepositorySystemSession newSession = new DefaultRepositorySystemSession( session );
-
- // Clear cache, since we're using a new local repository
- newSession.setCache( new DefaultRepositoryCache() );
-
- // keep same repositoryType
- String repositoryType = resolveRepositoryType( session.getLocalRepository() );
-
- LocalRepositoryManager localRepositoryManager =
- repositorySystem.newLocalRepositoryManager( new LocalRepository( basedir, repositoryType ) );
-
- newSession.setLocalRepositoryManager( localRepositoryManager );
-
- try
- {
- Invoker.invoke( newRequest, "setRepositorySession", RepositorySystemSession.class, newSession );
- }
- catch ( RepositoryManagerException e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
-
- return newRequest;
- }
-
- @Override
- public File getLocalRepositoryBasedir()
- {
- return session.getLocalRepository().getBasedir();
- }
-
- /**
- * @param localRepository {@link LocalRepository}
- * @return the resolved type.
- */
- protected String resolveRepositoryType( LocalRepository localRepository )
- {
- return localRepository.getContentType();
- }
-
- /**
- * @param coordinate {@link ArtifactCoordinate}
- * @return {@link Artifact}
- */
- protected Artifact toArtifact( ArtifactCoordinate coordinate )
- {
- if ( coordinate == null )
- {
- return null;
- }
-
- Artifact result =
- new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
- coordinate.getExtension(), coordinate.getVersion() );
-
- return result;
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java b/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
index 6f486a0..8ca19c6 100644
--- a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
+++ b/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
@@ -172,10 +172,7 @@ class Maven31RepositoryManager
return null;
}
- Artifact result =
- new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
- coordinate.getExtension(), coordinate.getVersion() );
-
- return result;
+ return new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
+ coordinate.getExtension(), coordinate.getVersion() );
}
}
diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index 1c729a6..034470d 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -29,7 +29,7 @@
${project.name}
The Maven Artifact Transfer Component is a library
- to install, deploy and resolve artifacts in Maven 3.
+ to install, deploy and resolve artifacts in Maven 3.1+
The {{{./comparison.html} comparison shows}} the differences between
a dependency, an artifact, and a Maven project.
diff --git a/src/test/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployerTest.java b/src/test/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployerTest.java
index 14ce5c4..d5e55b3 100644
--- a/src/test/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployerTest.java
+++ b/src/test/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployerTest.java
@@ -19,20 +19,19 @@ package org.apache.maven.shared.transfer.artifact.deploy.internal;
* under the License.
*/
-import static org.mockito.Mockito.mock;
-
-import java.util.Collections;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer;
import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
-import org.apache.maven.shared.transfer.artifact.deploy.internal.DefaultArtifactDeployer;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.util.Collections;
+
+import static org.mockito.Mockito.mock;
+
/**
* Check the parameter contracts which have been made based on the interface {@link ArtifactDeployer}.
*
diff --git a/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java b/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
deleted file mode 100644
index 19d1939..0000000
--- a/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.apache.maven.shared.transfer.artifact.install.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.Arrays;
-import java.util.Collection;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
-import org.apache.maven.shared.transfer.artifact.install.internal.Maven30ArtifactInstaller;
-import org.codehaus.plexus.PlexusTestCase;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
-
-public class Maven30ArtifactInstallerTest extends PlexusTestCase
-{
- private final File localRepo = new File( "target/tests/local-repo" );
-
- private RepositorySystem repositorySystem;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- repositorySystem = lookup( RepositorySystem.class );
- }
-
- public void testInstall() throws Exception
- {
- DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
- MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
- buildingRequest.setRepositorySession( repositorySession );
-
- DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler();
- artifactHandler.setExtension( "EXTENSION" );
-
- File artifactsDirectory = new File( "target/tests/artifacts" );
- artifactsDirectory.mkdirs();
- File tmpFile = File.createTempFile( "test-install", ".jar", artifactsDirectory );
-
- DefaultArtifact artifact = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", null, artifactHandler );
- artifact.setFile( tmpFile );
- DefaultArtifact artifactWithClassifier = new DefaultArtifact( "GROUPID", "ARTIFACTID", "VERSION", "compile", "jar", "CLASSIFIER", artifactHandler );
- artifactWithClassifier.setFile( tmpFile );
-
- Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier );
-
- MavenArtifactInstaller installer = new Maven30ArtifactInstaller( repositorySystem, repositorySession );
- installer.install( mavenArtifacts );
-
- assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() );
- assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() );
- assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/maven-metadata-local.xml" ).exists() ); //??
- }
-}
diff --git a/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java b/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
deleted file mode 100644
index 6e20cb4..0000000
--- a/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.apache.maven.shared.transfer.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 org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
-import org.apache.maven.shared.transfer.repository.internal.Maven30RepositoryManager;
-import org.codehaus.plexus.PlexusTestCase;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager;
-import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
-
-public class Maven30RepositoryManagerTest extends PlexusTestCase
-{
-
- private final File localRepo = new File( "target/tests/local-repo" );
-
- private RepositorySystem repositorySystem;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- repositorySystem = lookup( RepositorySystem.class );
- }
-
- public void testSetLocalRepositoryBasedirSimple()
- {
- DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
- MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
- buildingRequest.setRepositorySession( repositorySession );
-
- File basedir = new File( "NEW/LOCAL/REPO" );
-
- Maven30RepositoryManager repositoryManager =
- new Maven30RepositoryManager( repositorySystem, buildingRequest.getRepositorySession() );
-
- ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir );
-
- assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() );
-
- }
-
- public void testSetLocalRepositoryBasedirEnhanced()
- {
- DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
- MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
- repositorySession.setLocalRepositoryManager( new EnhancedLocalRepositoryManager( localRepo ) );
- buildingRequest.setRepositorySession( repositorySession );
-
- File basedir = new File( "NEW/LOCAL/REPO" );
-
- Maven30RepositoryManager repositoryManager =
- new Maven30RepositoryManager( repositorySystem, buildingRequest.getRepositorySession() );
-
- ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir );
-
- assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() );
-
- }
-
-}