Search in sources :

Example 21 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project druid by druid-io.

the class Initialization method getHadoopDependencyFilesToLoad.

/**
   * Find all the hadoop dependencies that should be loaded by druid
   *
   * @param hadoopDependencyCoordinates e.g.["org.apache.hadoop:hadoop-client:2.3.0"]
   * @param extensionsConfig            ExtensionsConfig configured by druid.extensions.xxx
   *
   * @return an array of hadoop dependency files that will be loaded by druid process
   */
public static File[] getHadoopDependencyFilesToLoad(List<String> hadoopDependencyCoordinates, ExtensionsConfig extensionsConfig) {
    final File rootHadoopDependenciesDir = new File(extensionsConfig.getHadoopDependenciesDir());
    if (rootHadoopDependenciesDir.exists() && !rootHadoopDependenciesDir.isDirectory()) {
        throw new ISE("Root Hadoop dependencies directory [%s] is not a directory!?", rootHadoopDependenciesDir);
    }
    final File[] hadoopDependenciesToLoad = new File[hadoopDependencyCoordinates.size()];
    int i = 0;
    for (final String coordinate : hadoopDependencyCoordinates) {
        final DefaultArtifact artifact = new DefaultArtifact(coordinate);
        final File hadoopDependencyDir = new File(rootHadoopDependenciesDir, artifact.getArtifactId());
        final File versionDir = new File(hadoopDependencyDir, artifact.getVersion());
        // find the hadoop dependency with the version specified in coordinate
        if (!hadoopDependencyDir.isDirectory() || !versionDir.isDirectory()) {
            throw new ISE(String.format("Hadoop dependency [%s] didn't exist!?", versionDir.getAbsolutePath()));
        }
        hadoopDependenciesToLoad[i++] = versionDir;
    }
    return hadoopDependenciesToLoad;
}
Also used : ISE(io.druid.java.util.common.ISE) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 22 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project grails-maven by grails.

the class AbstractGrailsMojo method resolveArtifactIds.

protected Collection<File> resolveArtifactIds(Collection<String> artifactIds) throws MojoExecutionException {
    Collection<ArtifactRequest> requests = new ArrayList<ArtifactRequest>();
    for (String artifactId : artifactIds) {
        ArtifactRequest request = new ArtifactRequest();
        request.setArtifact(new DefaultArtifact(artifactId));
        request.setRepositories(remoteRepos);
        getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos);
        requests.add(request);
    }
    Collection<File> files = new ArrayList<File>();
    try {
        List<ArtifactResult> result = repoSystem.resolveArtifacts(repoSession, requests);
        for (ArtifactResult artifactResult : result) {
            File file = artifactResult.getArtifact().getFile();
            files.add(file);
            getLog().debug("Resolved artifact " + artifactResult.getArtifact().getArtifactId() + " to " + file + " from " + artifactResult.getRepository());
        }
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
    return files;
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 23 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project pinpoint by naver.

the class DependencyResolver method getNewestVersion.

public String getNewestVersion(String groupId, String artifactId) throws VersionRangeResolutionException {
    Artifact artifact = new DefaultArtifact(groupId, artifactId, "jar", "[0,)");
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(artifact);
    rangeRequest.setRepositories(repositories);
    VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
    Version newestVersion = rangeResult.getHighestVersion();
    return newestVersion.toString();
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) Version(org.eclipse.aether.version.Version) VersionRangeRequest(org.eclipse.aether.resolution.VersionRangeRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 24 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project karaf by apache.

the class GenerateDescriptorMojo method processFeatureArtifact.

private void processFeatureArtifact(Features features, Feature feature, Map<Dependency, Feature> otherFeatures, Map<Feature, String> featureRepositories, Object artifact, Object parent, boolean add) throws MojoExecutionException, XMLStreamException, JAXBException, IOException {
    if (this.dependencyHelper.isArtifactAFeature(artifact) && FEATURE_CLASSIFIER.equals(this.dependencyHelper.getClassifier(artifact))) {
        File featuresFile = this.dependencyHelper.resolve(artifact, getLog());
        if (featuresFile == null || !featuresFile.exists()) {
            throw new MojoExecutionException("Cannot locate file for feature: " + artifact + " at " + featuresFile);
        }
        Features includedFeatures = readFeaturesFile(featuresFile);
        for (String repository : includedFeatures.getRepository()) {
            processFeatureArtifact(features, feature, otherFeatures, featureRepositories, new DefaultArtifact(MavenUtil.mvnToAether(repository)), parent, false);
        }
        for (Feature includedFeature : includedFeatures.getFeature()) {
            Dependency dependency = new Dependency(includedFeature.getName(), includedFeature.getVersion());
            dependency.setPrerequisite(prerequisiteFeatures.contains(dependency.getName()));
            dependency.setDependency(dependencyFeatures.contains(dependency.getName()));
            // Determine what dependency we're actually going to use
            Dependency matchingDependency = findMatchingDependency(feature.getFeature(), dependency);
            if (matchingDependency != null) {
                // The feature already has a matching dependency, merge
                mergeDependencies(matchingDependency, dependency);
                dependency = matchingDependency;
            }
            // We mustn't de-duplicate here, we may have seen a feature in !add mode
            otherFeatures.put(dependency, includedFeature);
            if (add) {
                if (!feature.getFeature().contains(dependency)) {
                    feature.getFeature().add(dependency);
                }
                if (aggregateFeatures) {
                    features.getFeature().add(includedFeature);
                }
            }
            if (!featureRepositories.containsKey(includedFeature)) {
                featureRepositories.put(includedFeature, this.dependencyHelper.artifactToMvn(artifact, getVersionOrRange(parent, artifact)));
            }
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Features(org.apache.karaf.features.internal.model.Features) Dependency(org.apache.karaf.features.internal.model.Dependency) LocalDependency(org.apache.karaf.tooling.utils.LocalDependency) ConfigFile(org.apache.karaf.features.internal.model.ConfigFile) File(java.io.File) Feature(org.apache.karaf.features.internal.model.Feature) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 25 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project karaf by apache.

the class Dependency31Helper method mvnToArtifact.

@Override
public org.apache.maven.artifact.Artifact mvnToArtifact(String name) throws MojoExecutionException {
    name = MavenUtil.mvnToAether(name);
    DefaultArtifact artifact = new DefaultArtifact(name);
    org.apache.maven.artifact.Artifact mavenArtifact = toArtifact(artifact);
    return mavenArtifact;
}
Also used : DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)29 Artifact (org.eclipse.aether.artifact.Artifact)13 File (java.io.File)10 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)8 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)7 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)7 IOException (java.io.IOException)5 Dependency (org.eclipse.aether.graph.Dependency)5 Path (java.nio.file.Path)4 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)4 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)4 Test (org.junit.Test)4 MavenVersion (aQute.bnd.version.MavenVersion)3 Rule (com.google.devtools.build.workspace.maven.Rule)3 ArrayList (java.util.ArrayList)3 RepositorySystem (org.eclipse.aether.RepositorySystem)3 CollectRequest (org.eclipse.aether.collection.CollectRequest)3 VersionRangeRequest (org.eclipse.aether.resolution.VersionRangeRequest)3 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)3 Version (org.eclipse.aether.version.Version)3