X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.slc.support%2Fsrc%2Forg%2Fargeo%2Fslc%2Faether%2FAetherTemplate.java;fp=org.argeo.slc.support%2Fsrc%2Forg%2Fargeo%2Fslc%2Faether%2FAetherTemplate.java;h=0000000000000000000000000000000000000000;hb=b182eb6c94fc5a5f942091a57d8ec6fd9a782a58;hp=a83caa1e08d01674ca08363b6f02922a8b4b671d;hpb=f59056d0b805cb91f524671a28b8780338509ba4;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.support/src/org/argeo/slc/aether/AetherTemplate.java b/org.argeo.slc.support/src/org/argeo/slc/aether/AetherTemplate.java deleted file mode 100644 index a83caa1e0..000000000 --- a/org.argeo.slc.support/src/org/argeo/slc/aether/AetherTemplate.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2007-2012 Argeo GmbH - * - * 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 org.argeo.slc.aether; - -import java.io.File; -import java.util.List; - -import org.argeo.slc.SlcException; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.collection.CollectRequest; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactRequest; -import org.eclipse.aether.resolution.ArtifactResolutionException; -import org.eclipse.aether.resolution.ArtifactResult; - -/** Simplifies access to Aether. */ -public class AetherTemplate { - private RepositorySystem repositorySystem; - private RepositorySystemSession repositorySystemSession; - private List remoteRepositories; - - /** Resolves the artifact in order to give access to its file. */ - public File getResolvedFile(Artifact artifact) { - try { - ArtifactRequest artifactRequest = new ArtifactRequest(artifact, - remoteRepositories, null); - ArtifactResult result = repositorySystem.resolveArtifact( - repositorySystemSession, artifactRequest); - return result.getArtifact().getFile(); - } catch (ArtifactResolutionException e) { - throw new SlcException("Cannot resolve " + artifact, e); - } - } - - /** - * Transitively resolves the dependencies of this artifact (with scope - * 'compile') - * - * @param artifact - * the artifact to resolve - */ - public DependencyNode resolveDependencies(Artifact artifact) { - return resolveDependencies(artifact, "compile"); - } - - /** - * Transitively resolves the dependencies of this artifact. - * - * @param artifact - * the artifact to resolve - * @param scope - * the scope - */ - public DependencyNode resolveDependencies(Artifact artifact, String scope) { - try { - Dependency dependency = new Dependency(artifact, scope); - CollectRequest collectRequest = new CollectRequest(); - collectRequest.setRoot(dependency); - for (RemoteRepository remoteRepository : remoteRepositories) - collectRequest.addRepository(remoteRepository); - DependencyNode node = repositorySystem.collectDependencies( - repositorySystemSession, collectRequest).getRoot(); - - // FIXME adapt to changes in Aether - // repositorySystem.resolveDependencies(repositorySystemSession, - // node, - // null); - return node; - } catch (Exception e) { - throw new SlcException("Cannot resolve dependencies of " + artifact - + " (scope: " + scope + ")", e); - } - } - - public RepositorySystem getRepositorySystem() { - return repositorySystem; - } - - public void setRepositorySystem(RepositorySystem repositorySystem) { - this.repositorySystem = repositorySystem; - } - - public RepositorySystemSession getRepositorySystemSession() { - return repositorySystemSession; - } - - public void setRepositorySystemSession( - RepositorySystemSession repositorySystemSession) { - this.repositorySystemSession = repositorySystemSession; - } - - public List getRemoteRepositories() { - return remoteRepositories; - } - - public void setRemoteRepositories(List remoteRepositories) { - this.remoteRepositories = remoteRepositories; - } - -}