You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/09/22 12:46:19 UTC
[maven-artifact-transfer] branch master updated: [MSHARED-987] Make
use of SISU (#24)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git
The following commit(s) were added to refs/heads/master by this push:
new ea7e7af [MSHARED-987] Make use of SISU (#24)
ea7e7af is described below
commit ea7e7af3a97dda668166c481c3eb075bca5b51d6
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Wed Sep 22 14:00:01 2021 +0200
[MSHARED-987] Make use of SISU (#24)
Drop all the reflection hoops and loops, and organize into api-provider layout. Should have NO IMPACT on consumers.
Implement using this SISU based pattern: https://github.com/cstamas/providers In short: SISU loads components lazily, and silently skips component that throws CNFEx during load. Moreover, Selector "figures our" current environment, more narrowing used delegate.
Changes at high level:
* code reorganization: maven-artifact-transfer-api (new), maven-artifact-transfer-maven-3.0.x (new), maven-artifact-transfer-maven-3.1.x (new) and maven-artifact-transfer (old).
* each module defines it's own (provided) expected environment and cleanly code against it, no reflection, no black magic
* using SISU collection lookup and some minor logic (not yet fully done, works for 3.0/3.1 case but could be improved, 302 repo exception is NOT in yet).
* existing UTs unmodified pass
* existing ITs unmodified pass except for 3.0.5
Benefits:
* each provider module set up it's "own" classpath, no need for reflection and overlapping dependency mess
* dropping a version support is just dropping a module
* adding new version support is just adding a new module
* consumers of m-a-t needs no change
---
maven-3.0.x/pom.xml | 144 ++++++
.../deploy/internal/Maven30ArtifactDeployer.java | 69 +--
.../install/internal/Maven30ArtifactInstaller.java | 78 ++-
.../resolve/internal/Maven30ArtifactResolver.java | 110 +++++
.../resolve/internal/Maven30ArtifactResult.java | 105 ++--
.../internal/Maven30ArtifactRepositoryAdapter.java | 12 +
.../collection/internal/Maven30CollectResult.java | 0
.../internal/Maven30DependencyCollector.java | 101 ++--
.../internal/Maven30DependencyNodeAdapter.java | 11 +-
.../internal/Maven30ArtifactRepositoryAdapter.java | 544 +++++++++++----------
.../collect/internal/Maven30CollectorResult.java | 170 +++----
.../internal/Maven30DependencyCollector.java | 325 ++++++------
.../internal/Maven30DependencyNodeAdapter.java | 11 +-
.../resolve/internal/Maven30ArtifactResult.java | 105 ++--
.../internal/Maven30DependencyResolver.java | 492 ++++++++++---------
.../Maven30DependencyResolverException.java | 122 ++---
.../metadata/internal/Maven30MetadataBridge.java | 0
.../internal/Maven30RepositoryManager.java | 168 +++++++
.../aether/util/artifact/AbstractArtifact.java | 188 +++++++
.../aether/util/artifact/DefaultArtifact.java | 360 ++++++++++++++
.../sonatype/aether/util/artifact/SubArtifact.java | 203 ++++++++
.../internal/Maven30ArtifactInstallerTest.java | 9 +-
.../internal/Maven30RepositoryManagerTest.java | 11 +-
maven-3.1.x/pom.xml | 151 ++++++
.../deploy/internal/Maven31ArtifactDeployer.java | 56 ++-
.../install/internal/Maven31ArtifactInstaller.java | 71 ++-
.../resolve/internal/Maven31ArtifactResolver.java | 76 +--
.../resolve/internal/Maven31ArtifactResult.java | 108 ++--
.../internal/Maven31ArtifactRepositoryAdapter.java | 12 +
.../collection/internal/Maven31CollectResult.java | 0
.../internal/Maven31DependencyCollector.java | 104 ++--
.../internal/Maven31DependencyNodeAdapter.java | 11 +-
.../internal/Maven31ArtifactRepositoryAdapter.java | 544 +++++++++++----------
.../collect/internal/Maven31CollectorResult.java | 170 +++----
.../internal/Maven31DependencyCollector.java | 323 ++++++------
.../internal/Maven31DependencyNodeAdapter.java | 11 +-
.../resolve/internal/Maven31ArtifactResult.java | 108 ++--
.../internal/Maven31DependencyResolver.java | 480 +++++++++---------
.../Maven31DependencyResolverException.java | 110 ++---
.../metadata/internal/Maven31MetadataBridge.java | 0
.../internal/Maven31RepositoryManager.java | 104 ++--
maven-artifact-transfer-api/pom.xml | 113 +++++
.../transfer/artifact/ArtifactCoordinate.java | 118 ++---
.../artifact/DefaultArtifactCoordinate.java | 368 +++++++-------
.../shared/transfer/artifact/TransferUtils.java | 250 +++++-----
.../transfer/artifact/deploy/ArtifactDeployer.java | 0
.../artifact/deploy/ArtifactDeployerException.java | 0
.../deploy/internal/ArtifactDeployerDelegate.java | 12 +-
.../deploy/internal/DefaultArtifactDeployer.java | 86 ++++
.../artifact/install/ArtifactInstaller.java | 1 -
.../install/ArtifactInstallerException.java | 0
.../internal/ArtifactInstallerDelegate.java | 13 +-
.../install/internal/DefaultArtifactInstaller.java | 95 ++++
.../artifact/resolve/ArtifactResolver.java | 0
.../resolve/ArtifactResolverException.java | 0
.../transfer/artifact/resolve/ArtifactResult.java | 72 +--
.../resolve/internal/ArtifactResolverDelegate.java | 12 +-
.../resolve/internal/DefaultArtifactResolver.java | 95 ++++
.../shared/transfer/collection/CollectRequest.java | 0
.../shared/transfer/collection/CollectResult.java | 0
.../collection/DependencyCollectionException.java | 0
.../transfer/collection/DependencyCollector.java | 0
.../internal/DefaultDependencyCollector.java | 113 +++++
.../internal/DependencyCollectorDelegate.java | 12 +-
.../dependencies/DefaultDependableCoordinate.java | 366 +++++++-------
.../dependencies/DependableCoordinate.java | 140 +++---
.../transfer/dependencies/TransferUtils.java | 272 +++++------
.../dependencies/collect/CollectorResult.java | 74 +--
.../dependencies/collect/DependencyCollector.java | 146 +++---
.../collect/DependencyCollectorException.java | 86 ++--
.../internal/DefaultDependencyCollector.java | 112 +++++
.../internal/DependencyCollectorDelegate.java | 12 +-
.../dependencies/resolve/DependencyResolver.java | 162 +++---
.../resolve/DependencyResolverException.java | 108 ++--
.../dependencies/resolve/DependencyResult.java | 74 +--
.../internal/DefaultDependencyResolver.java | 115 +++++
.../internal/DependencyResolverDelegate.java | 12 +-
.../shared/transfer/graph/DependencyNode.java | 0
.../shared/transfer/graph/DependencyVisitor.java | 0
.../shared/transfer/metadata/ArtifactMetadata.java | 0
.../transfer/project/NoFileAssignedException.java | 0
.../transfer/project/deploy/ProjectDeployer.java | 0
.../project/deploy/ProjectDeployerRequest.java | 264 +++++-----
.../deploy/internal/DefaultProjectDeployer.java | 47 +-
.../transfer/project/install/ProjectInstaller.java | 0
.../project/install/ProjectInstallerRequest.java | 102 ++--
.../install/internal/DefaultProjectInstaller.java | 45 +-
.../transfer/repository/RepositoryManager.java | 0
.../repository/RepositoryManagerException.java | 0
.../internal/DefaultRepositoryManager.java | 86 ++++
.../internal/RepositoryManagerDelegate.java | 12 +-
.../shared/transfer/support/ComponentSupport.java | 101 ++--
.../shared/transfer/support/DelegateSupport.java | 15 +-
.../maven/shared/transfer/support/Selector.java | 81 +++
.../apache/maven/shared/transfer/support/Trap.java | 71 +++
maven-artifact-transfer/pom.xml | 190 +++++++
.../src}/it/maven-artifact-deployer-plugin/pom.xml | 0
.../artifact/deployer/ArtifactDeployerMojo.java | 0
.../artifact/deployer/ArtifactDeployerTest.java | 4 +-
.../src/test/projects/example/pom.xml | 0
.../it/maven-artifact-installer-plugin/pom.xml | 0
.../artifact/installer/ArtifactInstallerMojo.java | 1 -
.../artifact/installer/ArtifactInstallerTest.java | 2 +-
.../src/test/projects/example/pom.xml | 0
.../it/maven-dependency-collector-plugin/pom.xml | 0
.../collector/DependencyCollectorMojo.java | 0
.../collector/DependencyCollectorTest.java | 2 +-
.../src/test/projects/example/pom.xml | 0
.../src}/it/maven-project-deployer-plugin/pom.xml | 0
.../plugin/project/deploy/ProjectDeployerMojo.java | 0
.../plugin/project/deploy/ProjectDeployerTest.java | 2 +-
.../src/test/projects/example/pom.xml | 0
.../src}/it/maven-project-installer-plugin/pom.xml | 0
.../project/install/ProjectInstallerMojo.java | 0
.../project/install/ProjectInstallerTest.java | 2 +-
.../src/test/projects/example/pom.xml | 0
.../src/test/projects/pom-only-example/pom.xml | 0
.../src}/it/settings.xml | 0
.../apache/maven/shared/transfer/TestUtils.java | 54 ++
.../artifact/DefaultArtifactCoordinateTest.java | 99 ++--
.../internal/DefaultArtifactDeployerTest.java | 25 +-
.../internal/DefaultArtifactInstallerTest.java | 35 +-
.../internal/DefaultArtifactResolverTest.java | 20 +-
.../internal/DefaultDependencyCollectorTest.java | 18 +-
.../DefaultDependableCoordinateTest.java | 103 ++--
.../internal/DefaultDependencyCollectorTest.java | 12 +-
.../internal/DefaultDependencyResolverTest.java | 13 +-
.../internal/DefaultProjectDeployerTest.java | 10 +-
.../internal/DefaultProjectInstallerTest.java | 10 +-
pom.xml | 425 +++++++---------
.../deploy/internal/DefaultArtifactDeployer.java | 145 ------
.../transfer/artifact/deploy/internal/Invoker.java | 66 ---
.../deploy/internal/MavenArtifactDeployer.java | 42 --
.../install/internal/DefaultArtifactInstaller.java | 162 ------
.../artifact/install/internal/Invoker.java | 65 ---
.../resolve/internal/DefaultArtifactResolver.java | 163 ------
.../artifact/resolve/internal/Invoker.java | 67 ---
.../resolve/internal/Maven30ArtifactResolver.java | 107 ----
.../resolve/internal/MavenArtifactResolver.java | 38 --
.../internal/DefaultDependencyCollector.java | 195 --------
.../transfer/collection/internal/Invoker.java | 96 ----
.../internal/MavenDependencyCollector.java | 43 --
.../internal/DefaultDependencyCollector.java | 198 --------
.../dependencies/collect/internal/Invoker.java | 93 ----
.../collect/internal/MavenDependencyCollector.java | 44 --
.../internal/DefaultDependencyResolver.java | 190 -------
.../dependencies/resolve/internal/Invoker.java | 95 ----
.../resolve/internal/MavenDependencyResolver.java | 51 --
.../shared/transfer/project/MavenAetherUtils.java | 100 ----
.../internal/DefaultRepositoryManager.java | 191 --------
.../transfer/repository/internal/Invoker.java | 79 ---
.../internal/Maven302RepositoryManager.java | 55 ---
.../internal/Maven30RepositoryManager.java | 172 -------
.../internal/MavenRepositoryManager.java | 67 ---
154 files changed, 6528 insertions(+), 6663 deletions(-)
diff --git a/maven-3.0.x/pom.xml b/maven-3.0.x/pom.xml
new file mode 100644
index 0000000..08f6158
--- /dev/null
+++ b/maven-3.0.x/pom.xml
@@ -0,0 +1,144 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-artifact-transfer-maven-3.0.x</artifactId>
+
+ <name>Apache Maven Artifact Transfer Maven 3.0.x provider</name>
+
+ <properties>
+ <maven30x.version>3.0.5</maven30x.version>
+ <sonatypeAether.version>1.13.1</sonatypeAether.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer-api</artifactId>
+ </dependency>
+ <!-- Not provided, as it is not present in Maven 3.0.x -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven30x.version}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-plexus</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven30x.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven30x.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <version>${sisu.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${sonatypeAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-impl</artifactId>
+ <version>${sonatypeAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ <version>${sonatypeAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ </dependency>
+
+ <!-- TEST -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
similarity index 68%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
index 611eb4c..2eec2df 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven30ArtifactDeployer.java
@@ -19,15 +19,18 @@ package org.apache.maven.shared.transfer.artifact.deploy.internal;
* 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.ProjectBuildingRequest;
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.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
@@ -36,34 +39,42 @@ import org.sonatype.aether.deployment.DeploymentException;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.util.artifact.SubArtifact;
+import java.util.Collection;
+import java.util.Objects;
+
/**
- *
+ *
*/
-class Maven30ArtifactDeployer
- implements MavenArtifactDeployer
+@Component( role = ArtifactDeployerDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30ArtifactDeployer
+ extends DelegateSupport
+ implements ArtifactDeployerDelegate
{
+ @Requirement
+ private RepositorySystem repositorySystem;
- private final RepositorySystem repositorySystem;
-
- private final RepositorySystemSession session;
-
- Maven30ArtifactDeployer( RepositorySystem repositorySystem, RepositorySystemSession session )
+ public Maven30ArtifactDeployer()
{
- this.repositorySystem = repositorySystem;
- this.session = session;
+ }
+
+ public Maven30ArtifactDeployer( RepositorySystem repositorySystem )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
}
@Override
- public void deploy( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactDeployerException
+ public void deploy( ProjectBuildingRequest buildingRequest,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactDeployerException
{
- deploy( null, mavenArtifacts );
+ deploy( buildingRequest, null, mavenArtifacts );
}
@Override
- public void deploy( ArtifactRepository remoteRepository,
+ public void deploy( ProjectBuildingRequest buildingRequest,
+ ArtifactRepository remoteRepository,
Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactDeployerException
+ throws ArtifactDeployerException
{
// prepare request
DeployRequest request = new DeployRequest();
@@ -72,20 +83,20 @@ class Maven30ArtifactDeployer
if ( remoteRepository != null )
{
- defaultRepository = getRemoteRepository( session, remoteRepository );
+ defaultRepository = getRemoteRepository( buildingRequest.getRepositorySession(), 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 );
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
request.addArtifact( aetherArtifact );
RemoteRepository aetherRepository;
if ( remoteRepository == null )
{
- aetherRepository = getRemoteRepository( session, mavenArtifact.getRepository() );
+ aetherRepository = getRemoteRepository( buildingRequest.getRepositorySession(),
+ mavenArtifact.getRepository() );
}
else
{
@@ -103,15 +114,15 @@ class Maven30ArtifactDeployer
request.addArtifact( pomArtifact );
}
else if ( // metadata instanceof SnapshotArtifactRepositoryMetadata ||
- metadata instanceof ArtifactRepositoryMetadata )
+ 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;
-
+ (org.apache.maven.shared.transfer.metadata.ArtifactMetadata) metadata;
+
request.addMetadata( new Maven30MetadataBridge( metadata ).setFile( transferMedata.getFile() ) );
}
}
@@ -120,7 +131,7 @@ class Maven30ArtifactDeployer
// deploy
try
{
- repositorySystem.deploy( session, request );
+ repositorySystem.deploy( buildingRequest.getRepositorySession(), request );
}
catch ( DeploymentException e )
{
@@ -128,12 +139,10 @@ class Maven30ArtifactDeployer
}
}
- private RemoteRepository getRemoteRepository( RepositorySystemSession session, ArtifactRepository remoteRepository )
- throws ArtifactDeployerException
+ private RemoteRepository getRemoteRepository( RepositorySystemSession session,
+ ArtifactRepository remoteRepository )
{
- RemoteRepository aetherRepo = Invoker.invoke( RepositoryUtils.class, "toRepo",
- ArtifactRepository.class,
- remoteRepository );
+ RemoteRepository aetherRepo = RepositoryUtils.toRepo( remoteRepository );
if ( aetherRepo.getAuthentication() == null )
{
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
similarity index 58%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
index fbff698..1f957b7 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstaller.java
@@ -19,49 +19,80 @@ package org.apache.maven.shared.transfer.artifact.install.internal;
* 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.ProjectBuildingRequest;
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.apache.maven.shared.transfer.repository.RepositoryManager;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
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;
+import java.io.File;
+import java.util.Collection;
+import java.util.Objects;
+
/**
- *
+ *
*/
-class Maven30ArtifactInstaller
- implements MavenArtifactInstaller
+@Component( role = ArtifactInstallerDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30ArtifactInstaller
+ extends DelegateSupport
+ implements ArtifactInstallerDelegate
{
- private final RepositorySystem repositorySystem;
-
- private final RepositorySystemSession session;
-
- Maven30ArtifactInstaller( RepositorySystem repositorySystem, RepositorySystemSession session )
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ @Requirement
+ private RepositoryManager repositoryManager;
+
+ public Maven30ArtifactInstaller()
{
- this.repositorySystem = repositorySystem;
- this.session = session;
+ }
+
+ public Maven30ArtifactInstaller( RepositorySystem repositorySystem,
+ RepositoryManager repositoryManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.repositoryManager = Objects.requireNonNull( repositoryManager );
+ }
+
+ @Override
+ public void install( ProjectBuildingRequest buildingRequest,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactInstallerException
+ {
+ install( buildingRequest, null, mavenArtifacts );
}
@Override
- public void install( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactInstallerException
+ public void install( ProjectBuildingRequest buildingRequest,
+ File localRepository,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactInstallerException
{
+ ProjectBuildingRequest currentBuildingRequest = buildingRequest;
+ if ( localRepository != null )
+ {
+ // update local repo in request
+ currentBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepository );
+ }
// 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 );
+ Artifact mainArtifact = RepositoryUtils.toArtifact( mavenArtifact );
request.addArtifact( mainArtifact );
for ( ArtifactMetadata metadata : mavenArtifact.getMetadataList() )
@@ -73,29 +104,24 @@ class Maven30ArtifactInstaller
request.addArtifact( pomArtifact );
}
else if ( // metadata instanceof SnapshotArtifactRepositoryMetadata ||
- metadata instanceof ArtifactRepositoryMetadata )
+ 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;
-
+ (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 );
+ repositorySystem.install( currentBuildingRequest.getRepositorySession(), request );
}
catch ( InstallationException e )
{
diff --git a/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java
new file mode 100644
index 0000000..3e2ab1a
--- /dev/null
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResolver.java
@@ -0,0 +1,110 @@
+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.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.artifact.Artifact;
+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;
+
+import java.util.Objects;
+
+/**
+ *
+ */
+@Component( role = ArtifactResolverDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30ArtifactResolver
+ extends DelegateSupport
+ implements ArtifactResolverDelegate
+{
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ public Maven30ArtifactResolver()
+ {
+ }
+
+ public Maven30ArtifactResolver( RepositorySystem repositorySystem )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ }
+
+ @Override
+ public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
+ org.apache.maven.artifact.Artifact mavenArtifact ) throws ArtifactResolverException
+ {
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
+
+ return resolveArtifact( buildingRequest, aetherArtifact );
+ }
+
+ @Override
+ public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
+ ArtifactCoordinate coordinate ) throws ArtifactResolverException
+ {
+ Artifact aetherArtifact = new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(),
+ coordinate.getClassifier(), coordinate.getExtension(), coordinate.getVersion() );
+
+ return resolveArtifact( buildingRequest, aetherArtifact );
+ }
+
+ private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
+ Artifact aetherArtifact ) throws ArtifactResolverException
+ {
+ try
+ {
+ // use descriptor to respect relocation
+ ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest( aetherArtifact,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ),
+ null );
+
+ ArtifactDescriptorResult descriptorResult = repositorySystem.readArtifactDescriptor(
+ buildingRequest.getRepositorySession(),
+ descriptorRequest );
+
+ ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(),
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ),
+ null );
+
+ return new Maven30ArtifactResult( repositorySystem.resolveArtifact(
+ buildingRequest.getRepositorySession(), 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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
similarity index 77%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
index 3bbea28..240e06e 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven30ArtifactResult.java
@@ -1,57 +1,48 @@
-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 );
- }
- }
-}
+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.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()
+ {
+ return RepositoryUtils.toArtifact( artifactResult.getArtifact() );
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
index 40d9143..0b6d456 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30ArtifactRepositoryAdapter.java
@@ -207,6 +207,18 @@ class Maven30ArtifactRepositoryAdapter implements ArtifactRepository
}
@Override
+ public List<ArtifactRepository> getMirroredRepositories()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30CollectResult.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
similarity index 60%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
index 108db21..7a0674c 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyCollector.java
@@ -19,102 +19,102 @@ package org.apache.maven.shared.transfer.collection.internal;
* 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.project.ProjectBuildingRequest;
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.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
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;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
/**
- * Maven 3.0 implementation of the {@link DependencyCollector}
- *
- * @author Robert Scholte
*
*/
-class Maven30DependencyCollector
- implements MavenDependencyCollector
+@Component( role = DependencyCollectorDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30DependencyCollector
+ extends DelegateSupport
+ implements DependencyCollectorDelegate
{
- private final RepositorySystem repositorySystem;
+ @Requirement
+ private RepositorySystem repositorySystem;
- private final ArtifactHandlerManager artifactHandlerManager;
+ @Requirement
+ private ArtifactHandlerManager artifactHandlerManager;
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> aetherRepositories;
-
- Maven30DependencyCollector( RepositorySystem repositorySystem, ArtifactHandlerManager artifactHandlerManager,
- RepositorySystemSession session, List<RemoteRepository> aetherRepositories )
+ public Maven30DependencyCollector()
{
- super();
- this.repositorySystem = repositorySystem;
- this.artifactHandlerManager = artifactHandlerManager;
- this.session = session;
- this.aetherRepositories = aetherRepositories;
+ }
+
+ public Maven30DependencyCollector( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
}
@Override
- public CollectResult collectDependencies( org.apache.maven.model.Dependency root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.model.Dependency root )
+ throws DependencyCollectionException
{
- ArtifactTypeRegistry typeRegistry = Invoker
- .invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
CollectRequest request = new CollectRequest();
request.setRoot( toDependency( root, typeRegistry ) );
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
@Override
- public CollectResult collectDependencies( DependableCoordinate root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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() );
+ extension, root.getVersion() );
CollectRequest request = new CollectRequest();
request.setRoot( new Dependency( aetherArtifact, null ) );
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
@Override
- public CollectResult collectDependencies( Model root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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() );
+ 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 );
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
List<Dependency> aetherDependencies = new ArrayList<>( root.getDependencies().size() );
for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencies() )
@@ -136,17 +136,19 @@ class Maven30DependencyCollector
request.setManagedDependencies( aetherManagerDependencies );
}
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
- private CollectResult collectDependencies( CollectRequest request )
- throws DependencyCollectionException
+ private CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ CollectRequest request )
+ throws DependencyCollectionException
{
- request.setRepositories( aetherRepositories );
+ request.setRepositories( RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
try
{
- return new Maven30CollectResult( repositorySystem.collectDependencies( session, request ) );
+ return new Maven30CollectResult( repositorySystem.collectDependencies(
+ buildingRequest.getRepositorySession(), request ) );
}
catch ( org.sonatype.aether.collection.DependencyCollectionException e )
{
@@ -156,12 +158,7 @@ class Maven30DependencyCollector
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 );
+ return RepositoryUtils.toDependency( mavenDependency, typeRegistry );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
similarity index 92%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
index fa96b35..cee74b9 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven30DependencyNodeAdapter.java
@@ -25,7 +25,6 @@ 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;
@@ -150,14 +149,6 @@ class Maven30DependencyNodeAdapter implements DependencyNode
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 );
- }
+ return RepositoryUtils.toArtifact( aetherArtifact );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
index b09ccd4..a1ba19d 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30ArtifactRepositoryAdapter.java
@@ -1,266 +1,278 @@
-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;
- }
-}
+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 List<ArtifactRepository> getMirroredRepositories()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ 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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
index 081dd66..926bfe6 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30CollectorResult.java
@@ -1,85 +1,85 @@
-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;
- }
-
-}
+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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
similarity index 62%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
index 8a85003..bbf2628 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyCollector.java
@@ -1,160 +1,165 @@
-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 );
- }
- }
-}
+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 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.project.ProjectBuildingRequest;
+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.DependencyCollectorException;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.sonatype.aether.RepositorySystem;
+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.util.artifact.DefaultArtifact;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ *
+ */
+@Component( role = DependencyCollectorDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30DependencyCollector
+ extends DelegateSupport
+ implements DependencyCollectorDelegate
+{
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ @Requirement
+ private ArtifactHandlerManager artifactHandlerManager;
+
+ public Maven30DependencyCollector()
+ {
+ }
+
+ public Maven30DependencyCollector( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
+ }
+
+ private static Dependency toDependency( org.apache.maven.model.Dependency mavenDependency,
+ ArtifactTypeRegistry typeRegistry )
+ {
+ return RepositoryUtils.toDependency( mavenDependency, typeRegistry );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.model.Dependency root )
+ throws DependencyCollectorException
+ {
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
+
+ CollectRequest request = new CollectRequest();
+ request.setRoot( toDependency( root, typeRegistry ) );
+
+ return collectDependencies( buildingRequest, request );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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( buildingRequest, request );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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 = RepositoryUtils.newArtifactTypeRegistry( 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( buildingRequest, request );
+ }
+
+ private CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ CollectRequest request )
+ throws DependencyCollectorException
+ {
+ request.setRepositories( RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ try
+ {
+ return new Maven30CollectorResult( repositorySystem.collectDependencies(
+ buildingRequest.getRepositorySession(), 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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
similarity index 92%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
index 87a10f8..31bc665 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven30DependencyNodeAdapter.java
@@ -25,7 +25,6 @@ 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;
@@ -150,14 +149,6 @@ class Maven30DependencyNodeAdapter implements DependencyNode
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 );
- }
+ return RepositoryUtils.toArtifact( aetherArtifact );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
similarity index 77%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
index b9f37d9..2d33053 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30ArtifactResult.java
@@ -1,57 +1,48 @@
-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 );
- }
- }
-}
+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.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()
+ {
+ return RepositoryUtils.toArtifact( artifactResult.getArtifact() );
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
similarity index 70%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
index 031d604..a540f0b 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolver.java
@@ -1,247 +1,245 @@
-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 );
- }
- }
-}
+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.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.project.ProjectBuildingRequest;
+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.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.sonatype.aether.RepositorySystem;
+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.resolution.ArtifactResolutionException;
+import org.sonatype.aether.resolution.ArtifactResult;
+import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.sonatype.aether.util.artifact.DefaultArtifactType;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ *
+ */
+@Component( role = DependencyResolverDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30DependencyResolver
+ extends DelegateSupport
+ implements DependencyResolverDelegate
+{
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ @Requirement
+ private ArtifactHandlerManager artifactHandlerManager;
+
+ public Maven30DependencyResolver()
+ {
+ }
+
+ public Maven30DependencyResolver( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
+ }
+
+ /**
+ * Based on RepositoryUtils#toDependency(org.apache.maven.model.Dependency, ArtifactTypeRegistry)
+ *
+ * @param coordinate {@link DependableCoordinate}
+ * @param stereotypes {@link org.sonatype.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 )
+ {
+ return RepositoryUtils.toDependency( mavenDependency, typeRegistry );
+ }
+
+ @Override
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ DependableCoordinate coordinate,
+ TransformableFilter dependencyFilter ) throws DependencyResolverException
+ {
+ ArtifactTypeRegistry typeRegistry = createTypeRegistry();
+
+ Dependency aetherRoot = toDependency( coordinate, typeRegistry );
+
+ CollectRequest request = new CollectRequest( aetherRoot,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ return resolveDependencies( buildingRequest, dependencyFilter, request );
+ }
+
+ private ArtifactTypeRegistry createTypeRegistry()
+ {
+ return RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
+ }
+
+ @Override
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ Model model,
+ TransformableFilter dependencyFilter ) 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,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ request.setDependencies( resolveDependencies( model.getDependencies() ) );
+
+ DependencyManagement mavenDependencyManagement = model.getDependencyManagement();
+ if ( mavenDependencyManagement != null )
+ {
+ request.setManagedDependencies( resolveDependencies( mavenDependencyManagement.getDependencies() ) );
+ }
+
+ return resolveDependencies( buildingRequest, 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.
+ */
+ private List<Dependency> resolveDependencies( Collection<org.apache.maven.model.Dependency> mavenDependencies )
+ {
+ 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
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ Collection<org.apache.maven.model.Dependency> mavenDependencies,
+ Collection<org.apache.maven.model.Dependency> managedMavenDependencies,
+ TransformableFilter filter ) throws DependencyResolverException
+ {
+ List<Dependency> aetherDependencies = resolveDependencies( mavenDependencies );
+
+ List<Dependency> aetherManagedDependencies = resolveDependencies( managedMavenDependencies );
+
+ CollectRequest request = new CollectRequest( aetherDependencies, aetherManagedDependencies,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ return resolveDependencies( buildingRequest, filter, request );
+ }
+
+ private Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ TransformableFilter dependencyFilter,
+ CollectRequest request ) throws DependencyResolverException
+ {
+ try
+ {
+ DependencyFilter depFilter = null;
+ if ( dependencyFilter != null )
+ {
+ depFilter = dependencyFilter.transform( new SonatypeAetherFilterTransformer() );
+ }
+
+ final List<ArtifactResult> dependencyResults = repositorySystem.resolveDependencies(
+ buildingRequest.getRepositorySession(), 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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
index 699903b..9b5f6fd 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven30DependencyResolverException.java
@@ -1,61 +1,61 @@
-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();
- }
- };
- }
-}
+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/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java
rename to maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven30MetadataBridge.java
diff --git a/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java
new file mode 100644
index 0000000..45c7f64
--- /dev/null
+++ b/maven-3.0.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManager.java
@@ -0,0 +1,168 @@
+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.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.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+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;
+
+import java.io.File;
+import java.util.Objects;
+
+/**
+ *
+ */
+@Component( role = RepositoryManagerDelegate.class, hint = Selector.MAVEN_3_0_X )
+public class Maven30RepositoryManager
+ extends DelegateSupport
+ implements RepositoryManagerDelegate
+{
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ public Maven30RepositoryManager()
+ {
+ }
+
+ public Maven30RepositoryManager( RepositorySystem repositorySystem )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ }
+
+ @Override
+ public String getPathForLocalArtifact( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.artifact.Artifact mavenArtifact )
+ {
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
+
+ return buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
+ aetherArtifact );
+ }
+
+ @Override
+ public String getPathForLocalArtifact( ProjectBuildingRequest buildingRequest,
+ ArtifactCoordinate coordinate )
+ {
+ Artifact aetherArtifact = toArtifact( coordinate );
+
+ // LRM.getPathForLocalArtifact() won't throw an Exception, so translate reflection error to RuntimeException
+
+ return buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
+ aetherArtifact );
+ }
+
+ @Override
+ public String getPathForLocalMetadata( ProjectBuildingRequest buildingRequest,
+ 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 buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalMetadata(
+ aetherMetadata );
+ }
+
+ @Override
+ public ProjectBuildingRequest setLocalRepositoryBasedir( ProjectBuildingRequest buildingRequest,
+ File basedir )
+ {
+ ProjectBuildingRequest newRequest = new DefaultProjectBuildingRequest( buildingRequest );
+
+ RepositorySystemSession session = buildingRequest.getRepositorySession();
+
+ // "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 );
+
+ newRequest.setRepositorySession( newSession );
+
+ return newRequest;
+ }
+
+ @Override
+ public File getLocalRepositoryBasedir( ProjectBuildingRequest buildingRequest )
+ {
+ return buildingRequest.getRepositorySession().getLocalRepository().getBasedir();
+ }
+
+ /**
+ * Aether-1.9+ (i.e. M3.0.2+) expects "default", not "enhanced" as repositoryType
+ */
+ private String resolveRepositoryType( LocalRepository localRepository )
+ {
+ String repositoryType;
+ if ( "enhanced".equals( localRepository.getContentType() ) )
+ {
+ repositoryType = "default";
+ }
+ else
+ {
+ // this should be "simple"
+ repositoryType = localRepository.getContentType();
+ }
+ return repositoryType;
+ }
+
+ /**
+ * @param coordinate {@link ArtifactCoordinate}
+ * @return {@link Artifact}
+ */
+ private 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/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/AbstractArtifact.java b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/AbstractArtifact.java
new file mode 100644
index 0000000..1e48f78
--- /dev/null
+++ b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/AbstractArtifact.java
@@ -0,0 +1,188 @@
+package org.sonatype.aether.util.artifact;
+
+/*
+ * 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.
+ */
+
+/*
+ * Copyright (c) 2010 Sonatype, Inc. All rights reserved.
+ *
+ * This program is licensed to you under the Apache License Version 2.0,
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the Apache License Version 2.0 is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
+ */
+
+import org.sonatype.aether.artifact.Artifact;
+
+import java.io.File;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A skeleton class for artifacts that implements {@link Object#equals(Object)}, {@link Object#hashCode()} and
+ * {@link Object#toString()}.
+ *
+ * Note: this is a one-to-one copy of same class from org.sonatype.aether:aether-util:1.13.1 (used in Maven 3.0,5),
+ * as Maven 3.0.5 does NOT EXPORT aether util package to plugins.
+ *
+ * @author Benjamin Bentmann
+ */
+public abstract class AbstractArtifact
+ implements Artifact
+{
+
+ private static final String SNAPSHOT = "SNAPSHOT";
+
+ private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile( "^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$" );
+
+ protected static boolean isSnapshot( String version )
+ {
+ return version.endsWith( SNAPSHOT ) || SNAPSHOT_TIMESTAMP.matcher( version ).matches();
+ }
+
+ protected static String toBaseVersion( String version )
+ {
+ String baseVersion;
+
+ if ( version == null )
+ {
+ baseVersion = version;
+ }
+ else if ( version.startsWith( "[" ) || version.startsWith( "(" ) )
+ {
+ baseVersion = version;
+ }
+ else
+ {
+ Matcher m = SNAPSHOT_TIMESTAMP.matcher( version );
+ if ( m.matches() )
+ {
+ if ( m.group( 1 ) != null )
+ {
+ baseVersion = m.group( 1 ) + SNAPSHOT;
+ }
+ else
+ {
+ baseVersion = SNAPSHOT;
+ }
+ }
+ else
+ {
+ baseVersion = version;
+ }
+ }
+
+ return baseVersion;
+ }
+
+ public Artifact setVersion( String version )
+ {
+ if ( getVersion().equals( version ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, getFile(),
+ getProperties() );
+ }
+
+ public Artifact setFile( File file )
+ {
+ if ( eq( getFile(), file ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), getVersion(), file,
+ getProperties() );
+ }
+
+ public Artifact setProperties( Map<String, String> properties )
+ {
+ if ( getProperties().equals( properties ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), getVersion(),
+ properties, getFile() );
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder( 128 );
+ buffer.append( getGroupId() );
+ buffer.append( ':' ).append( getArtifactId() );
+ buffer.append( ':' ).append( getExtension() );
+ if ( getClassifier().length() > 0 )
+ {
+ buffer.append( ':' ).append( getClassifier() );
+ }
+ buffer.append( ':' ).append( getVersion() );
+ return buffer.toString();
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( obj == this )
+ {
+ return true;
+ }
+ else if ( !( obj instanceof Artifact ) )
+ {
+ return false;
+ }
+
+ Artifact that = (Artifact) obj;
+
+ return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
+ && getVersion().equals( that.getVersion() ) && getExtension().equals( that.getExtension() )
+ && getClassifier().equals( that.getClassifier() ) && eq( getFile(), that.getFile() )
+ && getProperties().equals( that.getProperties() );
+ }
+
+ private static <T> boolean eq( T s1, T s2 )
+ {
+ return s1 != null ? s1.equals( s2 ) : s2 == null;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = 17;
+ hash = hash * 31 + getGroupId().hashCode();
+ hash = hash * 31 + getArtifactId().hashCode();
+ hash = hash * 31 + getExtension().hashCode();
+ hash = hash * 31 + getClassifier().hashCode();
+ hash = hash * 31 + getVersion().hashCode();
+ hash = hash * 31 + getProperties().hashCode();
+ hash = hash * 31 + hash( getFile() );
+ return hash;
+ }
+
+ private static int hash( Object obj )
+ {
+ return ( obj != null ) ? obj.hashCode() : 0;
+ }
+
+}
diff --git a/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/DefaultArtifact.java b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/DefaultArtifact.java
new file mode 100644
index 0000000..fc02aff
--- /dev/null
+++ b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/DefaultArtifact.java
@@ -0,0 +1,360 @@
+package org.sonatype.aether.util.artifact;
+
+/*
+ * 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.
+ */
+
+/*
+ * Copyright (c) 2010 Sonatype, Inc. All rights reserved.
+ *
+ * This program is licensed to you under the Apache License Version 2.0,
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the Apache License Version 2.0 is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
+ */
+
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.artifact.ArtifactType;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A simple artifact.
+ *
+ * Note: this is a one-to-one copy of same class from org.sonatype.aether:aether-util:1.13.1 (used in Maven 3.0,5),
+ * as Maven 3.0.5 does NOT EXPORT aether util package to plugins.
+ *
+ * @author Benjamin Bentmann
+ */
+public final class DefaultArtifact
+ extends AbstractArtifact
+{
+
+ private final String groupId;
+
+ private final String artifactId;
+
+ private final String version;
+
+ private final String classifier;
+
+ private final String extension;
+
+ private final File file;
+
+ private final Map<String, String> properties;
+
+ private String baseVersion;
+
+ /**
+ * Creates a new artifact with the specified coordinates.
+ *
+ * @param coords The artifact coordinates in the format
+ * {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
+ */
+ public DefaultArtifact( String coords )
+ {
+ this( coords, Collections.<String, String>emptyMap() );
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates and properties.
+ *
+ * @param coords The artifact coordinates in the format
+ * {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
+ * @param properties The artifact properties, may be {@code null}.
+ */
+ public DefaultArtifact( String coords, Map<String, String> properties )
+ {
+ Pattern p = Pattern.compile( "([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)" );
+ Matcher m = p.matcher( coords );
+ if ( !m.matches() )
+ {
+ throw new IllegalArgumentException( "Bad artifact coordinates"
+ + ", expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>" );
+ }
+ groupId = m.group( 1 );
+ artifactId = m.group( 2 );
+ extension = get( m.group( 4 ), "jar" );
+ classifier = get( m.group( 6 ), "" );
+ version = m.group( 7 );
+ file = null;
+ if ( properties != null && !properties.isEmpty() )
+ {
+ this.properties = new HashMap<String, String>( properties );
+ }
+ else
+ {
+ this.properties = Collections.emptyMap();
+ }
+ }
+
+ private static String get( String value, String defaultValue )
+ {
+ return ( value == null || value.length() <= 0 ) ? defaultValue : value;
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates.
+ *
+ * @param groupId The group identifier of the artifact, may be {@code null}.
+ * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+ * @param extension The file extension of the artifact, may be {@code null}.
+ * @param version The version of the artifact, may be {@code null}.
+ */
+ public DefaultArtifact( String groupId, String artifactId, String extension, String version )
+ {
+ this( groupId, artifactId, "", extension, version );
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates.
+ *
+ * @param groupId The group identifier of the artifact, may be {@code null}.
+ * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+ * @param classifier The classifier of the artifact, may be {@code null}.
+ * @param extension The file extension of the artifact, may be {@code null}.
+ * @param version The version of the artifact, may be {@code null}.
+ */
+ public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version )
+ {
+ this( groupId, artifactId, classifier, extension, version, null, (File) null );
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates. The optional artifact type provided to this constructor
+ * will be used to determine the artifact's classifier and file extension if the corresponding arguments for this
+ * constructor are {@code null}.
+ *
+ * @param groupId The group identifier of the artifact, may be {@code null}.
+ * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+ * @param classifier The classifier of the artifact, may be {@code null}.
+ * @param extension The file extension of the artifact, may be {@code null}.
+ * @param version The version of the artifact, may be {@code null}.
+ * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
+ */
+ public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+ ArtifactType type )
+ {
+ this( groupId, artifactId, classifier, extension, version, null, type );
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates and properties. The optional artifact type provided to this
+ * constructor will be used to determine the artifact's classifier and file extension if the corresponding arguments
+ * for this constructor are {@code null}. If the artifact type specifies properties, those will get merged with the
+ * properties passed directly into the constructor, with the latter properties taking precedence.
+ *
+ * @param groupId The group identifier of the artifact, may be {@code null}.
+ * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+ * @param classifier The classifier of the artifact, may be {@code null}.
+ * @param extension The file extension of the artifact, may be {@code null}.
+ * @param version The version of the artifact, may be {@code null}.
+ * @param properties The properties of the artifact, may be {@code null}.
+ * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
+ */
+ public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+ Map<String, String> properties, ArtifactType type )
+ {
+ this.groupId = emptify( groupId );
+ this.artifactId = emptify( artifactId );
+ if ( classifier != null || type == null )
+ {
+ this.classifier = emptify( classifier );
+ }
+ else
+ {
+ this.classifier = emptify( type.getClassifier() );
+ }
+ if ( extension != null || type == null )
+ {
+ this.extension = emptify( extension );
+ }
+ else
+ {
+ this.extension = emptify( type.getExtension() );
+ }
+ this.version = emptify( version );
+ this.file = null;
+ this.properties = merge( properties, ( type != null ) ? type.getProperties() : null );
+ }
+
+ private static Map<String, String> merge( Map<String, String> dominant, Map<String, String> recessive )
+ {
+ Map<String, String> properties;
+
+ if ( ( dominant == null || dominant.isEmpty() ) && ( recessive == null || recessive.isEmpty() ) )
+ {
+ properties = Collections.emptyMap();
+ }
+ else
+ {
+ properties = new HashMap<String, String>();
+ if ( recessive != null )
+ {
+ properties.putAll( recessive );
+ }
+ if ( dominant != null )
+ {
+ properties.putAll( dominant );
+ }
+ }
+
+ return properties;
+ }
+
+ /**
+ * Creates a new artifact with the specified coordinates, properties and file.
+ *
+ * @param groupId The group identifier of the artifact, may be {@code null}.
+ * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+ * @param classifier The classifier of the artifact, may be {@code null}.
+ * @param extension The file extension of the artifact, may be {@code null}.
+ * @param version The version of the artifact, may be {@code null}.
+ * @param properties The properties of the artifact, may be {@code null}.
+ * @param file The resolved file of the artifact, may be {@code null}.
+ */
+ public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+ Map<String, String> properties, File file )
+ {
+ this.groupId = emptify( groupId );
+ this.artifactId = emptify( artifactId );
+ this.classifier = emptify( classifier );
+ this.extension = emptify( extension );
+ this.version = emptify( version );
+ this.file = file;
+ if ( properties != null && !properties.isEmpty() )
+ {
+ this.properties = new HashMap<String, String>( properties );
+ }
+ else
+ {
+ this.properties = Collections.emptyMap();
+ }
+ }
+
+ DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version, File file,
+ Map<String, String> properties )
+ {
+ // NOTE: This constructor assumes immutability of the provided properties, for internal use only
+ this.groupId = emptify( groupId );
+ this.artifactId = emptify( artifactId );
+ this.classifier = emptify( classifier );
+ this.extension = emptify( extension );
+ this.version = emptify( version );
+ this.file = file;
+ this.properties = properties;
+ }
+
+ private static String emptify( String str )
+ {
+ return ( str == null ) ? "" : str;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public String getBaseVersion()
+ {
+ if ( baseVersion == null )
+ {
+ baseVersion = toBaseVersion( getVersion() );
+ }
+ return baseVersion;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public Artifact setVersion( String version )
+ {
+ if ( this.version.equals( version ) || ( version == null && this.version.length() <= 0 ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( groupId, artifactId, classifier, extension, version, file, properties );
+ }
+
+ public boolean isSnapshot()
+ {
+ return isSnapshot( getVersion() );
+ }
+
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public Artifact setFile( File file )
+ {
+ if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( groupId, artifactId, classifier, extension, version, file, properties );
+ }
+
+ public String getProperty( String key, String defaultValue )
+ {
+ String value = properties.get( key );
+ return ( value != null ) ? value : defaultValue;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return Collections.unmodifiableMap( properties );
+ }
+
+ public Artifact setProperties( Map<String, String> properties )
+ {
+ if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) )
+ {
+ return this;
+ }
+ return new DefaultArtifact( groupId, artifactId, classifier, extension, version, properties, file );
+ }
+
+}
diff --git a/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/SubArtifact.java b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/SubArtifact.java
new file mode 100644
index 0000000..b70a5a7
--- /dev/null
+++ b/maven-3.0.x/src/main/java/org/sonatype/aether/util/artifact/SubArtifact.java
@@ -0,0 +1,203 @@
+package org.sonatype.aether.util.artifact;
+
+/*
+ * 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.
+ */
+
+/*
+ * Copyright (c) 2010 Sonatype, Inc. All rights reserved.
+ *
+ * This program is licensed to you under the Apache License Version 2.0,
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the Apache License Version 2.0 is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
+ */
+
+import org.sonatype.aether.artifact.Artifact;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * An artifact whose identity is derived from another artifact.
+ *
+ * Note: this is a one-to-one copy of same class from org.sonatype.aether:aether-util:1.13.1 (used in Maven 3.0,5),
+ * as Maven 3.0.5 does NOT EXPORT aether util package to plugins.
+ *
+ * @author Benjamin Bentmann
+ */
+public final class SubArtifact
+ extends AbstractArtifact
+{
+
+ private final Artifact mainArtifact;
+
+ private final String classifier;
+
+ private final String extension;
+
+ private final File file;
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+ * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+ * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+ * used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if none.
+ * @param extension The extension for this artifact, may be {@code null} if none.
+ */
+ public SubArtifact( Artifact mainArtifact, String classifier, String extension )
+ {
+ this( mainArtifact, classifier, extension, null );
+ }
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+ * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+ * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+ * used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if none.
+ * @param extension The extension for this artifact, may be {@code null} if none.
+ * @param file The file for this artifact, may be {@code null} if unresolved.
+ */
+ public SubArtifact( Artifact mainArtifact, String classifier, String extension, File file )
+ {
+ if ( mainArtifact == null )
+ {
+ throw new IllegalArgumentException( "no artifact specified" );
+ }
+ this.mainArtifact = mainArtifact;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.file = file;
+ }
+
+ public String getGroupId()
+ {
+ return mainArtifact.getGroupId();
+ }
+
+ public String getArtifactId()
+ {
+ return mainArtifact.getArtifactId();
+ }
+
+ public String getVersion()
+ {
+ return mainArtifact.getVersion();
+ }
+
+ public Artifact setVersion( String version )
+ {
+ return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, getFile(),
+ getProperties() );
+ }
+
+ public String getBaseVersion()
+ {
+ return mainArtifact.getBaseVersion();
+ }
+
+ public boolean isSnapshot()
+ {
+ return mainArtifact.isSnapshot();
+ }
+
+ public String getClassifier()
+ {
+ return expand( classifier, mainArtifact.getClassifier() );
+ }
+
+ public String getExtension()
+ {
+ return expand( extension, mainArtifact.getExtension() );
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public Artifact setFile( File file )
+ {
+ if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
+ {
+ return this;
+ }
+ return new SubArtifact( mainArtifact, classifier, extension, file );
+ }
+
+ public String getProperty( String key, String defaultValue )
+ {
+ return mainArtifact.getProperty( key, defaultValue );
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return mainArtifact.getProperties();
+ }
+
+ private static String expand( String pattern, String replacement )
+ {
+ String result = "";
+ if ( pattern != null )
+ {
+ result = pattern.replace( "*", replacement );
+
+ if ( replacement.length() <= 0 )
+ {
+ if ( pattern.startsWith( "*" ) )
+ {
+ int i = 0;
+ for ( ; i < result.length(); i++ )
+ {
+ char c = result.charAt( i );
+ if ( c != '-' && c != '.' )
+ {
+ break;
+ }
+ }
+ result = result.substring( i );
+ }
+ if ( pattern.endsWith( "*" ) )
+ {
+ int i = result.length() - 1;
+ for ( ; i >= 0; i-- )
+ {
+ char c = result.charAt( i );
+ if ( c != '-' && c != '.' )
+ {
+ break;
+ }
+ }
+ result = result.substring( 0, i + 1 );
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java b/maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
similarity index 88%
rename from src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
rename to maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
index 19d1939..61ef91f 100644
--- a/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
+++ b/maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven30ArtifactInstallerTest.java
@@ -28,7 +28,8 @@ 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.apache.maven.shared.transfer.repository.RepositoryManager;
+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.SimpleLocalRepositoryManager;
@@ -52,6 +53,8 @@ public class Maven30ArtifactInstallerTest extends PlexusTestCase
MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
buildingRequest.setRepositorySession( repositorySession );
+
+ RepositoryManager repositoryManager = new Maven30RepositoryManager( repositorySystem );
DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler();
artifactHandler.setExtension( "EXTENSION" );
@@ -67,8 +70,8 @@ public class Maven30ArtifactInstallerTest extends PlexusTestCase
Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier );
- MavenArtifactInstaller installer = new Maven30ArtifactInstaller( repositorySystem, repositorySession );
- installer.install( mavenArtifacts );
+ ArtifactInstallerDelegate installer = new Maven30ArtifactInstaller( repositorySystem, repositoryManager );
+ installer.install( buildingRequest, mavenArtifacts );
assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() );
assertTrue( new File( localRepo, "GROUPID/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() );
diff --git a/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java b/maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
similarity index 91%
rename from src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
rename to maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
index 6e20cb4..ce900c8 100644
--- a/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
+++ b/maven-3.0.x/src/test/java/org/apache/maven/shared/transfer/repository/internal/Maven30RepositoryManagerTest.java
@@ -24,7 +24,6 @@ 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;
@@ -32,7 +31,6 @@ 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;
@@ -43,7 +41,7 @@ public class Maven30RepositoryManagerTest extends PlexusTestCase
super.setUp();
repositorySystem = lookup( RepositorySystem.class );
}
-
+
public void testSetLocalRepositoryBasedirSimple()
{
DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
@@ -54,12 +52,11 @@ public class Maven30RepositoryManagerTest extends PlexusTestCase
File basedir = new File( "NEW/LOCAL/REPO" );
Maven30RepositoryManager repositoryManager =
- new Maven30RepositoryManager( repositorySystem, buildingRequest.getRepositorySession() );
+ new Maven30RepositoryManager( repositorySystem );
ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir );
assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() );
-
}
public void testSetLocalRepositoryBasedirEnhanced()
@@ -72,12 +69,10 @@ public class Maven30RepositoryManagerTest extends PlexusTestCase
File basedir = new File( "NEW/LOCAL/REPO" );
Maven30RepositoryManager repositoryManager =
- new Maven30RepositoryManager( repositorySystem, buildingRequest.getRepositorySession() );
+ new Maven30RepositoryManager( repositorySystem );
ProjectBuildingRequest newBuildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, basedir );
assertEquals( basedir.getAbsoluteFile(), newBuildingRequest.getRepositorySession().getLocalRepository().getBasedir() );
-
}
-
}
diff --git a/maven-3.1.x/pom.xml b/maven-3.1.x/pom.xml
new file mode 100644
index 0000000..911076b
--- /dev/null
+++ b/maven-3.1.x/pom.xml
@@ -0,0 +1,151 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-artifact-transfer-maven-3.1.x</artifactId>
+
+ <name>Apache Maven Artifact Transfer Maven 3.1.x provider</name>
+
+ <!-- This module uses CP of Maven 3.1.x -->
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven31x.version}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-plexus</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven31x.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven31x.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.inject</artifactId>
+ <version>${maven31xEclipseSisu.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <version>${maven31xEclipseSisu.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${maven31xEclipseAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ <version>${maven31xEclipseAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-impl</artifactId>
+ <version>${maven31xEclipseAether.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- TEST -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java
similarity index 73%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java
index ed61b12..23b8d29 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/Maven31ArtifactDeployer.java
@@ -19,15 +19,16 @@ package org.apache.maven.shared.transfer.artifact.deploy.internal;
* 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.ProjectBuildingRequest;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
import org.apache.maven.shared.transfer.metadata.internal.Maven31MetadataBridge;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
@@ -36,32 +37,42 @@ import org.eclipse.aether.deployment.DeploymentException;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.artifact.SubArtifact;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.Collection;
+import java.util.Objects;
+
/**
*
*/
-class Maven31ArtifactDeployer implements MavenArtifactDeployer
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31ArtifactDeployer
+ extends DelegateSupport
+ implements ArtifactDeployerDelegate
{
-
private final RepositorySystem repositorySystem;
- private final RepositorySystemSession session;
-
- Maven31ArtifactDeployer( RepositorySystem repositorySystem, RepositorySystemSession session )
+ @Inject
+ public Maven31ArtifactDeployer( RepositorySystem repositorySystem )
{
- super();
- this.repositorySystem = repositorySystem;
- this.session = session;
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
}
@Override
- public void deploy( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts ) throws ArtifactDeployerException
+ public void deploy( ProjectBuildingRequest buildingRequest,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactDeployerException
{
- deploy( null, mavenArtifacts );
+ deploy( buildingRequest, null, mavenArtifacts );
}
@Override
- public void deploy( ArtifactRepository remoteRepository,
- Collection<org.apache.maven.artifact.Artifact> mavenArtifacts ) throws ArtifactDeployerException
+ public void deploy( ProjectBuildingRequest buildingRequest,
+ ArtifactRepository remoteRepository,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactDeployerException
{
// prepare request
DeployRequest request = new DeployRequest();
@@ -70,20 +81,20 @@ class Maven31ArtifactDeployer implements MavenArtifactDeployer
if ( remoteRepository != null )
{
- defaultRepository = getRemoteRepository( session, remoteRepository );
+ defaultRepository = getRemoteRepository( buildingRequest.getRepositorySession(), 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 );
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
request.addArtifact( aetherArtifact );
RemoteRepository aetherRepository;
if ( remoteRepository == null )
{
- aetherRepository = getRemoteRepository( session, mavenArtifact.getRepository() );
+ aetherRepository = getRemoteRepository( buildingRequest.getRepositorySession(),
+ mavenArtifact.getRepository() );
}
else
{
@@ -118,7 +129,7 @@ class Maven31ArtifactDeployer implements MavenArtifactDeployer
// deploy
try
{
- repositorySystem.deploy( session, request );
+ repositorySystem.deploy( buildingRequest.getRepositorySession(), request );
}
catch ( DeploymentException e )
{
@@ -126,11 +137,10 @@ class Maven31ArtifactDeployer implements MavenArtifactDeployer
}
}
- private RemoteRepository getRemoteRepository( RepositorySystemSession session, ArtifactRepository remoteRepository )
- throws ArtifactDeployerException
+ private RemoteRepository getRemoteRepository( RepositorySystemSession session,
+ ArtifactRepository remoteRepository )
{
- RemoteRepository aetherRepo = Invoker.invoke( RepositoryUtils.class, "toRepo", ArtifactRepository.class,
- remoteRepository );
+ RemoteRepository aetherRepo = RepositoryUtils.toRepo( remoteRepository );
if ( aetherRepo.getAuthentication() == null || aetherRepo.getProxy() == null )
{
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java
similarity index 60%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java
index aa15504..2d93469 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/Maven31ArtifactInstaller.java
@@ -19,50 +19,77 @@ package org.apache.maven.shared.transfer.artifact.install.internal;
* 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.ProjectBuildingRequest;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
import org.apache.maven.shared.transfer.metadata.internal.Maven31MetadataBridge;
+import org.apache.maven.shared.transfer.repository.RepositoryManager;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.installation.InstallRequest;
import org.eclipse.aether.installation.InstallationException;
import org.eclipse.aether.util.artifact.SubArtifact;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.util.Collection;
+import java.util.Objects;
+
/**
- *
+ *
*/
-class Maven31ArtifactInstaller
- implements MavenArtifactInstaller
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31ArtifactInstaller
+ extends DelegateSupport
+ implements ArtifactInstallerDelegate
{
private final RepositorySystem repositorySystem;
- private final RepositorySystemSession session;
-
- Maven31ArtifactInstaller( RepositorySystem repositorySystem,
- RepositorySystemSession session )
+ private final RepositoryManager repositoryManager;
+
+ @Inject
+ public Maven31ArtifactInstaller( RepositorySystem repositorySystem,
+ RepositoryManager repositoryManager )
{
- this.repositorySystem = repositorySystem;
- this.session = session;
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.repositoryManager = Objects.requireNonNull( repositoryManager );
}
@Override
- public void install( Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
- throws ArtifactInstallerException
+ public void install( ProjectBuildingRequest request,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactInstallerException
{
+ install( request, null, mavenArtifacts );
+ }
+
+ @Override
+ public void install( ProjectBuildingRequest buildingRequest,
+ File localRepository,
+ Collection<org.apache.maven.artifact.Artifact> mavenArtifacts )
+ throws ArtifactInstallerException
+ {
+ ProjectBuildingRequest currentRequest = buildingRequest;
+ if ( localRepository != null )
+ {
+ currentRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepository );
+ }
+
// 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 );
+ Artifact mainArtifact = RepositoryUtils.toArtifact( mavenArtifact );
request.addArtifact( mainArtifact );
for ( ArtifactMetadata metadata : mavenArtifact.getMetadataList() )
@@ -74,24 +101,24 @@ class Maven31ArtifactInstaller
request.addArtifact( pomArtifact );
}
else if ( // metadata instanceof SnapshotArtifactRepositoryMetadata ||
- metadata instanceof ArtifactRepositoryMetadata )
+ 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 transferMetadata =
- (org.apache.maven.shared.transfer.metadata.ArtifactMetadata) metadata;
-
+ org.apache.maven.shared.transfer.metadata.ArtifactMetadata transferMetadata =
+ (org.apache.maven.shared.transfer.metadata.ArtifactMetadata) metadata;
+
request.addMetadata( new Maven31MetadataBridge( metadata ).setFile( transferMetadata.getFile() ) );
}
}
}
-
+
// install
try
{
- repositorySystem.install( session, request );
+ repositorySystem.install( currentRequest.getRepositorySession(), request );
}
catch ( InstallationException e )
{
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java
similarity index 52%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java
index 9ef5658..0bea944 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResolver.java
@@ -19,87 +19,87 @@ package org.apache.maven.shared.transfer.artifact.resolve.internal;
* under the License.
*/
-import java.util.List;
-
import org.apache.maven.RepositoryUtils;
+import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactDescriptorException;
import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
import org.eclipse.aether.resolution.ArtifactDescriptorResult;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.Objects;
+
/**
- *
+ *
*/
-class Maven31ArtifactResolver
- implements MavenArtifactResolver
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31ArtifactResolver
+ extends DelegateSupport
+ implements ArtifactResolverDelegate
{
private final RepositorySystem repositorySystem;
-
- private final List<RemoteRepository> aetherRepositories;
-
- private final RepositorySystemSession session;
- Maven31ArtifactResolver( RepositorySystem repositorySystem, List<RemoteRepository> aetherRepositories,
- RepositorySystemSession session )
+ @Inject
+ public Maven31ArtifactResolver( RepositorySystem repositorySystem )
{
- this.repositorySystem = repositorySystem;
- this.aetherRepositories = aetherRepositories;
- this.session = session;
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
}
@Override
public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
org.apache.maven.artifact.Artifact mavenArtifact ) throws ArtifactResolverException
{
- Artifact aetherArtifact = Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.apache.maven.artifact.Artifact.class, mavenArtifact );
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
- return resolveArtifact( aetherArtifact );
+ return resolveArtifact( buildingRequest, aetherArtifact );
}
@Override
- // CHECKSTYLE_OFF: LineLength
- public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact( ArtifactCoordinate coordinate )
- throws ArtifactResolverException
- // CHECKSTYLE_ON: LineLength
+ public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
+ ArtifactCoordinate coordinate ) throws ArtifactResolverException
{
- Artifact aetherArtifact =
- new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
- coordinate.getExtension(), coordinate.getVersion() );
+ Artifact aetherArtifact = new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(),
+ coordinate.getClassifier(), coordinate.getExtension(), coordinate.getVersion() );
- return resolveArtifact( aetherArtifact );
+ return resolveArtifact( buildingRequest, aetherArtifact );
}
- // CHECKSTYLE_OFF: LineLength
- private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact( Artifact aetherArtifact )
- throws ArtifactResolverException
- // CHECKSTYLE_ON: LineLength
+ private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult resolveArtifact(
+ ProjectBuildingRequest buildingRequest,
+ Artifact aetherArtifact ) throws ArtifactResolverException
{
try
{
// use descriptor to respect relocation
- ArtifactDescriptorRequest descriptorRequest =
- new ArtifactDescriptorRequest( aetherArtifact, aetherRepositories, null );
+ ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest( aetherArtifact,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ), null );
- ArtifactDescriptorResult descriptorResult =
- repositorySystem.readArtifactDescriptor( session, descriptorRequest );
+ ArtifactDescriptorResult descriptorResult = repositorySystem.readArtifactDescriptor(
+ buildingRequest.getRepositorySession(),
+ descriptorRequest );
- ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(), aetherRepositories, null );
+ ArtifactRequest request = new ArtifactRequest( descriptorResult.getArtifact(),
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ), null );
- return new Maven31ArtifactResult( repositorySystem.resolveArtifact( session, request ) );
+ return new Maven31ArtifactResult(
+ repositorySystem.resolveArtifact( buildingRequest.getRepositorySession(), 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/Maven31ArtifactResult.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResult.java
similarity index 75%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResult.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResult.java
index 7b56826..3367c2b 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResult.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/Maven31ArtifactResult.java
@@ -1,59 +1,49 @@
-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.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
- *
- * @author Robert Scholte
- * @since 3.0
- */
-class Maven31ArtifactResult
- implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
-{
- private final ArtifactResult artifactResult;
-
- /**
- * @param artifactResult {@link ArtifactResult}
- */
- Maven31ArtifactResult( 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 );
- }
- }
-}
+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.eclipse.aether.resolution.ArtifactResult;
+
+/**
+ * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
+ *
+ * @author Robert Scholte
+ * @since 3.0
+ */
+class Maven31ArtifactResult
+ implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
+{
+ private final ArtifactResult artifactResult;
+
+ /**
+ * @param artifactResult {@link ArtifactResult}
+ */
+ Maven31ArtifactResult( ArtifactResult artifactResult )
+ {
+ this.artifactResult = artifactResult;
+ }
+
+ @Override
+ public org.apache.maven.artifact.Artifact getArtifact()
+ {
+ return RepositoryUtils.toArtifact( artifactResult.getArtifact() );
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
index d53a452..27461cc 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31ArtifactRepositoryAdapter.java
@@ -207,6 +207,18 @@ class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
}
@Override
+ public List<ArtifactRepository> getMirroredRepositories()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31CollectResult.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31CollectResult.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31CollectResult.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31CollectResult.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java
similarity index 59%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java
index 43846ab..3faa291 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyCollector.java
@@ -19,102 +19,99 @@ package org.apache.maven.shared.transfer.collection.internal;
* 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.project.ProjectBuildingRequest;
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.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.repository.RemoteRepository;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
/**
- * Maven 3.1+ implementation of the {@link DependencyCollector}
- *
- * @author Robert Scholte
*
*/
-class Maven31DependencyCollector
- implements MavenDependencyCollector
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31DependencyCollector
+ extends DelegateSupport
+ implements DependencyCollectorDelegate
{
private final RepositorySystem repositorySystem;
private final ArtifactHandlerManager artifactHandlerManager;
-
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> aetherRepositories;
-
- Maven31DependencyCollector( RepositorySystem repositorySystem, ArtifactHandlerManager artifactHandlerManager,
- RepositorySystemSession session, List<RemoteRepository> aetherRepositories )
+
+ @Inject
+ public Maven31DependencyCollector( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
{
- super();
- this.repositorySystem = repositorySystem;
- this.artifactHandlerManager = artifactHandlerManager;
- this.session = session;
- this.aetherRepositories = aetherRepositories;
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
}
@Override
- public CollectResult collectDependencies( org.apache.maven.model.Dependency root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.model.Dependency root )
+ throws DependencyCollectionException
{
- ArtifactTypeRegistry typeRegistry = Invoker
- .invoke( RepositoryUtils.class, "newArtifactTypeRegistry",
- ArtifactHandlerManager.class, artifactHandlerManager );
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
CollectRequest request = new CollectRequest();
request.setRoot( toDependency( root, typeRegistry ) );
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
@Override
- public CollectResult collectDependencies( DependableCoordinate root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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() );
+ extension, root.getVersion() );
CollectRequest request = new CollectRequest();
request.setRoot( new Dependency( aetherArtifact, null ) );
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
@Override
- public CollectResult collectDependencies( Model root )
- throws DependencyCollectionException
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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() );
+ 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 );
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
List<Dependency> aetherDependencies = new ArrayList<>( root.getDependencies().size() );
for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencies() )
@@ -136,17 +133,20 @@ class Maven31DependencyCollector
request.setManagedDependencies( aetherManagerDependencies );
}
- return collectDependencies( request );
+ return collectDependencies( buildingRequest, request );
}
- private CollectResult collectDependencies( CollectRequest request )
- throws DependencyCollectionException
+ private CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ CollectRequest request )
+ throws DependencyCollectionException
{
- request.setRepositories( aetherRepositories );
+ request.setRepositories( RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
try
{
- return new Maven31CollectResult( repositorySystem.collectDependencies( session, request ) );
+ return new Maven31CollectResult(
+ repositorySystem.collectDependencies( buildingRequest.getRepositorySession(), request )
+ );
}
catch ( org.eclipse.aether.collection.DependencyCollectionException e )
{
@@ -154,15 +154,9 @@ class Maven31DependencyCollector
}
}
- private static Dependency toDependency( org.apache.maven.model.Dependency root, ArtifactTypeRegistry typeRegistry )
- throws DependencyCollectionException
+ private static Dependency toDependency( org.apache.maven.model.Dependency root,
+ ArtifactTypeRegistry typeRegistry )
{
- Class<?>[] argClasses = new Class<?>[] { org.apache.maven.model.Dependency.class, ArtifactTypeRegistry.class };
-
- Object[] args = new Object[] { root, typeRegistry };
-
- return Invoker
- .invoke( RepositoryUtils.class, "toDependency", argClasses, args );
+ return RepositoryUtils.toDependency( root, typeRegistry );
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java
similarity index 92%
rename from src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java
index eae1542..87c1dfe 100644
--- a/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/collection/internal/Maven31DependencyNodeAdapter.java
@@ -25,7 +25,6 @@ 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.eclipse.aether.repository.RemoteRepository;
@@ -150,14 +149,6 @@ class Maven31DependencyNodeAdapter implements DependencyNode
private Artifact getArtifact( org.eclipse.aether.artifact.Artifact aetherArtifact )
{
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.eclipse.aether.artifact.Artifact.class, aetherArtifact );
- }
- catch ( DependencyCollectionException e )
- {
- throw new RuntimeException( e );
- }
+ return RepositoryUtils.toArtifact( aetherArtifact );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
index 854cf4a..6f40e09 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31ArtifactRepositoryAdapter.java
@@ -1,266 +1,278 @@
-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.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-
-/**
- * ArtifactRepository wrapper around {@link RemoteRepository}
- *
- * @author Robert Scholte
- *
- */
-class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
-{
-
- private RemoteRepository remoteRepository;
-
- /**
- * @param remoteRepository {@link RemoteRepository}
- */
- Maven31ArtifactRepositoryAdapter( 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;
- }
-
- Maven31ArtifactRepositoryAdapter other = (Maven31ArtifactRepositoryAdapter) obj;
- if ( remoteRepository == null )
- {
- if ( other.remoteRepository != null )
- {
- return false;
- }
- }
- else if ( !remoteRepository.equals( other.remoteRepository ) )
- {
- return false;
- }
- return true;
- }
-}
+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.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.RepositoryPolicy;
+
+/**
+ * ArtifactRepository wrapper around {@link RemoteRepository}
+ *
+ * @author Robert Scholte
+ *
+ */
+class Maven31ArtifactRepositoryAdapter implements ArtifactRepository
+{
+
+ private RemoteRepository remoteRepository;
+
+ /**
+ * @param remoteRepository {@link RemoteRepository}
+ */
+ Maven31ArtifactRepositoryAdapter( 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 List<ArtifactRepository> getMirroredRepositories()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setMirroredRepositories( List<ArtifactRepository> mirroredRepositories )
+ {
+ 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;
+ }
+
+ Maven31ArtifactRepositoryAdapter other = (Maven31ArtifactRepositoryAdapter) 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/Maven31CollectorResult.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
index dbf8717..c1a4e6f 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
@@ -1,85 +1,85 @@
-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.eclipse.aether.collection.CollectResult;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.graph.DependencyVisitor;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * CollectorResult wrapper around {@link CollectResult}
- *
- * @author Robert Scholte
- *
- */
-class Maven31CollectorResult implements CollectorResult
-{
- private final CollectResult collectResult;
-
- /**
- * @param collectResult {@link CollectorResult}
- */
- Maven31CollectorResult( 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 Maven31ArtifactRepositoryAdapter( aetherRepository ) );
- }
-
- return mavenRepositories;
- }
-
-}
+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.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.graph.DependencyVisitor;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * CollectorResult wrapper around {@link CollectResult}
+ *
+ * @author Robert Scholte
+ *
+ */
+class Maven31CollectorResult implements CollectorResult
+{
+ private final CollectResult collectResult;
+
+ /**
+ * @param collectResult {@link CollectorResult}
+ */
+ Maven31CollectorResult( 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 Maven31ArtifactRepositoryAdapter( aetherRepository ) );
+ }
+
+ return mavenRepositories;
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
similarity index 64%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
index 50f3700..eaa48dd 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
@@ -1,160 +1,163 @@
-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.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.collection.DependencyCollectionException;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Maven 3.1+ implementation of the {@link DependencyCollector}
- *
- * @author Robert Scholte
- */
-class Maven31DependencyCollector implements MavenDependencyCollector
-{
- private final RepositorySystem repositorySystem;
-
- private final ArtifactHandlerManager artifactHandlerManager;
-
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> aetherRepositories;
-
- Maven31DependencyCollector( 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 Maven31CollectorResult( repositorySystem.collectDependencies( session, request ) );
- }
- catch ( DependencyCollectionException e )
- {
- throw new DependencyCollectorException( e.getMessage(), e );
- }
- }
-}
+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 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.project.ProjectBuildingRequest;
+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.DependencyCollectorException;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.DependencyCollectionException;
+import org.eclipse.aether.graph.Dependency;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ *
+ */
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31DependencyCollector
+ extends DelegateSupport
+ implements DependencyCollectorDelegate
+{
+ private final RepositorySystem repositorySystem;
+
+ private final ArtifactHandlerManager artifactHandlerManager;
+
+ @Inject
+ public Maven31DependencyCollector( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
+ }
+
+ private static Dependency toDependency( org.apache.maven.model.Dependency mavenDependency,
+ ArtifactTypeRegistry typeRegistry )
+ {
+ return RepositoryUtils.toDependency( mavenDependency, typeRegistry );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.model.Dependency root )
+ throws DependencyCollectorException
+ {
+ ArtifactTypeRegistry typeRegistry = RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
+
+ CollectRequest request = new CollectRequest();
+ request.setRoot( toDependency( root, typeRegistry ) );
+
+ return collectDependencies( buildingRequest, request );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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( buildingRequest, request );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ 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 = RepositoryUtils.newArtifactTypeRegistry( 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( buildingRequest, request );
+ }
+
+ private CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ CollectRequest request )
+ throws DependencyCollectorException
+ {
+ request.setRepositories( RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ try
+ {
+ return new Maven31CollectorResult(
+ repositorySystem.collectDependencies( buildingRequest.getRepositorySession(), request )
+ );
+ }
+ catch ( DependencyCollectionException e )
+ {
+ throw new DependencyCollectorException( e.getMessage(), e );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java
similarity index 92%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java
index f0cccc4..2a7908c 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyNodeAdapter.java
@@ -25,7 +25,6 @@ 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.eclipse.aether.repository.RemoteRepository;
@@ -150,14 +149,6 @@ class Maven31DependencyNodeAdapter implements DependencyNode
private Artifact getArtifact( org.eclipse.aether.artifact.Artifact aetherArtifact )
{
- try
- {
- return Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.eclipse.aether.artifact.Artifact.class, aetherArtifact );
- }
- catch ( DependencyCollectorException e )
- {
- throw new RuntimeException( e );
- }
+ return RepositoryUtils.toArtifact( aetherArtifact );
}
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java
similarity index 74%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java
index fe26ce4..b040504 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31ArtifactResult.java
@@ -1,59 +1,49 @@
-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.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
- *
- * @author Robert Scholte
- * @since 3.0
- */
-class Maven31ArtifactResult
- implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
-{
- private final ArtifactResult artifactResult;
-
- /**
- * @param artifactResult {@link ArtifactResult}
- */
- Maven31ArtifactResult( 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 );
- }
- }
-}
+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.eclipse.aether.resolution.ArtifactResult;
+
+/**
+ * {@link org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult} wrapper for {@link ArtifactResult}
+ *
+ * @author Robert Scholte
+ * @since 3.0
+ */
+class Maven31ArtifactResult
+ implements org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult
+{
+ private final ArtifactResult artifactResult;
+
+ /**
+ * @param artifactResult {@link ArtifactResult}
+ */
+ Maven31ArtifactResult( ArtifactResult artifactResult )
+ {
+ this.artifactResult = artifactResult;
+ }
+
+ @Override
+ public org.apache.maven.artifact.Artifact getArtifact()
+ {
+ return RepositoryUtils.toArtifact( artifactResult.getArtifact() );
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java
similarity index 70%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java
index ea35bc5..d657092 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolver.java
@@ -1,243 +1,237 @@
-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.EclipseAetherFilterTransformer;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.ArtifactType;
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.artifact.DefaultArtifactType;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.DependencyFilter;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.resolution.DependencyRequest;
-import org.eclipse.aether.resolution.DependencyResolutionException;
-import org.eclipse.aether.resolution.DependencyResult;
-
-/**
- *
- */
-class Maven31DependencyResolver 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;
-
- Maven31DependencyResolver( 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 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 root, ArtifactTypeRegistry typeRegistry )
- throws DependencyResolverException
- {
- Object[] args = new Object[] {root, 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( model.getDependencyManagement().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> aetherDeps = resolveDependencies( mavenDependencies );
-
- List<Dependency> aetherManagedDependencies = resolveDependencies( managedMavenDependencies );
-
- CollectRequest request = new CollectRequest( aetherDeps, 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 EclipseAetherFilterTransformer() );
- }
-
- DependencyRequest depRequest = new DependencyRequest( request, depFilter );
-
- final DependencyResult dependencyResults = repositorySystem.resolveDependencies( session, depRequest );
-
- // 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.getArtifactResults().size() );
- // CHECKSTYLE_ON: LineLength
-
- for ( ArtifactResult artifactResult : dependencyResults.getArtifactResults() )
- {
- artResults.add( new Maven31ArtifactResult( artifactResult ) );
- }
-
- return artResults.iterator();
- }
- };
- }
- catch ( DependencyResolutionException e )
- {
- throw new Maven31DependencyResolverException( e );
- }
- }
-}
+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.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.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
+import org.apache.maven.shared.artifact.filter.resolve.transform.EclipseAetherFilterTransformer;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+import org.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactType;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.DefaultArtifactType;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.resolution.DependencyResult;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ *
+ */
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31DependencyResolver
+ extends DelegateSupport
+ implements DependencyResolverDelegate
+{
+ private final RepositorySystem repositorySystem;
+
+ private final ArtifactHandlerManager artifactHandlerManager;
+
+ @Inject
+ public Maven31DependencyResolver( RepositorySystem repositorySystem,
+ ArtifactHandlerManager artifactHandlerManager )
+ {
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
+ this.artifactHandlerManager = Objects.requireNonNull( artifactHandlerManager );
+ }
+
+ /**
+ * Based on RepositoryUtils#toDependency(org.apache.maven.model.Dependency, ArtifactTypeRegistry)
+ *
+ * @param coordinate {@link DependableCoordinate}
+ * @param stereotypes {@link 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 root, ArtifactTypeRegistry typeRegistry )
+ {
+ return RepositoryUtils.toDependency( root, typeRegistry );
+ }
+
+ @Override
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ DependableCoordinate coordinate,
+ TransformableFilter dependencyFilter ) throws DependencyResolverException
+ {
+ ArtifactTypeRegistry typeRegistry = createTypeRegistry();
+
+ Dependency aetherRoot = toDependency( coordinate, typeRegistry );
+
+ CollectRequest request = new CollectRequest( aetherRoot,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ return resolveDependencies( buildingRequest, dependencyFilter, request );
+ }
+
+ private ArtifactTypeRegistry createTypeRegistry()
+ {
+ return RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
+ }
+
+ @Override
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ Model model,
+ TransformableFilter dependencyFilter ) 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,
+ RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ request.setDependencies( resolveDependencies( model.getDependencies() ) );
+
+ DependencyManagement mavenDependencyManagement = model.getDependencyManagement();
+ if ( mavenDependencyManagement != null )
+ {
+ request.setManagedDependencies( resolveDependencies( model.getDependencyManagement().getDependencies() ) );
+ }
+
+ return resolveDependencies( buildingRequest, dependencyFilter, request );
+ }
+
+ /**
+ * @param mavenDependencies {@link org.apache.maven.model.Dependency} can be {@code null}.
+ * @return List of resolved dependencies.
+ */
+ private List<Dependency> resolveDependencies( Collection<org.apache.maven.model.Dependency> mavenDependencies )
+ {
+ 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
+ public Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ Collection<org.apache.maven.model.Dependency> mavenDependencies,
+ Collection<org.apache.maven.model.Dependency> managedMavenDependencies,
+ TransformableFilter filter ) throws DependencyResolverException
+ {
+ List<Dependency> aetherDeps = resolveDependencies( mavenDependencies );
+
+ List<Dependency> aetherManagedDependencies = resolveDependencies( managedMavenDependencies );
+
+ CollectRequest request = new CollectRequest( aetherDeps,
+ aetherManagedDependencies, RepositoryUtils.toRepos( buildingRequest.getRemoteRepositories() ) );
+
+ return resolveDependencies( buildingRequest, filter, request );
+ }
+
+ private Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> resolveDependencies(
+ ProjectBuildingRequest buildingRequest,
+ TransformableFilter dependencyFilter,
+ CollectRequest request ) throws DependencyResolverException
+ {
+ try
+ {
+ DependencyFilter depFilter = null;
+ if ( dependencyFilter != null )
+ {
+ depFilter = dependencyFilter.transform( new EclipseAetherFilterTransformer() );
+ }
+
+ DependencyRequest depRequest = new DependencyRequest( request, depFilter );
+
+ final DependencyResult dependencyResults = repositorySystem.resolveDependencies(
+ buildingRequest.getRepositorySession(), depRequest );
+
+ // 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()
+ {
+ Collection<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> artResults =
+ new ArrayList<>( dependencyResults.getArtifactResults().size() );
+
+ for ( ArtifactResult artifactResult : dependencyResults.getArtifactResults() )
+ {
+ artResults.add( new Maven31ArtifactResult( artifactResult ) );
+ }
+
+ return artResults.iterator();
+ }
+ };
+ }
+ catch ( DependencyResolutionException e )
+ {
+ throw new Maven31DependencyResolverException( e );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java
index c892033..ef6185d 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/internal/Maven31DependencyResolverException.java
@@ -1,55 +1,55 @@
-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.eclipse.aether.resolution.DependencyResolutionException;
-
-/**
- *
- * @author Robert Scholte
- *
- */
-class Maven31DependencyResolverException extends DependencyResolverException
-{
- private DependencyResolutionException e;
-
- Maven31DependencyResolverException( DependencyResolutionException e )
- {
- super( e );
- this.e = e;
- }
-
- @Override
- public DependencyResult getResult()
- {
- return new DependencyResult()
- {
- @Override
- public List<Exception> getCollectorExceptions()
- {
- return e.getResult().getCollectExceptions();
- }
- };
- }
-}
+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.eclipse.aether.resolution.DependencyResolutionException;
+
+/**
+ *
+ * @author Robert Scholte
+ *
+ */
+class Maven31DependencyResolverException extends DependencyResolverException
+{
+ private DependencyResolutionException e;
+
+ Maven31DependencyResolverException( DependencyResolutionException e )
+ {
+ super( e );
+ this.e = e;
+ }
+
+ @Override
+ public DependencyResult getResult()
+ {
+ return new DependencyResult()
+ {
+ @Override
+ public List<Exception> getCollectorExceptions()
+ {
+ return e.getResult().getCollectExceptions();
+ }
+ };
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven31MetadataBridge.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven31MetadataBridge.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven31MetadataBridge.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/metadata/internal/Maven31MetadataBridge.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
similarity index 56%
rename from src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
rename to maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
index 6f486a0..281a50e 100644
--- a/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
+++ b/maven-3.1.x/src/main/java/org/apache/maven/shared/transfer/repository/internal/Maven31RepositoryManager.java
@@ -19,14 +19,13 @@ package org.apache.maven.shared.transfer.repository.internal;
* 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.apache.maven.shared.transfer.support.DelegateSupport;
+import org.apache.maven.shared.transfer.support.Selector;
import org.eclipse.aether.DefaultRepositoryCache;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
@@ -39,76 +38,71 @@ import org.eclipse.aether.metadata.Metadata.Nature;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.util.Objects;
+
/**
- *
+ *
*/
-class Maven31RepositoryManager
- implements MavenRepositoryManager
+@Singleton
+@Named( Selector.MAVEN_3_1_X )
+public class Maven31RepositoryManager
+ extends DelegateSupport
+ implements RepositoryManagerDelegate
{
private final RepositorySystem repositorySystem;
- private final RepositorySystemSession session;
-
- Maven31RepositoryManager( RepositorySystem repositorySystem,
- RepositorySystemSession session )
+ @Inject
+ public Maven31RepositoryManager( RepositorySystem repositorySystem )
{
- this.repositorySystem = repositorySystem;
- this.session = session;
+ this.repositorySystem = Objects.requireNonNull( repositorySystem );
}
@Override
- public String getPathForLocalArtifact( org.apache.maven.artifact.Artifact mavenArtifact )
+ public String getPathForLocalArtifact( ProjectBuildingRequest buildingRequest,
+ org.apache.maven.artifact.Artifact mavenArtifact )
{
- Artifact aetherArtifact;
+ Artifact aetherArtifact = RepositoryUtils.toArtifact( mavenArtifact );
// 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 );
+ return buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
+ aetherArtifact );
}
@Override
- public String getPathForLocalArtifact( ArtifactCoordinate coordinate )
+ public String getPathForLocalArtifact( ProjectBuildingRequest buildingRequest,
+ ArtifactCoordinate coordinate )
{
Artifact aetherArtifact = toArtifact( coordinate );
- return session.getLocalRepositoryManager().getPathForLocalArtifact( aetherArtifact );
+ return buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
+ aetherArtifact );
}
-
+
@Override
- public String getPathForLocalMetadata( ArtifactMetadata metadata )
+ public String getPathForLocalMetadata( ProjectBuildingRequest buildingRequest,
+ 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 );
+ 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 );
+ return buildingRequest.getRepositorySession().getLocalRepositoryManager().getPathForLocalMetadata(
+ aetherMetadata );
}
@Override
- public ProjectBuildingRequest setLocalRepositoryBasedir( ProjectBuildingRequest buildingRequest, File basedir )
+ 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 );
- }
+ RepositorySystemSession session = buildingRequest.getRepositorySession();
// "clone" session and replace localRepository
DefaultRepositorySystemSession newSession = new DefaultRepositorySystemSession( session );
@@ -119,27 +113,20 @@ class Maven31RepositoryManager
// keep same repositoryType
String repositoryType = resolveRepositoryType( session.getLocalRepository() );
- LocalRepositoryManager localRepositoryManager =
- repositorySystem.newLocalRepositoryManager( newSession, new LocalRepository( basedir, repositoryType ) );
+ LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager( newSession,
+ new LocalRepository( basedir, repositoryType ) );
newSession.setLocalRepositoryManager( localRepositoryManager );
- try
- {
- Invoker.invoke( newRequest, "setRepositorySession", RepositorySystemSession.class, newSession );
- }
- catch ( RepositoryManagerException e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
+ newRequest.setRepositorySession( newSession );
return newRequest;
}
@Override
- public File getLocalRepositoryBasedir()
+ public File getLocalRepositoryBasedir( ProjectBuildingRequest buildingRequest )
{
- return session.getLocalRepository().getBasedir();
+ return buildingRequest.getRepositorySession().getLocalRepository().getBasedir();
}
/**
@@ -172,9 +159,8 @@ class Maven31RepositoryManager
return null;
}
- Artifact result =
- new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(), coordinate.getClassifier(),
- coordinate.getExtension(), coordinate.getVersion() );
+ Artifact result = new DefaultArtifact( coordinate.getGroupId(), coordinate.getArtifactId(),
+ coordinate.getClassifier(), coordinate.getExtension(), coordinate.getVersion() );
return result;
}
diff --git a/maven-artifact-transfer-api/pom.xml b/maven-artifact-transfer-api/pom.xml
new file mode 100644
index 0000000..798814c
--- /dev/null
+++ b/maven-artifact-transfer-api/pom.xml
@@ -0,0 +1,113 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-artifact-transfer-api</artifactId>
+
+ <name>Apache Maven Artifact Transfer API</name>
+
+ <properties>
+ <apiMaven.version>3.0</apiMaven.version>
+ </properties>
+
+ <!-- This module must work in CP of Maven 3.0.x AND Maven 3.1.x -->
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${apiMaven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${apiMaven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Not provided, as it is not present in Maven 3.0.x -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ </dependency>
+
+ <!-- Real dependenciesL we need them resolved at runtime-->
+ <!-- TODO: this is used by maven-3.0.x provider!!! Move sonatype filters into maven-3.0.x? -->
+ <!-- Sadly, this AGAIN pulls in all of maven, so leave them out: we control explicitly maven stuff -->
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-common-artifact-filters</artifactId>
+ <version>${artifactFilters.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-plexus</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java
index eed2eca..7b0654b 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/ArtifactCoordinate.java
@@ -1,60 +1,60 @@
-package org.apache.maven.shared.transfer.artifact;
-
-/*
- * 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.
- */
-
-/**
- * <p>
- * Contains all required elements of a Maven Artifact to resolve and calculate its path for either a local or
- * remote Maven2 repository.
- * </p>
- *
- * @author Robert Scholte
- */
-public interface ArtifactCoordinate
-{
- /**
- * @return The groupId of the artifact.
- */
- String getGroupId();
-
- /**
- * @return The artifactId of the artifact.
- */
- String getArtifactId();
-
- /**
- * A version, never a versionRange
- *
- * @return The version.
- */
- String getVersion();
-
- /**
- * The file-extension of the artifact.
- *
- * @return The extension.
- */
- String getExtension();
-
- /**
- * @return The classifier of the artifact.
- */
- String getClassifier();
+package org.apache.maven.shared.transfer.artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * <p>
+ * Contains all required elements of a Maven Artifact to resolve and calculate its path for either a local or
+ * remote Maven2 repository.
+ * </p>
+ *
+ * @author Robert Scholte
+ */
+public interface ArtifactCoordinate
+{
+ /**
+ * @return The groupId of the artifact.
+ */
+ String getGroupId();
+
+ /**
+ * @return The artifactId of the artifact.
+ */
+ String getArtifactId();
+
+ /**
+ * A version, never a versionRange
+ *
+ * @return The version.
+ */
+ String getVersion();
+
+ /**
+ * The file-extension of the artifact.
+ *
+ * @return The extension.
+ */
+ String getExtension();
+
+ /**
+ * @return The classifier of the artifact.
+ */
+ String getClassifier();
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java
index 070607d..9b86ee2 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/DefaultArtifactCoordinate.java
@@ -1,184 +1,184 @@
-package org.apache.maven.shared.transfer.artifact;
-
-/*
- * 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.
- */
-
-/**
- * Common usage of an ArtifactCoordinate for a Mojo
- *
- * <pre>
- * @Parameter
- * private DefaultArtifactCoordinate[] artifacts;
- * </pre>
- *
- * and
- *
- * <pre>
- * private DefaultArtifactCoordinate artifact = new DefaultArtifactCoordinate();
- *
- * @Parameter( property = "groupId" )
- * private String groupId;
- *
- * @Parameter( property = "artifactId" )
- * private String artifactId;
- *
- * @Parameter( property = "version" )
- * private String version;
- *
- * @Parameter( property = "classifier" )
- * private String classifier;
- *
- * @Parameter( property = "type" )
- * private String type;
- *
- * public void setGroupId( String groupId )
- * {
- * this.artifact.setGroupId( groupId );
- * }
- *
- * public void setArtifactId( String artifactId )
- * {
- * this.artifact.setArtifactId( artifactId );
- * }
- *
- * public void setVersion( String version )
- * {
- * this.artifact.setVersion( version );
- * }
- *
- * public void setClassifier( String classifier )
- * {
- * this.artifact.setClassifier( classifier );
- * }
- *
- * public void setType( String type )
- * {
- * this.artifact.setType( type );
- * }
- * </pre>
- *
- * <strong>Note: </strong> type is not the same as extension! {@link org.apache.maven.artifact.handler.ArtifactHandler}s
- * are used to map a type to an extension.
- *
- * @author Robert Scholte
- * @since 3.0
- */
-public class DefaultArtifactCoordinate
- implements ArtifactCoordinate
-{
- private String groupId;
-
- private String artifactId;
-
- private String version;
-
- private String extension;
-
- private String classifier;
-
- @Override
- public final String getGroupId()
- {
- return groupId;
- }
-
- /**
- * @param groupId The groupId to be used.
- */
- public final void setGroupId( String groupId )
- {
- this.groupId = groupId;
- }
-
- @Override
- public final String getArtifactId()
- {
- return artifactId;
- }
-
- /**
- * @param artifactId The artifactId to be used.
- */
- public final void setArtifactId( String artifactId )
- {
- this.artifactId = artifactId;
- }
-
- @Override
- public final String getVersion()
- {
- return version;
- }
-
- /**
- * @param version The version to be used.
- */
- public final void setVersion( String version )
- {
- this.version = version;
- }
-
- @Override
- public final String getExtension()
- {
- return extension != null ? extension : "jar";
- }
-
- /**
- * @param extension The extension to be used.
- */
- public final void setExtension( String extension )
- {
- this.extension = extension;
- }
-
- @Override
- public final String getClassifier()
- {
- return classifier;
- }
-
- /**
- * @param classifier The classifier to be used.
- */
- public final void setClassifier( String classifier )
- {
- this.classifier = classifier;
- }
-
- /**
- * @see org.apache.maven.artifact.DefaultArtifact#toString()
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder().append( groupId ).append( ':' )
- .append( artifactId ).append( ':' ).append( getExtension() );
-
- if ( classifier != null )
- {
- sb.append( ':' ).append( classifier );
- }
-
- sb.append( ':' ).append( version );
-
- return sb.toString();
- }
-
-}
+package org.apache.maven.shared.transfer.artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * Common usage of an ArtifactCoordinate for a Mojo
+ *
+ * <pre>
+ * @Parameter
+ * private DefaultArtifactCoordinate[] artifacts;
+ * </pre>
+ *
+ * and
+ *
+ * <pre>
+ * private DefaultArtifactCoordinate artifact = new DefaultArtifactCoordinate();
+ *
+ * @Parameter( property = "groupId" )
+ * private String groupId;
+ *
+ * @Parameter( property = "artifactId" )
+ * private String artifactId;
+ *
+ * @Parameter( property = "version" )
+ * private String version;
+ *
+ * @Parameter( property = "classifier" )
+ * private String classifier;
+ *
+ * @Parameter( property = "type" )
+ * private String type;
+ *
+ * public void setGroupId( String groupId )
+ * {
+ * this.artifact.setGroupId( groupId );
+ * }
+ *
+ * public void setArtifactId( String artifactId )
+ * {
+ * this.artifact.setArtifactId( artifactId );
+ * }
+ *
+ * public void setVersion( String version )
+ * {
+ * this.artifact.setVersion( version );
+ * }
+ *
+ * public void setClassifier( String classifier )
+ * {
+ * this.artifact.setClassifier( classifier );
+ * }
+ *
+ * public void setType( String type )
+ * {
+ * this.artifact.setType( type );
+ * }
+ * </pre>
+ *
+ * <strong>Note: </strong> type is not the same as extension! {@link org.apache.maven.artifact.handler.ArtifactHandler}s
+ * are used to map a type to an extension.
+ *
+ * @author Robert Scholte
+ * @since 3.0
+ */
+public class DefaultArtifactCoordinate
+ implements ArtifactCoordinate
+{
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String extension;
+
+ private String classifier;
+
+ @Override
+ public final String getGroupId()
+ {
+ return groupId;
+ }
+
+ /**
+ * @param groupId The groupId to be used.
+ */
+ public final void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ @Override
+ public final String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ /**
+ * @param artifactId The artifactId to be used.
+ */
+ public final void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ @Override
+ public final String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * @param version The version to be used.
+ */
+ public final void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ @Override
+ public final String getExtension()
+ {
+ return extension != null ? extension : "jar";
+ }
+
+ /**
+ * @param extension The extension to be used.
+ */
+ public final void setExtension( String extension )
+ {
+ this.extension = extension;
+ }
+
+ @Override
+ public final String getClassifier()
+ {
+ return classifier;
+ }
+
+ /**
+ * @param classifier The classifier to be used.
+ */
+ public final void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ /**
+ * @see org.apache.maven.artifact.DefaultArtifact#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder().append( groupId ).append( ':' )
+ .append( artifactId ).append( ':' ).append( getExtension() );
+
+ if ( classifier != null )
+ {
+ sb.append( ':' ).append( classifier );
+ }
+
+ sb.append( ':' ).append( version );
+
+ return sb.toString();
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
similarity index 97%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
index 83fa7e1..d4506c3 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
@@ -1,125 +1,125 @@
-package org.apache.maven.shared.transfer.artifact;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Extension;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.ReportPlugin;
-
-/**
- * Utility class
- *
- * @author Robert Scholte
- */
-public final class TransferUtils
-{
- private TransferUtils()
- {
- }
-
- /**
- * @param artifact {@link Artifact}
- * @return {@link ArtifactCoordinate}
- */
- public static ArtifactCoordinate toArtifactCoordinate( Artifact artifact )
- {
- DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-
- coordinate.setGroupId( artifact.getGroupId() );
- coordinate.setArtifactId( artifact.getArtifactId() );
- coordinate.setVersion( artifact.getVersion() );
- coordinate.setExtension( artifact.getArtifactHandler().getExtension() );
- coordinate.setClassifier( artifact.getClassifier() );
-
- return coordinate;
- }
-
- /**
- * Special case: an extension is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
- *
- * @param extension {@link Extension}
- * @return {@link ArtifactCoordinate}
- */
- public static ArtifactCoordinate toArtifactCoordinate( Extension extension )
- {
- DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-
- coordinate.setGroupId( extension.getGroupId() );
- coordinate.setArtifactId( extension.getArtifactId() );
- coordinate.setVersion( extension.getVersion() );
-
- return coordinate;
- }
-
- /**
- * Special case: a parent is always of type {@code pom}, so can be transformed to an ArtifactCoordinate.
- *
- * @param parent {@link Parent}
- * @return {@link ArtifactCoordinate}
- */
- public static ArtifactCoordinate toArtifactCoordinate( Parent parent )
- {
- DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-
- coordinate.setGroupId( parent.getGroupId() );
- coordinate.setArtifactId( parent.getArtifactId() );
- coordinate.setVersion( parent.getVersion() );
- coordinate.setExtension( "pom" );
-
- return coordinate;
- }
-
- /**
- * Special case: a plugin is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
- *
- * @param plugin {@link Plugin}
- * @return {@link ArtifactCoordinate}
- */
- public static ArtifactCoordinate toArtifactCoordinate( Plugin plugin )
- {
- DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-
- coordinate.setGroupId( plugin.getGroupId() );
- coordinate.setArtifactId( plugin.getArtifactId() );
- coordinate.setVersion( plugin.getVersion() );
-
- return coordinate;
- }
-
- /**
- * Special case: a reportPlugin is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
- *
- * @param plugin {@link ReportPlugin}
- * @return {@link ArtifactCoordinate}
- */
- public static ArtifactCoordinate toArtifactCoordinate( ReportPlugin plugin )
- {
- DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-
- coordinate.setGroupId( plugin.getGroupId() );
- coordinate.setArtifactId( plugin.getArtifactId() );
- coordinate.setVersion( plugin.getVersion() );
-
- return coordinate;
- }
-
-}
+package org.apache.maven.shared.transfer.artifact;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Extension;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.ReportPlugin;
+
+/**
+ * Utility class
+ *
+ * @author Robert Scholte
+ */
+public final class TransferUtils
+{
+ private TransferUtils()
+ {
+ }
+
+ /**
+ * @param artifact {@link Artifact}
+ * @return {@link ArtifactCoordinate}
+ */
+ public static ArtifactCoordinate toArtifactCoordinate( Artifact artifact )
+ {
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+
+ coordinate.setGroupId( artifact.getGroupId() );
+ coordinate.setArtifactId( artifact.getArtifactId() );
+ coordinate.setVersion( artifact.getVersion() );
+ coordinate.setExtension( artifact.getArtifactHandler().getExtension() );
+ coordinate.setClassifier( artifact.getClassifier() );
+
+ return coordinate;
+ }
+
+ /**
+ * Special case: an extension is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
+ *
+ * @param extension {@link Extension}
+ * @return {@link ArtifactCoordinate}
+ */
+ public static ArtifactCoordinate toArtifactCoordinate( Extension extension )
+ {
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+
+ coordinate.setGroupId( extension.getGroupId() );
+ coordinate.setArtifactId( extension.getArtifactId() );
+ coordinate.setVersion( extension.getVersion() );
+
+ return coordinate;
+ }
+
+ /**
+ * Special case: a parent is always of type {@code pom}, so can be transformed to an ArtifactCoordinate.
+ *
+ * @param parent {@link Parent}
+ * @return {@link ArtifactCoordinate}
+ */
+ public static ArtifactCoordinate toArtifactCoordinate( Parent parent )
+ {
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+
+ coordinate.setGroupId( parent.getGroupId() );
+ coordinate.setArtifactId( parent.getArtifactId() );
+ coordinate.setVersion( parent.getVersion() );
+ coordinate.setExtension( "pom" );
+
+ return coordinate;
+ }
+
+ /**
+ * Special case: a plugin is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
+ *
+ * @param plugin {@link Plugin}
+ * @return {@link ArtifactCoordinate}
+ */
+ public static ArtifactCoordinate toArtifactCoordinate( Plugin plugin )
+ {
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+
+ coordinate.setGroupId( plugin.getGroupId() );
+ coordinate.setArtifactId( plugin.getArtifactId() );
+ coordinate.setVersion( plugin.getVersion() );
+
+ return coordinate;
+ }
+
+ /**
+ * Special case: a reportPlugin is always of type {@code jar}, so can be transformed to an ArtifactCoordinate.
+ *
+ * @param plugin {@link ReportPlugin}
+ * @return {@link ArtifactCoordinate}
+ */
+ public static ArtifactCoordinate toArtifactCoordinate( ReportPlugin plugin )
+ {
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+
+ coordinate.setGroupId( plugin.getGroupId() );
+ coordinate.setArtifactId( plugin.getArtifactId() );
+ coordinate.setVersion( plugin.getVersion() );
+
+ return coordinate;
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployer.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployer.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployer.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployer.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployerException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployerException.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployerException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/ArtifactDeployerException.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/ArtifactDeployerDelegate.java
similarity index 74%
copy from src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
copy to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/ArtifactDeployerDelegate.java
index e77d6fd..b523f13 100644
--- a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/ArtifactDeployerDelegate.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.transfer.metadata;
+package org.apache.maven.shared.transfer.artifact.deploy.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,15 +19,11 @@ package org.apache.maven.shared.transfer.metadata;
* under the License.
*/
-import java.io.File;
+import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer;
/**
- * Original ArtifactMetada with File reference
- *
- * @author Robert Scholte
- *
+ * To be implemented by provider specific implementation.
*/
-public interface ArtifactMetadata extends org.apache.maven.repository.legacy.metadata.ArtifactMetadata
+public interface ArtifactDeployerDelegate extends ArtifactDeployer
{
- File getFile();
}
diff --git a/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java
new file mode 100644
index 0000000..ccf0b76
--- /dev/null
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/deploy/internal/DefaultArtifactDeployer.java
@@ -0,0 +1,86 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+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.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.util.Collection;
+import java.util.Map;
+
+import static org.apache.maven.shared.transfer.support.Selector.selectDelegate;
+
+/**
+ *
+ */
+@Component( role = ArtifactDeployer.class, hint = "default" )
+public class DefaultArtifactDeployer
+ implements ArtifactDeployer
+{
+ @Requirement( role = ArtifactDeployerDelegate.class )
+ private Map<String, ArtifactDeployerDelegate> delegates;
+
+ public DefaultArtifactDeployer()
+ {
+ }
+
+ public DefaultArtifactDeployer( Map<String, ArtifactDeployerDelegate> delegates )
+ {
+ this.delegates = delegates;
+ }
+
+ @Override
+ public void deploy( ProjectBuildingRequest request,
+ Collection<Artifact> mavenArtifacts ) throws ArtifactDeployerException
+ {
+ validateParameters( request, mavenArtifacts );
+ selectDelegate( delegates ).deploy( request, mavenArtifacts );
+ }
+
+ @Override
+ public void deploy( ProjectBuildingRequest request,
+ ArtifactRepository remoteRepository,
+ Collection<Artifact> mavenArtifacts ) throws ArtifactDeployerException
+ {
+ validateParameters( request, mavenArtifacts );
+ selectDelegate( delegates ).deploy( request, remoteRepository, mavenArtifacts );
+ }
+
+ private void validateParameters( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts )
+ {
+ if ( request == null )
+ {
+ throw new IllegalArgumentException( "The parameter request is not allowed to be null." );
+ }
+ if ( mavenArtifacts == null )
+ {
+ throw new IllegalArgumentException( "The parameter mavenArtifacts is not allowed to be null." );
+ }
+ if ( mavenArtifacts.isEmpty() )
+ {
+ throw new IllegalArgumentException( "The collection mavenArtifacts is not allowed to be empty." );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java
similarity index 99%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java
index 5ca2f7c..7aeea53 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstaller.java
@@ -30,7 +30,6 @@ import org.apache.maven.project.ProjectBuildingRequest;
*/
public interface ArtifactInstaller
{
-
/**
* @param request {@link ProjectBuildingRequest}
* @param mavenArtifacts {@link Artifact} (no null or empty collection allowed.)
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstallerException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstallerException.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstallerException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/ArtifactInstallerException.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/MavenArtifactInstaller.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/ArtifactInstallerDelegate.java
similarity index 78%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/MavenArtifactInstaller.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/ArtifactInstallerDelegate.java
index 6d6509d..0f60651 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/MavenArtifactInstaller.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/ArtifactInstallerDelegate.java
@@ -19,18 +19,11 @@ package org.apache.maven.shared.transfer.artifact.install.internal;
* under the License.
*/
-import java.util.Collection;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller;
/**
- *
- * @author Robert Scholte
- *
+ * To be implemented by provider specific implementation.
*/
-interface MavenArtifactInstaller
+public interface ArtifactInstallerDelegate extends ArtifactInstaller
{
- void install( Collection<Artifact> mavenArtifacts )
- throws ArtifactInstallerException;
}
diff --git a/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java
new file mode 100644
index 0000000..e57d1f1
--- /dev/null
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/install/internal/DefaultArtifactInstaller.java
@@ -0,0 +1,95 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller;
+import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Map;
+
+import static org.apache.maven.shared.transfer.support.Selector.selectDelegate;
+
+/**
+ *
+ */
+@Component( role = ArtifactInstaller.class, hint = "default" )
+public class DefaultArtifactInstaller
+ implements ArtifactInstaller
+{
+ @Requirement( role = ArtifactInstallerDelegate.class )
+ private Map<String, ArtifactInstallerDelegate> delegates;
+
+ public DefaultArtifactInstaller()
+ {
+ }
+
+ public DefaultArtifactInstaller( Map<String, ArtifactInstallerDelegate> delegates )
+ {
+ this.delegates = delegates;
+ }
+
+ @Override
+ public void install( ProjectBuildingRequest request,
+ Collection<Artifact> mavenArtifacts )
+ throws ArtifactInstallerException, IllegalArgumentException
+ {
+ validateParameters( request, mavenArtifacts );
+ selectDelegate( delegates ).install( request, mavenArtifacts );
+ }
+
+ @Override
+ public void install( ProjectBuildingRequest request,
+ File localRepository,
+ Collection<Artifact> mavenArtifacts ) throws ArtifactInstallerException
+ {
+ validateParameters( request, mavenArtifacts );
+ if ( localRepository == null )
+ {
+ throw new IllegalArgumentException( "The parameter localRepository is not allowed to be null." );
+ }
+ if ( !localRepository.isDirectory() )
+ {
+ throw new IllegalArgumentException( "The parameter localRepository must be a directory." );
+ }
+ selectDelegate( delegates ).install( request, localRepository, mavenArtifacts );
+ }
+
+ private void validateParameters( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts )
+ {
+ if ( request == null )
+ {
+ throw new IllegalArgumentException( "The parameter request is not allowed to be null." );
+ }
+ if ( mavenArtifacts == null )
+ {
+ throw new IllegalArgumentException( "The parameter mavenArtifacts is not allowed to be null." );
+ }
+ if ( mavenArtifacts.isEmpty() )
+ {
+ throw new IllegalArgumentException( "The collection mavenArtifacts is not allowed to be empty." );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolver.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolver.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolver.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolver.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolverException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolverException.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolverException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResolverException.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java
index bc89ff0..6941975 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/ArtifactResult.java
@@ -1,36 +1,36 @@
-package org.apache.maven.shared.transfer.artifact.resolve;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-
-/**
- * The Artifact Result
- *
- * @author Robert Scholte
- * @since 3.0
- */
-public interface ArtifactResult
-{
- /**
- * @return {@link Artifact}
- */
- Artifact getArtifact();
-}
+package org.apache.maven.shared.transfer.artifact.resolve;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * The Artifact Result
+ *
+ * @author Robert Scholte
+ * @since 3.0
+ */
+public interface ArtifactResult
+{
+ /**
+ * @return {@link Artifact}
+ */
+ Artifact getArtifact();
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/ArtifactResolverDelegate.java
similarity index 74%
copy from src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
copy to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/ArtifactResolverDelegate.java
index e77d6fd..da59943 100644
--- a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/ArtifactResolverDelegate.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.transfer.metadata;
+package org.apache.maven.shared.transfer.artifact.resolve.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,15 +19,11 @@ package org.apache.maven.shared.transfer.metadata;
* under the License.
*/
-import java.io.File;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
/**
- * Original ArtifactMetada with File reference
- *
- * @author Robert Scholte
- *
+ * To be implemented by provider specific implementation.
*/
-public interface ArtifactMetadata extends org.apache.maven.repository.legacy.metadata.ArtifactMetadata
+public interface ArtifactResolverDelegate extends ArtifactResolver
{
- File getFile();
}
diff --git a/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java
new file mode 100644
index 0000000..e5e6192
--- /dev/null
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/artifact/resolve/internal/DefaultArtifactResolver.java
@@ -0,0 +1,95 @@
+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.artifact.Artifact;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.util.Map;
+
+import static org.apache.maven.shared.transfer.support.Selector.selectDelegate;
+
+/**
+ *
+ */
+@Component( role = ArtifactResolver.class, hint = "default" )
+public class DefaultArtifactResolver
+ implements ArtifactResolver
+{
+ @Requirement( role = ArtifactResolverDelegate.class )
+ private Map<String, ArtifactResolverDelegate> delegates;
+
+ public DefaultArtifactResolver()
+ {
+ }
+
+ public DefaultArtifactResolver( Map<String, ArtifactResolverDelegate> delegates )
+ {
+ this.delegates = delegates;
+ }
+
+ @Override
+ public ArtifactResult resolveArtifact( ProjectBuildingRequest buildingRequest,
+ Artifact mavenArtifact )
+ throws ArtifactResolverException, IllegalArgumentException
+ {
+ validateParameters( buildingRequest, mavenArtifact );
+ return selectDelegate( delegates ).resolveArtifact( buildingRequest, mavenArtifact );
+ }
+
+ @Override
+ public ArtifactResult resolveArtifact( ProjectBuildingRequest buildingRequest,
+ ArtifactCoordinate coordinate )
+ throws ArtifactResolverException, IllegalArgumentException
+ {
+ validateParameters( buildingRequest, coordinate );
+ return selectDelegate( delegates ).resolveArtifact( buildingRequest, coordinate );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, Artifact mavenArtifact )
+ {
+ if ( buildingRequest == null )
+ {
+ throw new IllegalArgumentException( "The parameter buildingRequest is not allowed to be null." );
+ }
+ if ( mavenArtifact == null )
+ {
+ throw new IllegalArgumentException( "The parameter mavenArtifact is not allowed to be null." );
+ }
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, ArtifactCoordinate coordinate )
+ {
+ if ( buildingRequest == null )
+ {
+ throw new IllegalArgumentException( "The parameter buildingRequest is not allowed to be null." );
+ }
+ if ( coordinate == null )
+ {
+ throw new IllegalArgumentException( "The parameter coordinate is not allowed to be null." );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/CollectRequest.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/CollectRequest.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/CollectRequest.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/CollectRequest.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/CollectResult.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/CollectResult.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/CollectResult.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/CollectResult.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollectionException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollectionException.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollectionException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollectionException.java
diff --git a/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollector.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollector.java
similarity index 100%
rename from src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollector.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/DependencyCollector.java
diff --git a/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java
new file mode 100644
index 0000000..5603c49
--- /dev/null
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DefaultDependencyCollector.java
@@ -0,0 +1,113 @@
+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 org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingRequest;
+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.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.maven.shared.transfer.support.Selector.selectDelegate;
+
+/**
+ *
+ */
+@Component( role = DependencyCollector.class, hint = "default" )
+public class DefaultDependencyCollector
+ implements DependencyCollector
+{
+ @Requirement( role = DependencyCollectorDelegate.class )
+ private Map<String, DependencyCollectorDelegate> delegates;
+
+ public DefaultDependencyCollector()
+ {
+ }
+
+ public DefaultDependencyCollector( Map<String, DependencyCollectorDelegate> delegates )
+ {
+ this.delegates = delegates;
+ }
+
+ @Override
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ Dependency root )
+ throws DependencyCollectionException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ @Override
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ DependableCoordinate root )
+ throws DependencyCollectionException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ @Override
+ public CollectResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ Model root )
+ throws DependencyCollectionException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
+ {
+ validateBuildingRequestAndRoot( buildingRequest, root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, Dependency root )
+ {
+ validateBuildingRequestAndRoot( buildingRequest, root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, Model root )
+ {
+ validateBuildingRequestAndRoot( buildingRequest, root );
+ }
+
+ private void validateBuildingRequestAndRoot( ProjectBuildingRequest buildingRequest, Object root )
+ {
+ validateBuildingRequest( buildingRequest );
+ validateRoot( root );
+ }
+
+ private void validateBuildingRequest( ProjectBuildingRequest buildingRequest )
+ {
+ Objects.requireNonNull( buildingRequest, "The parameter buildingRequest is not allowed to be null." );
+ }
+
+ private void validateRoot( Object root )
+ {
+ Objects.requireNonNull( root, "The parameter root is not allowed to be null." );
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DependencyCollectorDelegate.java
similarity index 74%
copy from src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
copy to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DependencyCollectorDelegate.java
index e77d6fd..7f02685 100644
--- a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/collection/internal/DependencyCollectorDelegate.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.transfer.metadata;
+package org.apache.maven.shared.transfer.collection.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,15 +19,11 @@ package org.apache.maven.shared.transfer.metadata;
* under the License.
*/
-import java.io.File;
+import org.apache.maven.shared.transfer.collection.DependencyCollector;
/**
- * Original ArtifactMetada with File reference
- *
- * @author Robert Scholte
- *
+ * To be implemented by provider specific implementation.
*/
-public interface ArtifactMetadata extends org.apache.maven.repository.legacy.metadata.ArtifactMetadata
+public interface DependencyCollectorDelegate extends DependencyCollector
{
- File getFile();
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java
similarity index 95%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java
index 1619586..dcd78b5 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DefaultDependableCoordinate.java
@@ -1,183 +1,183 @@
-package org.apache.maven.shared.transfer.dependencies;
-
-/*
- * 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.
- */
-
-/**
- * Common usage of an DependableCoordinate for a Mojo
- *
- * <pre>
- * @Parameter
- * private DefaultDependableCoordinate[] dependencies;
- * </pre>
- *
- * and
- *
- * <pre>
- * private DefaultDependableCoordinate dependable = new DefaultDependableCoordinate();
- *
- * @Parameter( property = "groupId" )
- * private String groupId;
- *
- * @Parameter( property = "artifactId" )
- * private String artifactId;
- *
- * @Parameter( property = "version" )
- * private String version;
- *
- * @Parameter( property = "classifier" )
- * private String classifier;
- *
- * @Parameter( property = "type" )
- * private String type;
- *
- * public void setGroupId( String groupId )
- * {
- * this.dependable.setGroupId( groupId );
- * }
- *
- * public void setArtifactId( String artifactId )
- * {
- * this.dependable.setArtifactId( artifactId );
- * }
- *
- * public void setVersion( String version )
- * {
- * this.dependable.setVersion( version );
- * }
- *
- * public void setClassifier( String classifier )
- * {
- * this.dependable.setClassifier( classifier );
- * }
- *
- * public void setType( String type )
- * {
- * this.dependable.setType( type );
- * }
- * </pre>
- * <strong>Note: </strong> type is not the same as extension!
- * {@link org.apache.maven.artifact.handler.ArtifactHandler}s are used to map a type to an extension.
- *
- *
- * @author Robert Scholte
- * @since 3.0
- */
-public class DefaultDependableCoordinate implements DependableCoordinate
-{
- private String groupId;
-
- private String artifactId;
-
- private String version;
-
- private String type;
-
- private String classifier;
-
- @Override
- public final String getGroupId()
- {
- return groupId;
- }
-
- /**
- * @param groupId The groupId to be set.
- */
- public final void setGroupId( String groupId )
- {
- this.groupId = groupId;
- }
-
- @Override
- public final String getArtifactId()
- {
- return artifactId;
- }
-
- /**
- * @param artifactId The artifactId to be set.
- */
- public final void setArtifactId( String artifactId )
- {
- this.artifactId = artifactId;
- }
-
- @Override
- public final String getVersion()
- {
- return version;
- }
-
- /**
- * @param version The version to be set.
- */
- public final void setVersion( String version )
- {
- this.version = version;
- }
-
- @Override
- public final String getType()
- {
- return type != null ? type : "jar";
- }
-
- /**
- * @param type The type to be set.
- */
- public void setType( String type )
- {
- this.type = type;
- }
-
- @Override
- public final String getClassifier()
- {
- return classifier;
- }
-
- /**
- * @param classifier The classifier to be set.
- */
- public final void setClassifier( String classifier )
- {
- this.classifier = classifier;
- }
-
- /**
- * @see org.apache.maven.artifact.DefaultArtifact#toString()
- */
- @Override
- public String toString()
- {
- StringBuilder sb =
- new StringBuilder().append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( getType() );
-
- if ( classifier != null )
- {
- sb.append( ':' ).append( classifier );
- }
-
- sb.append( ':' ).append( version );
-
- return sb.toString();
- }
-
-}
+package org.apache.maven.shared.transfer.dependencies;
+
+/*
+ * 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.
+ */
+
+/**
+ * Common usage of an DependableCoordinate for a Mojo
+ *
+ * <pre>
+ * @Parameter
+ * private DefaultDependableCoordinate[] dependencies;
+ * </pre>
+ *
+ * and
+ *
+ * <pre>
+ * private DefaultDependableCoordinate dependable = new DefaultDependableCoordinate();
+ *
+ * @Parameter( property = "groupId" )
+ * private String groupId;
+ *
+ * @Parameter( property = "artifactId" )
+ * private String artifactId;
+ *
+ * @Parameter( property = "version" )
+ * private String version;
+ *
+ * @Parameter( property = "classifier" )
+ * private String classifier;
+ *
+ * @Parameter( property = "type" )
+ * private String type;
+ *
+ * public void setGroupId( String groupId )
+ * {
+ * this.dependable.setGroupId( groupId );
+ * }
+ *
+ * public void setArtifactId( String artifactId )
+ * {
+ * this.dependable.setArtifactId( artifactId );
+ * }
+ *
+ * public void setVersion( String version )
+ * {
+ * this.dependable.setVersion( version );
+ * }
+ *
+ * public void setClassifier( String classifier )
+ * {
+ * this.dependable.setClassifier( classifier );
+ * }
+ *
+ * public void setType( String type )
+ * {
+ * this.dependable.setType( type );
+ * }
+ * </pre>
+ * <strong>Note: </strong> type is not the same as extension!
+ * {@link org.apache.maven.artifact.handler.ArtifactHandler}s are used to map a type to an extension.
+ *
+ *
+ * @author Robert Scholte
+ * @since 3.0
+ */
+public class DefaultDependableCoordinate implements DependableCoordinate
+{
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String type;
+
+ private String classifier;
+
+ @Override
+ public final String getGroupId()
+ {
+ return groupId;
+ }
+
+ /**
+ * @param groupId The groupId to be set.
+ */
+ public final void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ @Override
+ public final String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ /**
+ * @param artifactId The artifactId to be set.
+ */
+ public final void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ @Override
+ public final String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * @param version The version to be set.
+ */
+ public final void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ @Override
+ public final String getType()
+ {
+ return type != null ? type : "jar";
+ }
+
+ /**
+ * @param type The type to be set.
+ */
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ @Override
+ public final String getClassifier()
+ {
+ return classifier;
+ }
+
+ /**
+ * @param classifier The classifier to be set.
+ */
+ public final void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ /**
+ * @see org.apache.maven.artifact.DefaultArtifact#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb =
+ new StringBuilder().append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( getType() );
+
+ if ( classifier != null )
+ {
+ sb.append( ':' ).append( classifier );
+ }
+
+ sb.append( ':' ).append( version );
+
+ return sb.toString();
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java
index 5182b3d..a2e8a3b 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/DependableCoordinate.java
@@ -1,70 +1,70 @@
-package org.apache.maven.shared.transfer.dependencies;
-
-/*
- * 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.
- */
-
-/**
- * <p>
- * Represents any instance which may contain Maven Dependencies, both explicit or implicit to (transitively) resolve
- * and calculate its path for either a local or remote Maven repository.
- * </p>
- * <p>
- * The version can be a version range. Based on the groupId and artifactId it will be resolved to the actual version.
- * </p>
- * <p>
- * The type will be translated to an extension based on the artifact descriptor ({@code pom.xml} matching the groupId,
- * artifactId and version.
- * </p>
- * A MavenProject is not considered a DependableCoordinate because it should never have a versionRange, and it has
- * packaging instead of type.
- *
- * @author Robert Scholte
- */
-public interface DependableCoordinate
-{
- /**
- * @return the groupId of the coordinate
- */
- String getGroupId();
-
- /**
- *
- * @return the artifact of the coordinate
- */
- String getArtifactId();
-
- /**
- * A version or versionRange
- *
- * @return the version
- */
- String getVersion();
-
- /**
- *
- * @return the type of the coordinate
- */
- String getType();
-
- /**
- *
- * @return the classifier or {@code null}
- */
- String getClassifier();
-}
+package org.apache.maven.shared.transfer.dependencies;
+
+/*
+ * 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.
+ */
+
+/**
+ * <p>
+ * Represents any instance which may contain Maven Dependencies, both explicit or implicit to (transitively) resolve
+ * and calculate its path for either a local or remote Maven repository.
+ * </p>
+ * <p>
+ * The version can be a version range. Based on the groupId and artifactId it will be resolved to the actual version.
+ * </p>
+ * <p>
+ * The type will be translated to an extension based on the artifact descriptor ({@code pom.xml} matching the groupId,
+ * artifactId and version.
+ * </p>
+ * A MavenProject is not considered a DependableCoordinate because it should never have a versionRange, and it has
+ * packaging instead of type.
+ *
+ * @author Robert Scholte
+ */
+public interface DependableCoordinate
+{
+ /**
+ * @return the groupId of the coordinate
+ */
+ String getGroupId();
+
+ /**
+ *
+ * @return the artifact of the coordinate
+ */
+ String getArtifactId();
+
+ /**
+ * A version or versionRange
+ *
+ * @return the version
+ */
+ String getVersion();
+
+ /**
+ *
+ * @return the type of the coordinate
+ */
+ String getType();
+
+ /**
+ *
+ * @return the classifier or {@code null}
+ */
+ String getClassifier();
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java
similarity index 97%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java
index aa87f81..078ebb4 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/TransferUtils.java
@@ -1,136 +1,136 @@
-package org.apache.maven.shared.transfer.dependencies;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Extension;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.ReportPlugin;
-
-/**
- * Utility class to convert different things like {@link Dependency}, {@link Extension}, {@link Model}, {@link Parent},
- * {@link Plugin} and {@link ReportPlugin} into {@link DependableCoordinate}.
- *
- * @author Robert Scholte
- */
-public final class TransferUtils
-{
- private TransferUtils()
- {
- }
-
- /**
- * @param dependency {@link Dependency} to be converted to {@link DependableCoordinate}
- * @return {@link DependableCoordinate}
- */
- public static DependableCoordinate toDependableCoordinate( Dependency dependency )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( dependency.getGroupId() );
- coordinate.setArtifactId( dependency.getArtifactId() );
- coordinate.setVersion( dependency.getVersion() );
- coordinate.setType( dependency.getType() );
- coordinate.setClassifier( dependency.getClassifier() );
-
- return coordinate;
- }
-
- /**
- * @param extension {@link Extension} to be converted to {@link DependableCoordinate}
- * @return {@link DependableCoordinate}
- */
- public static DependableCoordinate toDependableCoordinate( Extension extension )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( extension.getGroupId() );
- coordinate.setArtifactId( extension.getArtifactId() );
- coordinate.setVersion( extension.getVersion() );
-
- return coordinate;
- }
-
- /**
- * @param model {@link Model} coordinates to be converted to {@link DependableCoordinate}.
- * @return {@link DependableCoordinate}
- */
- public static DependableCoordinate toDependableCoordinate( Model model )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( model.getGroupId() );
- coordinate.setArtifactId( model.getArtifactId() );
- coordinate.setVersion( model.getVersion() );
- coordinate.setType( model.getPackaging() );
-
- return coordinate;
- }
-
- /**
- * @param parent {@link Parent parent} coordinates to be converted to {@link DependableCoordinate}.
- * @return {@link DependableCoordinate}.
- */
- public static DependableCoordinate toDependableCoordinate( Parent parent )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( parent.getGroupId() );
- coordinate.setArtifactId( parent.getArtifactId() );
- coordinate.setVersion( parent.getVersion() );
- coordinate.setType( "pom" );
-
- return coordinate;
- }
-
- /**
- * @param plugin The {@link Plugin plugin} coordiantes which should be converted.
- * @return {@link DependableCoordinate}.
- */
- public static DependableCoordinate toDependableCoordinate( Plugin plugin )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( plugin.getGroupId() );
- coordinate.setArtifactId( plugin.getArtifactId() );
- coordinate.setVersion( plugin.getVersion() );
-
- return coordinate;
- }
-
- /**
- * Convert {@link ReportPlugin plugin} coordinates to {@link DependableCoordinate}.
- * @param plugin The {@link ReportPlugin plugin} to be converted to {@link DependableCoordinate}.
- * @return The converted {@link DependableCoordinate} coordinates.
- */
- public static DependableCoordinate toDependableCoordinate( ReportPlugin plugin )
- {
- DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
-
- coordinate.setGroupId( plugin.getGroupId() );
- coordinate.setArtifactId( plugin.getArtifactId() );
- coordinate.setVersion( plugin.getVersion() );
-
- return coordinate;
- }
-
-}
+package org.apache.maven.shared.transfer.dependencies;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Extension;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.ReportPlugin;
+
+/**
+ * Utility class to convert different things like {@link Dependency}, {@link Extension}, {@link Model}, {@link Parent},
+ * {@link Plugin} and {@link ReportPlugin} into {@link DependableCoordinate}.
+ *
+ * @author Robert Scholte
+ */
+public final class TransferUtils
+{
+ private TransferUtils()
+ {
+ }
+
+ /**
+ * @param dependency {@link Dependency} to be converted to {@link DependableCoordinate}
+ * @return {@link DependableCoordinate}
+ */
+ public static DependableCoordinate toDependableCoordinate( Dependency dependency )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( dependency.getGroupId() );
+ coordinate.setArtifactId( dependency.getArtifactId() );
+ coordinate.setVersion( dependency.getVersion() );
+ coordinate.setType( dependency.getType() );
+ coordinate.setClassifier( dependency.getClassifier() );
+
+ return coordinate;
+ }
+
+ /**
+ * @param extension {@link Extension} to be converted to {@link DependableCoordinate}
+ * @return {@link DependableCoordinate}
+ */
+ public static DependableCoordinate toDependableCoordinate( Extension extension )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( extension.getGroupId() );
+ coordinate.setArtifactId( extension.getArtifactId() );
+ coordinate.setVersion( extension.getVersion() );
+
+ return coordinate;
+ }
+
+ /**
+ * @param model {@link Model} coordinates to be converted to {@link DependableCoordinate}.
+ * @return {@link DependableCoordinate}
+ */
+ public static DependableCoordinate toDependableCoordinate( Model model )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( model.getGroupId() );
+ coordinate.setArtifactId( model.getArtifactId() );
+ coordinate.setVersion( model.getVersion() );
+ coordinate.setType( model.getPackaging() );
+
+ return coordinate;
+ }
+
+ /**
+ * @param parent {@link Parent parent} coordinates to be converted to {@link DependableCoordinate}.
+ * @return {@link DependableCoordinate}.
+ */
+ public static DependableCoordinate toDependableCoordinate( Parent parent )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( parent.getGroupId() );
+ coordinate.setArtifactId( parent.getArtifactId() );
+ coordinate.setVersion( parent.getVersion() );
+ coordinate.setType( "pom" );
+
+ return coordinate;
+ }
+
+ /**
+ * @param plugin The {@link Plugin plugin} coordiantes which should be converted.
+ * @return {@link DependableCoordinate}.
+ */
+ public static DependableCoordinate toDependableCoordinate( Plugin plugin )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( plugin.getGroupId() );
+ coordinate.setArtifactId( plugin.getArtifactId() );
+ coordinate.setVersion( plugin.getVersion() );
+
+ return coordinate;
+ }
+
+ /**
+ * Convert {@link ReportPlugin plugin} coordinates to {@link DependableCoordinate}.
+ * @param plugin The {@link ReportPlugin plugin} to be converted to {@link DependableCoordinate}.
+ * @return The converted {@link DependableCoordinate} coordinates.
+ */
+ public static DependableCoordinate toDependableCoordinate( ReportPlugin plugin )
+ {
+ DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+ coordinate.setGroupId( plugin.getGroupId() );
+ coordinate.setArtifactId( plugin.getArtifactId() );
+ coordinate.setVersion( plugin.getVersion() );
+
+ return coordinate;
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
index d5a13b5..674dad5 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
@@ -1,37 +1,37 @@
-package org.apache.maven.shared.transfer.dependencies.collect;
-
-/*
- * 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.repository.ArtifactRepository;
-
-/**
- *
- * @author Robert Scholte
- *
- */
-public interface CollectorResult
-{
- /**
- * @return List of {@link ArtifactRepository}
- */
- List<ArtifactRepository> getRemoteRepositories();
-}
+package org.apache.maven.shared.transfer.dependencies.collect;
+
+/*
+ * 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.repository.ArtifactRepository;
+
+/**
+ *
+ * @author Robert Scholte
+ *
+ */
+public interface CollectorResult
+{
+ /**
+ * @return List of {@link ArtifactRepository}
+ */
+ List<ArtifactRepository> getRemoteRepositories();
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
similarity index 97%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
index 2134776..0dbc465 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
@@ -1,73 +1,73 @@
-package org.apache.maven.shared.transfer.dependencies.collect;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-
-/**
- * Will only download the pom files when not available, never the artifact.
- *
- * @author Robert Scholte
- *
- */
-public interface DependencyCollector
-{
-
- /**
- * A dependency may have excludes
- *
- * @param buildingRequest {@link ProjectBuildingRequest}
- * @param root {@link Dependency}
- * @return {@link CollectorResult}
- * @throws DependencyCollectorException in case of an error.
- * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
- * parameter <code>root</code> is <code>null</code>.
- */
- CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, Dependency root )
- throws DependencyCollectorException;
-
- /**
- * @param buildingRequest {@link ProjectBuildingRequest}.
- * @param root {@link DependableCoordinate}
- * @return {@link CollectorResult}
- * @throws DependencyCollectorException in case of an error which can be a component lookup error or
- * an error while trying to look up the dependencies.
- * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
- * parameter <code>root</code> is <code>null</code>.
- */
- CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
- throws DependencyCollectorException;
-
- /**
- * @param buildingRequest {@link ProjectBuildingRequest}.
- * @param root {@link Model}
- * @return {@link CollectorResult}
- * @throws DependencyCollectorException in case of an error which can be a component lookup error or
- * an error while trying to look up the dependencies.
- * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
- * parameter <code>root</code> is <code>null</code>.
- */
- CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, Model root )
- throws DependencyCollectorException;
-
-}
+package org.apache.maven.shared.transfer.dependencies.collect;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+
+/**
+ * Will only download the pom files when not available, never the artifact.
+ *
+ * @author Robert Scholte
+ *
+ */
+public interface DependencyCollector
+{
+
+ /**
+ * A dependency may have excludes
+ *
+ * @param buildingRequest {@link ProjectBuildingRequest}
+ * @param root {@link Dependency}
+ * @return {@link CollectorResult}
+ * @throws DependencyCollectorException in case of an error.
+ * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
+ * parameter <code>root</code> is <code>null</code>.
+ */
+ CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, Dependency root )
+ throws DependencyCollectorException;
+
+ /**
+ * @param buildingRequest {@link ProjectBuildingRequest}.
+ * @param root {@link DependableCoordinate}
+ * @return {@link CollectorResult}
+ * @throws DependencyCollectorException in case of an error which can be a component lookup error or
+ * an error while trying to look up the dependencies.
+ * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
+ * parameter <code>root</code> is <code>null</code>.
+ */
+ CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
+ throws DependencyCollectorException;
+
+ /**
+ * @param buildingRequest {@link ProjectBuildingRequest}.
+ * @param root {@link Model}
+ * @return {@link CollectorResult}
+ * @throws DependencyCollectorException in case of an error which can be a component lookup error or
+ * an error while trying to look up the dependencies.
+ * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code> or
+ * parameter <code>root</code> is <code>null</code>.
+ */
+ CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, Model root )
+ throws DependencyCollectorException;
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java
index c959b05..cc5a784 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollectorException.java
@@ -1,43 +1,43 @@
-package org.apache.maven.shared.transfer.dependencies.collect;
-
-/*
- * 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.
- */
-
-/**
- *
- * @author Robert Scholte
- */
-public class DependencyCollectorException extends Exception
-{
-
- /**
- *
- */
- private static final long serialVersionUID = -180986912170441437L;
-
- /**
- * @param message The message you would give for the exception.
- * @param cause The cause which is related to the message.
- */
- public DependencyCollectorException( String message, Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.shared.transfer.dependencies.collect;
+
+/*
+ * 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.
+ */
+
+/**
+ *
+ * @author Robert Scholte
+ */
+public class DependencyCollectorException extends Exception
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -180986912170441437L;
+
+ /**
+ * @param message The message you would give for the exception.
+ * @param cause The cause which is related to the message.
+ */
+ public DependencyCollectorException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
new file mode 100644
index 0000000..f77f456
--- /dev/null
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
@@ -0,0 +1,112 @@
+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 org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingRequest;
+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.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.util.Map;
+
+import static org.apache.maven.shared.transfer.support.Selector.selectDelegate;
+
+/**
+ *
+ */
+@Component( role = DependencyCollector.class, hint = "default" )
+public class DefaultDependencyCollector
+ implements DependencyCollector
+{
+ @Requirement( role = DependencyCollectorDelegate.class )
+ private Map<String, DependencyCollectorDelegate> delegates;
+
+ public DefaultDependencyCollector()
+ {
+ }
+
+ public DefaultDependencyCollector( Map<String, DependencyCollectorDelegate> delegates )
+ {
+ this.delegates = delegates;
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ Dependency root ) throws DependencyCollectorException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ DependableCoordinate root ) throws DependencyCollectorException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ @Override
+ public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest,
+ Model root ) throws DependencyCollectorException
+ {
+ validateParameters( buildingRequest, root );
+ return selectDelegate( delegates ).collectDependencies( buildingRequest, root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
+ {
+ validateBuildingRequest( buildingRequest );
+ validateRoot( root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, Dependency root )
+ {
+ validateBuildingRequest( buildingRequest );
+ validateRoot( root );
+ }
+
+ private void validateParameters( ProjectBuildingRequest buildingRequest, Model root )
+ {
+ validateBuildingRequest( buildingRequest );
+ validateRoot( root );
+ }
+
+ private void validateBuildingRequest( ProjectBuildingRequest buildingRequest )
+ {
+ if ( buildingRequest == null )
+ {
+ throw new IllegalArgumentException( "The parameter buildingRequest is not allowed to be null." );
+ }
+ }
+
+ private void validateRoot( Object root )
+ {
+ if ( root == null )
+ {
+ throw new IllegalArgumentException( "The parameter root is not allowed to be null." );
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DependencyCollectorDelegate.java
similarity index 74%
copy from src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
copy to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DependencyCollectorDelegate.java
index e77d6fd..bb95839 100644
--- a/src/main/java/org/apache/maven/shared/transfer/metadata/ArtifactMetadata.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DependencyCollectorDelegate.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.transfer.metadata;
+package org.apache.maven.shared.transfer.dependencies.collect.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,15 +19,11 @@ package org.apache.maven.shared.transfer.metadata;
* under the License.
*/
-import java.io.File;
+import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector;
/**
- * Original ArtifactMetada with File reference
- *
- * @author Robert Scholte
- *
+ * To be implemented by provider specific implementation.
*/
-public interface ArtifactMetadata extends org.apache.maven.repository.legacy.metadata.ArtifactMetadata
+public interface DependencyCollectorDelegate extends DependencyCollector
{
- File getFile();
}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java
similarity index 97%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java
index 23baf51..041a613 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolver.java
@@ -1,81 +1,81 @@
-package org.apache.maven.shared.transfer.dependencies.resolve;
-
-/*
- * 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.model.Dependency;
-import org.apache.maven.model.Model;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
-import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
-import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
-
-/**
- * @author Robert Scholte
- */
-public interface DependencyResolver
-{
- /**
- * This will resolve the dependencies of the coordinate, not resolving the the artifact of the coordinate itself. If
- * the coordinate needs to be resolved too, use
- * {@link #resolveDependencies(ProjectBuildingRequest, Collection, Collection, TransformableFilter)} passing
- * {@code Collections.singletonList(coordinate)}
- *
- * @param buildingRequest {@link ProjectBuildingRequest}
- * @param coordinate {@link DependableCoordinate}
- * @param filter {@link TransformableFilter} (can be {@code null}).
- * @return the resolved dependencies.
- * @throws DependencyResolverException in case of an error.
- */
- Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest,
- DependableCoordinate coordinate, TransformableFilter filter )
- throws DependencyResolverException;
-
- /**
- * This will resolve the dependencies of the coordinate, not resolving the the artifact of the coordinate itself. If
- * the coordinate needs to be resolved too, use
- * {@link #resolveDependencies(ProjectBuildingRequest, Collection, Collection, TransformableFilter)} passing
- * {@code Collections.singletonList(coordinate)}
- *
- * @param buildingRequest {@link ProjectBuildingRequest}
- * @param model {@link Model}
- * @param filter {@link TransformableFilter} (can be {@code null}).
- * @return the resolved dependencies.
- * @throws DependencyResolverException in case of an error.
- */
- Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest, Model model,
- TransformableFilter filter )
- throws DependencyResolverException;
-
- /**
- * @param buildingRequest the project building request, never {@code null}
- * @param dependencies the dependencies to resolve, can be {@code null}
- * @param managedDependencies managed dependencies, can be {@code null}
- * @param filter a filter, can be {@code null}
- * @return the resolved dependencies.
- * @throws DependencyResolverException in case of an error.
- */
- Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest,
- Collection<Dependency> dependencies,
- Collection<Dependency> managedDependencies,
- TransformableFilter filter )
- throws DependencyResolverException;
-}
+package org.apache.maven.shared.transfer.dependencies.resolve;
+
+/*
+ * 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.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+
+/**
+ * @author Robert Scholte
+ */
+public interface DependencyResolver
+{
+ /**
+ * This will resolve the dependencies of the coordinate, not resolving the the artifact of the coordinate itself. If
+ * the coordinate needs to be resolved too, use
+ * {@link #resolveDependencies(ProjectBuildingRequest, Collection, Collection, TransformableFilter)} passing
+ * {@code Collections.singletonList(coordinate)}
+ *
+ * @param buildingRequest {@link ProjectBuildingRequest}
+ * @param coordinate {@link DependableCoordinate}
+ * @param filter {@link TransformableFilter} (can be {@code null}).
+ * @return the resolved dependencies.
+ * @throws DependencyResolverException in case of an error.
+ */
+ Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest,
+ DependableCoordinate coordinate, TransformableFilter filter )
+ throws DependencyResolverException;
+
+ /**
+ * This will resolve the dependencies of the coordinate, not resolving the the artifact of the coordinate itself. If
+ * the coordinate needs to be resolved too, use
+ * {@link #resolveDependencies(ProjectBuildingRequest, Collection, Collection, TransformableFilter)} passing
+ * {@code Collections.singletonList(coordinate)}
+ *
+ * @param buildingRequest {@link ProjectBuildingRequest}
+ * @param model {@link Model}
+ * @param filter {@link TransformableFilter} (can be {@code null}).
+ * @return the resolved dependencies.
+ * @throws DependencyResolverException in case of an error.
+ */
+ Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest, Model model,
+ TransformableFilter filter )
+ throws DependencyResolverException;
+
+ /**
+ * @param buildingRequest the project building request, never {@code null}
+ * @param dependencies the dependencies to resolve, can be {@code null}
+ * @param managedDependencies managed dependencies, can be {@code null}
+ * @param filter a filter, can be {@code null}
+ * @return the resolved dependencies.
+ * @throws DependencyResolverException in case of an error.
+ */
+ Iterable<ArtifactResult> resolveDependencies( ProjectBuildingRequest buildingRequest,
+ Collection<Dependency> dependencies,
+ Collection<Dependency> managedDependencies,
+ TransformableFilter filter )
+ throws DependencyResolverException;
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java
similarity index 96%
rename from src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java
rename to maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java
index 0235cdf..d6ca1ac 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java
+++ b/maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/dependencies/resolve/DependencyResolverException.java
@@ -1,54 +1,54 @@
-package org.apache.maven.shared.transfer.dependencies.resolve;
-
-/*
- * 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.
- */
-
-/**
- * The Exception class in case a resolving does not work.
- */
-public class DependencyResolverException
- extends Exception
-{
- private static final long serialVersionUID = 5320065249974323888L;
-
- /**
- * @param cause The {@link Exception cause} of the problem.
- */
- protected DependencyResolverException( Exception cause )
- {
- super( cause );
- }
-
- /**
- * @param message The message to give.
- * @param e The {@link Exception}.
- */
- public DependencyResolverException( String message, Exception e )
- {
- super( message, e );
- }
-
- /**
- * @return {@link DependencyResult}
- */
- public DependencyResult getResult()
- {
- return null;
- }
-}
+package org.apache.maven.shared.transfer.dependencies.resolve;
+
+/*
+ * 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.
+ */
+
+/**
+ * The Exception class in case a resolving does not work.
+ */
+public class DependencyResolverException
+ extends Exception
... 5558 lines suppressed ...