diff --git a/pom.xml b/pom.xml
index 8c48569..8cff805 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,9 +23,9 @@
- 1.13.1
- 3.0.4
-
+ 3.9.9
+ 1.9.22
+ 1.7.36
true
@@ -41,188 +41,225 @@
resolver
${project.version}
-
-
- org.sonatype.aether
- aether-spi
- ${dep.aether.version}
-
-
- org.sonatype.aether
- aether-api
- ${dep.aether.version}
+ org.slf4j
+ slf4j-api
+ ${dep.slf4j.version}
-
- org.sonatype.aether
- aether-impl
- ${dep.aether.version}
+ commons-codec
+ commons-codec
+ 1.15
-
- org.sonatype.aether
- aether-util
- ${dep.aether.version}
+ org.slf4j
+ jcl-over-slf4j
+ ${dep.slf4j.version}
-
- org.sonatype.aether
- aether-connector-file
- ${dep.aether.version}
-
-
-
- org.sonatype.aether
- aether-connector-asynchttpclient
- ${dep.aether.version}
+ org.apache.maven
+ maven-compat
+ ${dep.maven.version}
- org.jboss.netty
- netty
+ org.codehaus.plexus
+ plexus-classworlds
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.plexus
+
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+
+
+ com.google.guava
+ guava
+
+
-
- io.netty
- netty
- 3.6.2.Final
+ org.apache.maven.resolver
+ maven-resolver-transport-file
+ ${dep.maven.resolver.version}
-
- org.apache.maven
- maven-core
- ${dep.maven.version}
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+ ${dep.maven.resolver.version}
- org.sonatype.sisu
- sisu-inject-plexus
+ commons-codec
+ commons-codec
-
-
- org.apache.maven
- maven-model
- ${dep.maven.version}
-
-
- org.apache.maven
- maven-artifact
- ${dep.maven.version}
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+ ${dep.maven.resolver.version}
-
- org.apache.maven
- maven-aether-provider
- ${dep.maven.version}
+ org.slf4j
+ slf4j-nop
+ ${dep.slf4j.version}
+ test
-
org.apache.maven
- maven-embedder
+ maven-core
${dep.maven.version}
- org.sonatype.sisu
- sisu-inject-plexus
+ org.eclipse.sisu
+ org.eclipse.sisu.plexus
- commons-cli
- commons-cli
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+
+
+ com.google.guava
+ guava
-
- org.codehaus.plexus
- plexus-container-default
- 1.5.5
+ junit
+ junit
+ 4.13.2
+ test
+
+
+ com.google.guava
+ guava
+ 33.1.0-jre
- commons-logging
- commons-logging-api
-
-
- com.google.collections
- google-collections
+ error_prone_annotations
+ com.google.errorprone
- junit
- junit
+ com.google.j2objc
+ j2objc-annotations
+
+
+
+ com.google.inject
+ guice
+ 5.1.0
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.5.1
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.plexus
+ 0.3.5
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+ 0.3.5
+
- log4j
- log4j
+ org.codehaus.plexus
+ plexus-classworlds
-
org.codehaus.plexus
plexus-classworlds
- 2.4
+ 2.8.0
+
+
-
-
-
- com.ning.maven.plugins
- maven-duplicate-finder-plugin
-
-
-
-
-
- aopalliance
- aopalliance
-
-
- org.sonatype.sisu
- sisu-inject-bean
-
-
-
- org.aopalliance.aop.Advice
- org.aopalliance.aop.AspectException
- org.aopalliance.intercept.ConstructorInterceptor
- org.aopalliance.intercept.ConstructorInvocation
- org.aopalliance.intercept.Interceptor
- org.aopalliance.intercept.Invocation
- org.aopalliance.intercept.Joinpoint
- org.aopalliance.intercept.MethodInterceptor
- org.aopalliance.intercept.MethodInvocation
-
-
-
-
-
- javax.inject
- javax.inject
-
-
- org.sonatype.sisu
- sisu-inject-bean
-
-
-
- javax.inject.Inject
- javax.inject.Named
- javax.inject.Provider
- javax.inject.Qualifier
- javax.inject.Scope
- javax.inject.Singleton
-
-
-
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+
+ org.apache.maven:maven-artifact
+ org.apache.maven:maven-model
+ org.apache.maven:maven-resolver-provider
+ org.apache.maven.resolver:maven-resolver-api
+ org.apache.maven.resolver:maven-resolver-impl
+ org.apache.maven:maven-model-builder
+ org.apache.maven.resolver:maven-resolver-util
+ org.apache.maven.resolver:maven-resolver-spi
+
+
+ org.apache.maven:maven-compat
+
+
+
+
+
+
+ org.basepom.maven
+ duplicate-finder-maven-plugin
+
+
+
+
+
+ org.codehaus.plexus
+ plexus-utils
+
+
+ org.codehaus.plexus
+ plexus-xml
+
+
+
+ org.codehaus.plexus.util.xml.CompactXMLWriter
+ org.codehaus.plexus.util.xml.PrettyPrintXMLWriter
+ org.codehaus.plexus.util.xml.SerializerXMLWriter
+ org.codehaus.plexus.util.xml.XmlReader
+ org.codehaus.plexus.util.xml.XmlReaderException
+ org.codehaus.plexus.util.xml.XmlStreamReader
+ org.codehaus.plexus.util.xml.XmlStreamReaderException
+ org.codehaus.plexus.util.xml.XmlStreamWriter
+ org.codehaus.plexus.util.xml.XmlUtil
+ org.codehaus.plexus.util.xml.XMLWriter
+ org.codehaus.plexus.util.xml.XmlWriterUtil
+ org.codehaus.plexus.util.xml.Xpp3Dom
+ org.codehaus.plexus.util.xml.Xpp3DomBuilder
+ org.codehaus.plexus.util.xml.Xpp3DomUtils
+ org.codehaus.plexus.util.xml.Xpp3DomWriter
+ org.codehaus.plexus.util.xml.pull.EntityReplacementMap
+ org.codehaus.plexus.util.xml.pull.MXParser
+ org.codehaus.plexus.util.xml.pull.MXSerializer
+ org.codehaus.plexus.util.xml.pull.XmlPullParser
+ org.codehaus.plexus.util.xml.pull.XmlPullParserException
+ org.codehaus.plexus.util.xml.pull.XmlSerializer
+
+
+
+
+ javac.sh
+ about.html
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M7
+
+
diff --git a/resolver-integration/pom.xml b/resolver-integration/pom.xml
index a4b4782..1a0609d 100644
--- a/resolver-integration/pom.xml
+++ b/resolver-integration/pom.xml
@@ -7,7 +7,6 @@
1.7-SNAPSHOT
- io.airlift.resolver
resolver-integration
jar
@@ -24,17 +23,10 @@
- org.testng
- testng
+ junit
+ junit
test
-
-
- org.sonatype.aether
- aether-api
- test
-
-
org.slf4j
slf4j-nop
diff --git a/resolver-integration/src/test/java/io/airlift/resolver/TestArtifactResolve.java b/resolver-integration/src/test/java/io/airlift/resolver/TestArtifactResolve.java
index 42cea0a..47395a2 100644
--- a/resolver-integration/src/test/java/io/airlift/resolver/TestArtifactResolve.java
+++ b/resolver-integration/src/test/java/io/airlift/resolver/TestArtifactResolve.java
@@ -13,9 +13,11 @@
*/
package io.airlift.resolver;
-import org.sonatype.aether.artifact.Artifact;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.junit.Assert;
+import org.junit.Test;
import java.io.File;
import java.util.List;
@@ -32,9 +34,9 @@ public void testResolveArtifacts()
ArtifactResolver artifactResolver = new ArtifactResolver("target/local-repo", MAVEN_CENTRAL_URI);
List artifacts = artifactResolver.resolveArtifacts(new DefaultArtifact("org.apache.maven:maven-core:3.0.4"));
- Assert.assertNotNull(artifacts, "artifacts is null");
+ Assert.assertNotNull("artifacts is null", artifacts);
for (Artifact artifact : artifacts) {
- Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved");
+ Assert.assertNotNull("Artifact " + artifact + " is not resolved", artifact.getFile());
}
}
@@ -47,9 +49,9 @@ public void testResolvePom()
ArtifactResolver artifactResolver = new ArtifactResolver("target/local-repo", MAVEN_CENTRAL_URI);
List artifacts = artifactResolver.resolvePom(pomFile);
- Assert.assertNotNull(artifacts, "artifacts is null");
+ Assert.assertNotNull("artifacts is null", artifacts);
for (Artifact artifact : artifacts) {
- Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved");
+ Assert.assertNotNull("Artifact " + artifact + " is not resolved", artifact.getFile());
}
}
}
diff --git a/resolver/pom.xml b/resolver/pom.xml
index 248c347..dc4b767 100644
--- a/resolver/pom.xml
+++ b/resolver/pom.xml
@@ -7,111 +7,48 @@
1.7-SNAPSHOT
- io.airlift.resolver
resolver
-
- ${project.parent.basedir}
-
-
- org.sonatype.aether
- aether-spi
-
-
-
- org.sonatype.aether
- aether-api
-
-
-
- org.sonatype.aether
- aether-impl
-
-
-
- org.sonatype.aether
- aether-util
-
-
-
- org.sonatype.aether
- aether-connector-file
-
-
-
- org.sonatype.aether
- aether-connector-asynchttpclient
-
-
-
- io.netty
- netty
- runtime
+ org.slf4j
+ slf4j-api
-
org.apache.maven
- maven-core
+ maven-compat
-
- org.apache.maven
- maven-model
+ org.apache.maven.resolver
+ maven-resolver-transport-file
-
- org.apache.maven
- maven-artifact
+ org.apache.maven.resolver
+ maven-resolver-transport-http
-
- org.apache.maven
- maven-aether-provider
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
-
org.apache.maven
- maven-embedder
- runtime
+ maven-core
-
- org.codehaus.plexus
- plexus-container-default
+ org.eclipse.sisu
+ org.eclipse.sisu.plexus
-
org.codehaus.plexus
plexus-classworlds
-
-
- com.google.inject
- guice
- runtime
-
-
com.google.guava
guava
-
-
- org.slf4j
- slf4j-api
-
-
-
- org.testng
- testng
- test
-
-
- org.slf4j
- slf4j-nop
+ junit
+ junit
test
diff --git a/resolver/src/main/java/io/airlift/resolver/ArtifactResolver.java b/resolver/src/main/java/io/airlift/resolver/ArtifactResolver.java
index b21e431..8baa0d7 100644
--- a/resolver/src/main/java/io/airlift/resolver/ArtifactResolver.java
+++ b/resolver/src/main/java/io/airlift/resolver/ArtifactResolver.java
@@ -13,54 +13,57 @@
*/
package io.airlift.resolver;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Stream;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.airlift.resolver.internal.ConsoleRepositoryListener;
import io.airlift.resolver.internal.ConsoleTransferListener;
-import io.airlift.resolver.internal.Slf4jLoggerManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
-import org.apache.maven.repository.internal.MavenServiceLocator;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.logging.Logger;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.connector.async.AsyncRepositoryConnectorFactory;
-import org.sonatype.aether.connector.file.FileRepositoryConnectorFactory;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
-import org.sonatype.aether.repository.LocalRepositoryManager;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.resolution.DependencyRequest;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.resolution.DependencyResult;
-import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
-import org.sonatype.aether.util.filter.DependencyFilterUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Stream;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.Exclusion;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResult;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.transport.file.FileTransporterFactory;
+import org.eclipse.aether.transport.http.HttpTransporterFactory;
+import org.eclipse.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.util.filter.DependencyFilterUtils;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.lang.String.format;
@@ -69,17 +72,18 @@
public class ArtifactResolver
{
+
public static final String USER_LOCAL_REPO = System.getProperty("user.home") + "/.m2/repository";
public static final String MAVEN_CENTRAL_URI = "https://repo1.maven.org/maven2/";
- public static final Set DEPRECATED_MAVEN_CENTRAL_URIS = ImmutableSet.builder()
- .add("http://repo1.maven.org/maven2")
- .add("http://repo1.maven.org/maven2/")
- .add("http://repo.maven.apache.org/maven2")
- .add("http://repo.maven.apache.org/maven2/")
- .build();
+ public static final Set DEPRECATED_MAVEN_CENTRAL_URIS = ImmutableSet.of(
+ "http://repo1.maven.org/maven2",
+ "http://repo1.maven.org/maven2/",
+ "http://repo.maven.apache.org/maven2",
+ "http://repo.maven.apache.org/maven2/"
+ );
private final RepositorySystem repositorySystem;
- private final MavenRepositorySystemSession repositorySystemSession;
+ private final DefaultRepositorySystemSession repositorySystemSession;
private final List repositories;
public ArtifactResolver(String localRepositoryDir, String... remoteRepositoryUris)
@@ -89,14 +93,15 @@ public ArtifactResolver(String localRepositoryDir, String... remoteRepositoryUri
public ArtifactResolver(String localRepositoryDir, List remoteRepositoryUris)
{
- MavenServiceLocator locator = new MavenServiceLocator();
- locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
- locator.addService(RepositoryConnectorFactory.class, AsyncRepositoryConnectorFactory.class);
+ DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
+ locator.addService(TransporterFactory.class, FileTransporterFactory.class);
+ locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
+ locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
repositorySystem = locator.getService(RepositorySystem.class);
- repositorySystemSession = new MavenRepositorySystemSession();
-
- LocalRepositoryManager localRepositoryManager = new SimpleLocalRepositoryManager(localRepositoryDir);
+ repositorySystemSession = MavenRepositorySystemUtils.newSession();
+ LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(
+ repositorySystemSession, new LocalRepository(localRepositoryDir));
repositorySystemSession.setLocalRepositoryManager(localRepositoryManager);
repositorySystemSession.setTransferListener(new ConsoleTransferListener());
@@ -105,11 +110,12 @@ public ArtifactResolver(String localRepositoryDir, List remoteRepository
List repositories = new ArrayList<>(remoteRepositoryUris.size());
int index = 0;
for (String repositoryUri : remoteRepositoryUris) {
- repositories.add(new RemoteRepository("repo-" + index++, "default", repositoryUri));
+ repositories.add(new RemoteRepository.Builder("repo-" + index++, "default", repositoryUri).build());
}
this.repositories = Collections.unmodifiableList(repositories);
}
+
public List resolveArtifacts(Artifact... sourceArtifacts)
{
return resolveArtifacts(Arrays.asList(sourceArtifacts));
@@ -124,7 +130,8 @@ public List resolveArtifacts(Iterable extends Artifact> sourceArtifa
for (RemoteRepository repository : repositories) {
// Hack: avoid using deprecated Maven Central URLs
if (DEPRECATED_MAVEN_CENTRAL_URIS.contains(repository.getUrl())) {
- repository = new RemoteRepository(repository.getId(), repository.getContentType(), MAVEN_CENTRAL_URI);
+ repository = new RemoteRepository.Builder(repository.getId(),
+ repository.getContentType(), MAVEN_CENTRAL_URI).build();
}
collectRequest.addRepository(repository);
}
@@ -134,6 +141,7 @@ public List resolveArtifacts(Iterable extends Artifact> sourceArtifa
return resolveArtifacts(dependencyRequest);
}
+
public List resolvePom(File pomFile)
{
if (pomFile == null) {
@@ -153,13 +161,15 @@ public List resolvePom(File pomFile)
ImmutableList.Builder allRepositories = ImmutableList.builder();
for (RemoteRepository repository : pom.getRemoteProjectRepositories()) {
if (DEPRECATED_MAVEN_CENTRAL_URIS.contains(repository.getUrl())) {
- repository = new RemoteRepository(repository.getId(), repository.getContentType(), MAVEN_CENTRAL_URI);
+ repository = new RemoteRepository.Builder(repository.getId(),
+ repository.getContentType(), MAVEN_CENTRAL_URI).build();
}
allRepositories.add(repository);
}
for (RemoteRepository repository : repositories) {
if (DEPRECATED_MAVEN_CENTRAL_URIS.contains(repository.getUrl())) {
- repository = new RemoteRepository(repository.getId(), repository.getContentType(), MAVEN_CENTRAL_URI);
+ repository = new RemoteRepository.Builder(repository.getId(),
+ repository.getContentType(), MAVEN_CENTRAL_URI).build();
}
allRepositories.add(repository);
}
@@ -185,12 +195,14 @@ public List resolvePom(File pomFile)
.collect(toImmutableList());
}
+
private MavenProject getMavenProject(File pomFile)
{
try {
PlexusContainer container = container();
- org.apache.maven.repository.RepositorySystem lrs = container.lookup(org.apache.maven.repository.RepositorySystem.class);
+
ProjectBuilder projectBuilder = container.lookup(ProjectBuilder.class);
+ org.apache.maven.repository.RepositorySystem lrs = container.lookup(org.apache.maven.repository.RepositorySystem.class);
ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
request.setSystemProperties(requiredSystemProperties());
request.setRepositorySession(repositorySystemSession);
@@ -266,7 +278,7 @@ private List resolveArtifacts(DependencyRequest dependencyRequest)
try {
dependencyResult = repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
}
- catch (DependencyResolutionException e) {
+ catch (org.eclipse.aether.resolution.DependencyResolutionException e) {
dependencyResult = e.getResult();
}
List artifactResults = dependencyResult.getArtifactResults();
@@ -291,14 +303,15 @@ private static PlexusContainer container()
ContainerConfiguration cc = new DefaultContainerConfiguration()
.setClassWorld(classWorld)
.setRealm(null)
- .setName("maven");
+ .setName("maven")
+ .setClassPathScanning(PlexusConstants.SCANNING_INDEX)
+ .setAutoWiring(true);
DefaultPlexusContainer container = new DefaultPlexusContainer(cc);
// NOTE: To avoid inconsistencies, we'll use the Thread context class loader exclusively for lookups
container.setLookupRealm(null);
- container.setLoggerManager(new Slf4jLoggerManager());
container.getLoggerManager().setThresholds(Logger.LEVEL_INFO);
return container;
@@ -307,4 +320,11 @@ private static PlexusContainer container()
throw new RuntimeException("Error loading Maven system", e);
}
}
+
+ public static ComponentDescriptor getDescriptor(Class> interfaced, Class implementation) {
+ ComponentDescriptor descriptor = new ComponentDescriptor<>();
+ descriptor.setRole(interfaced.getName());
+ descriptor.setImplementationClass(implementation);
+ return descriptor;
+ }
}
diff --git a/resolver/src/main/java/io/airlift/resolver/DefaultArtifact.java b/resolver/src/main/java/io/airlift/resolver/DefaultArtifact.java
deleted file mode 100644
index 7a11091..0000000
--- a/resolver/src/main/java/io/airlift/resolver/DefaultArtifact.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.airlift.resolver;
-
-/*******************************************************************************
- * Copyright (c) 2010-2011 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-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.LinkedHashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A simple artifact. Note: Instances of this class are immutable and the exposed mutators return new objects
- * rather than changing the current instance.
- *
- * @author Benjamin Bentmann
- */
-public final class DefaultArtifact
- implements Artifact
-{
- private static final String SNAPSHOT = "SNAPSHOT";
- private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
-
- 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 properties;
- private String baseVersion;
-
- /**
- * Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the
- * artifact's extension defaults to {@code jar} and classifier to an empty string.
- *
- * @param coords The artifact coordinates in the format
- * {@code :[:[:]]:}, must not be {@code null}.
- */
- public DefaultArtifact(String coords)
- {
- this(coords, Collections.emptyMap());
- }
-
- /**
- * Creates a new artifact with the specified coordinates and properties. If not specified in the artifact
- * coordinates, the artifact's extension defaults to {@code jar} and classifier to an empty string.
- *
- * @param coords The artifact coordinates in the format
- * {@code :[:[:]]:}, must not be {@code null}.
- * @param properties The artifact properties, may be {@code null}.
- */
- public DefaultArtifact(String coords, Map properties)
- {
- Pattern p = Pattern.compile("([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)");
- Matcher m = p.matcher(coords);
- if (!m.matches()) {
- throw new IllegalArgumentException("Bad artifact coordinates " + coords
- + ", expected format is :[:[:]]:");
- }
- this.groupId = m.group(1);
- this.artifactId = m.group(2);
- this.extension = get(m.group(4), "jar");
- this.classifier = get(m.group(6), "");
- this.version = m.group(7);
- this.file = null;
- this.properties = Collections.unmodifiableMap(new LinkedHashMap<>(properties));
- }
-
- private static String get(String value, String defaultValue)
- {
- return (value == null || value.length() <= 0) ? defaultValue : value;
- }
-
- /**
- * Creates a new artifact with the specified coordinates and no classifier. Passing {@code null} for any of the
- * coordinates is equivalent to specifying an empty string.
- *
- * @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. Passing {@code null} for any of the coordinates is
- * equivalent to specifying an empty string.
- *
- * @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. Passing {@code null} for any of the coordinates is
- * equivalent to specifying an empty string. 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. Passing {@code null} for any of the
- * coordinates is equivalent to specifying an empty string. 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} if none.
- * @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 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 merge(Map dominant, Map recessive)
- {
- Map properties;
-
- if ((dominant == null || dominant.isEmpty()) && (recessive == null || recessive.isEmpty())) {
- properties = Collections.emptyMap();
- }
- else {
- properties = new HashMap<>();
- 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. Passing {@code null} for any of the
- * coordinates is equivalent to specifying an empty string.
- *
- * @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} if none.
- * @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 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;
- this.properties = Collections.unmodifiableMap(new LinkedHashMap<>(properties));
- }
-
- DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, File file,
- Map 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;
- }
-
- @Override
- public String getGroupId()
- {
- return groupId;
- }
-
- @Override
- public String getArtifactId()
- {
- return artifactId;
- }
-
- @Override
- public String getBaseVersion()
- {
- if (baseVersion == null) {
- baseVersion = toBaseVersion(getVersion());
- }
- return baseVersion;
- }
-
- @Override
- public String getVersion()
- {
- return version;
- }
-
- @Override
- 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);
- }
-
- @Override
- public boolean isSnapshot()
- {
- return version.endsWith(SNAPSHOT) || SNAPSHOT_TIMESTAMP.matcher(version).matches();
- }
-
- @Override
- public String getClassifier()
- {
- return classifier;
- }
-
- @Override
- public String getExtension()
- {
- return extension;
- }
-
- @Override
- public File getFile()
- {
- return file;
- }
-
- @Override
- 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);
- }
-
- @Override
- public String getProperty(String key, String defaultValue)
- {
- String value = properties.get(key);
- return (value != null) ? value : defaultValue;
- }
-
- @Override
- public Map getProperties()
- {
- return Collections.unmodifiableMap(properties);
- }
-
- @Override
- public Artifact setProperties(Map properties)
- {
- if (this.properties.equals(properties) || (properties == null && this.properties.isEmpty())) {
- return this;
- }
- return new DefaultArtifact(groupId, artifactId, classifier, extension, version, file, Collections.unmodifiableMap(new LinkedHashMap<>(properties)));
- }
-
- protected static String toBaseVersion(String version)
- {
- if (version == null) {
- return version;
- }
-
- if (version.startsWith("[") || version.startsWith("(")) {
- return version;
- }
-
- Matcher m = SNAPSHOT_TIMESTAMP.matcher(version);
- if (!m.matches()) {
- return version;
- }
-
- if (m.group(1) == null) {
- return SNAPSHOT;
- }
-
- return m.group(1) + SNAPSHOT;
- }
-}
diff --git a/resolver/src/main/java/io/airlift/resolver/Main.java b/resolver/src/main/java/io/airlift/resolver/Main.java
index fe53281..b9b495a 100644
--- a/resolver/src/main/java/io/airlift/resolver/Main.java
+++ b/resolver/src/main/java/io/airlift/resolver/Main.java
@@ -13,7 +13,9 @@
*/
package io.airlift.resolver;
-import org.sonatype.aether.artifact.Artifact;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
import java.io.File;
import java.util.ArrayList;
diff --git a/resolver/src/main/java/io/airlift/resolver/internal/ConsoleRepositoryListener.java b/resolver/src/main/java/io/airlift/resolver/internal/ConsoleRepositoryListener.java
index 13e39cc..169f72a 100644
--- a/resolver/src/main/java/io/airlift/resolver/internal/ConsoleRepositoryListener.java
+++ b/resolver/src/main/java/io/airlift/resolver/internal/ConsoleRepositoryListener.java
@@ -13,10 +13,11 @@
*/
package io.airlift.resolver.internal;
+import org.eclipse.aether.AbstractRepositoryListener;
+import org.eclipse.aether.RepositoryEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonatype.aether.AbstractRepositoryListener;
-import org.sonatype.aether.RepositoryEvent;
+
/**
* A simplistic repository listener that logs events to the console.
diff --git a/resolver/src/main/java/io/airlift/resolver/internal/ConsoleTransferListener.java b/resolver/src/main/java/io/airlift/resolver/internal/ConsoleTransferListener.java
index c6fa1ad..9d35c81 100644
--- a/resolver/src/main/java/io/airlift/resolver/internal/ConsoleTransferListener.java
+++ b/resolver/src/main/java/io/airlift/resolver/internal/ConsoleTransferListener.java
@@ -13,11 +13,12 @@
*/
package io.airlift.resolver.internal;
+import org.eclipse.aether.transfer.TransferCancelledException;
+import org.eclipse.aether.transfer.TransferEvent;
+import org.eclipse.aether.transfer.TransferListener;
+import org.eclipse.aether.transfer.TransferResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonatype.aether.transfer.AbstractTransferListener;
-import org.sonatype.aether.transfer.TransferEvent;
-import org.sonatype.aether.transfer.TransferResource;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
@@ -27,8 +28,7 @@
* A simplistic transfer listener that logs uploads/downloads.
*/
public class ConsoleTransferListener
- extends AbstractTransferListener
-{
+ implements TransferListener {
private final Logger logger;
public ConsoleTransferListener()
@@ -49,6 +49,11 @@ public void transferInitiated(TransferEvent event)
logger.debug(message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
}
+ @Override
+ public void transferStarted(TransferEvent transferEvent) throws TransferCancelledException {
+
+ }
+
@Override
public void transferProgressed(TransferEvent event)
{
diff --git a/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLogger.java b/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLogger.java
deleted file mode 100644
index 1c3df09..0000000
--- a/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLogger.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package io.airlift.resolver.internal;
-
-import org.codehaus.plexus.logging.Logger;
-
-/**
- * Adapt an SLF4J logger to a Plexus logger, ignoring Plexus logger API parts that are not classical and
- * probably not really used.
- *
- * @author Jason van Zyl
- */
-public class Slf4jLogger
- implements Logger
-{
- private final org.slf4j.Logger logger;
-
- public Slf4jLogger(org.slf4j.Logger logger)
- {
- this.logger = logger;
- }
-
- public void debug(String message)
- {
- logger.debug(message);
- }
-
- public void debug(String message, Throwable throwable)
- {
- logger.debug(message, throwable);
- }
-
- public boolean isDebugEnabled()
- {
- return logger.isDebugEnabled();
- }
-
- public void info(String message)
- {
- logger.info(message);
- }
-
- public void info(String message, Throwable throwable)
- {
- logger.info(message, throwable);
- }
-
- public boolean isInfoEnabled()
- {
- return logger.isInfoEnabled();
- }
-
- public void warn(String message)
- {
- logger.warn(message);
- }
-
- public void warn(String message, Throwable throwable)
- {
- logger.warn(message, throwable);
- }
-
- public boolean isWarnEnabled()
- {
- return logger.isWarnEnabled();
- }
-
- public void error(String message)
- {
- logger.error(message);
- }
-
- public void error(String message, Throwable throwable)
- {
- logger.error(message, throwable);
- }
-
- public boolean isErrorEnabled()
- {
- return logger.isErrorEnabled();
- }
-
- public void fatalError(String message)
- {
- logger.error(message);
- }
-
- public void fatalError(String message, Throwable throwable)
- {
- logger.error(message, throwable);
- }
-
- public boolean isFatalErrorEnabled()
- {
- return logger.isErrorEnabled();
- }
-
- /**
- * Warning: ignored (always return 0 == Logger.LEVEL_DEBUG
).
- */
- public int getThreshold()
- {
- return 0;
- }
-
- /**
- * Warning: ignored.
- */
- public void setThreshold(int threshold)
- {
- }
-
- /**
- * Warning: ignored (always return null
).
- */
- public Logger getChildLogger(String name)
- {
- return null;
- }
-
- public String getName()
- {
- return logger.getName();
- }
-}
diff --git a/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLoggerManager.java b/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLoggerManager.java
deleted file mode 100644
index 7422b9e..0000000
--- a/resolver/src/main/java/io/airlift/resolver/internal/Slf4jLoggerManager.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package io.airlift.resolver.internal;
-
-import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.logging.LoggerManager;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.LoggerFactory;
-
-/**
- * Use an SLF4J {@link org.slf4j.ILoggerFactory} as a backing for a Plexus {@link org.codehaus.plexus.logging.LoggerManager},
- * ignoring Plexus logger API parts that are not classical and probably not really used.
- *
- * @author Jason van Zyl
- * @since 3.1
- */
-public class Slf4jLoggerManager
- implements LoggerManager
-{
- private final ILoggerFactory loggerFactory;
-
- public Slf4jLoggerManager()
- {
- loggerFactory = LoggerFactory.getILoggerFactory();
- }
-
- public Logger getLoggerForComponent(String role)
- {
- return new Slf4jLogger(loggerFactory.getLogger(role));
- }
-
- /**
- * The logger name for a component with a non-null hint is role.hint
.
- * Warning: this does not conform to logger name as class name convention.
- * (and what about null
and default
hint equivalence?)
- */
- public Logger getLoggerForComponent(String role, String hint)
- {
- return (null == hint
- ? getLoggerForComponent(role)
- : new Slf4jLogger(loggerFactory.getLogger(role + '.' + hint)));
- }
-
- //
- // Trying to give loggers back is a bad idea. Ceki said so :-)
- // notice to self: what was this method supposed to do?
- //
-
- /**
- * Warning: ignored.
- */
- @Override
- public void setThreshold(String role, int threshold)
- {
- }
-
- /**
- * Warning: ignored.
- */
- @Override
- public void setThreshold(String role, String roleHint, int threshold)
- {
- }
-
- /**
- * Warning: ignored.
- */
- @Override
- public int getThreshold(String role)
- {
- return 0;
- }
-
- /**
- * Warning: ignored.
- */
- @Override
- public int getThreshold(String role, String roleHint)
- {
- return 0;
- }
-
- /**
- * Warning: ignored.
- */
- public void returnComponentLogger(String role)
- {
- }
-
- /**
- * Warning: ignored.
- */
- public void returnComponentLogger(String role, String hint)
- {
- }
-
- /**
- * Warning: ignored (always return 0
).
- */
- public int getThreshold()
- {
- return 0;
- }
-
- /**
- * Warning: ignored.
- */
- public void setThreshold(int threshold)
- {
- }
-
- /**
- * Warning: ignored.
- */
- public void setThresholds(int threshold)
- {
- }
-
- /**
- * Warning: ignored (always return 0
).
- */
- public int getActiveLoggerCount()
- {
- return 0;
- }
-}
diff --git a/resolver/src/test/java/io/airlift/resolver/ArtifactResolverTest.java b/resolver/src/test/java/io/airlift/resolver/ArtifactResolverTest.java
index f59562b..1894983 100644
--- a/resolver/src/test/java/io/airlift/resolver/ArtifactResolverTest.java
+++ b/resolver/src/test/java/io/airlift/resolver/ArtifactResolverTest.java
@@ -14,11 +14,11 @@
package io.airlift.resolver;
import com.google.common.collect.ImmutableList;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.junit.Assert;
+import org.junit.Test;
import java.io.File;
import java.util.List;
@@ -27,7 +27,7 @@
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.airlift.resolver.ArtifactResolver.MAVEN_CENTRAL_URI;
import static io.airlift.resolver.ArtifactResolver.USER_LOCAL_REPO;
-import static org.testng.Assert.assertTrue;
+import static org.junit.Assert.assertTrue;
public class ArtifactResolverTest
{
@@ -38,9 +38,9 @@ public void testResolveArtifacts()
ArtifactResolver artifactResolver = new ArtifactResolver(USER_LOCAL_REPO, MAVEN_CENTRAL_URI);
List artifacts = artifactResolver.resolveArtifacts(ImmutableList.of(new DefaultArtifact("org.apache.maven:maven-core:3.0.4")));
- Assert.assertNotNull(artifacts, "artifacts is null");
+ Assert.assertNotNull("artifacts is null", artifacts);
for (Artifact artifact : artifacts) {
- Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved");
+ Assert.assertNotNull("Artifact " + artifact + " is not resolved", artifact.getFile());
}
}
@@ -49,14 +49,14 @@ public void testResolvePom()
throws DependencyResolutionException
{
File pomFile = new File("src/test/poms/maven-core-3.0.4.pom");
- Assert.assertTrue(pomFile.canRead());
+ assertTrue(pomFile.canRead());
ArtifactResolver artifactResolver = new ArtifactResolver(USER_LOCAL_REPO, MAVEN_CENTRAL_URI);
List artifacts = artifactResolver.resolvePom(pomFile);
- Assert.assertNotNull(artifacts, "artifacts is null");
+ Assert.assertNotNull("artifacts is null", artifacts);
for (Artifact artifact : artifacts) {
- Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved");
+ Assert.assertNotNull("Artifact " + artifact + " is not resolved", artifact.getFile());
}
}