Example usage for org.apache.maven.artifact.repository MavenArtifactRepository getId

List of usage examples for org.apache.maven.artifact.repository MavenArtifactRepository getId

Introduction

In this page you can find the example usage for org.apache.maven.artifact.repository MavenArtifactRepository getId.

Prototype

public String getId() 

Source Link

Usage

From source file:io.fabric8.maven.plugin.AbstractArtifactSearchMojo.java

License:Apache License

protected File resolveArtifactFile(HelmIndexMojo.ArtifactDTO artifactDTO, String classifier, String extension) {
    File file = null;// w  ww .  ja  va  2  s . co m
    try {
        ArtifactRequest artifactRequest = new ArtifactRequest();
        org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(artifactDTO.getG(),
                artifactDTO.getA(), classifier, extension, artifactDTO.getV());
        artifactRequest.setArtifact(artifact);

        // convert maven remote repositories to Aether repos
        List<RemoteRepository> aetherRepoList = new ArrayList<>();
        for (MavenArtifactRepository remoteRepository : remoteRepositories) {
            RemoteRepository.Builder builder = new RemoteRepository.Builder(remoteRepository.getId(),
                    remoteRepository.getLayout().getId(), remoteRepository.getUrl());
            RemoteRepository aetherRepo = builder.build();
            aetherRepoList.add(aetherRepo);
        }
        artifactRequest.setRepositories(aetherRepoList);

        ArtifactResult artifactResult = artifactResolver.resolveArtifact(repoSession, artifactRequest);
        org.eclipse.aether.artifact.Artifact resolvedArtifact = artifactResult.getArtifact();
        if (resolvedArtifact == null) {
            getLog().warn("Could not resolve artifact " + artifactDTO.description());
            return null;
        }
        file = resolvedArtifact.getFile();

    } catch (Exception e) {
        getLog().warn("Failed to resolve manifest manifest for " + artifactDTO.description() + ". " + e, e);
        return null;
    }

    if (file == null) {
        getLog().warn("Could not resolve artifact file for " + artifactDTO.description());
        return null;
    }
    if (!file.isFile() || !file.exists()) {
        getLog().warn("Resolved artifact file does not exist for " + artifactDTO.description());
        return null;
    }
    return file;
}

From source file:org.mule.tooling.jubula.JubulaPrepareMojo.java

License:Open Source License

protected List<RemoteRepository> mavenArtifactRepositories2aetherRepositories() {
    final List<RemoteRepository> aetherRepos = new ArrayList<RemoteRepository>();

    for (final MavenArtifactRepository repo : remoteRepos) {
        final RemoteRepository remoteRepository = new RemoteRepository(repo.getId(), repo.getLayout().getId(),
                repo.getUrl());//from   w  w w.  j a  v  a2s. c  o m

        setAuthenticationIfNeeded(remoteRepository);
        aetherRepos.add(remoteRepository);
    }

    return aetherRepos;
}