Search in sources :

Example 21 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project intellij-community by JetBrains.

the class Maven3ServerEmbedder method retrieveAvailableVersions.

@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId, @NotNull String artifactId, @NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException {
    try {
        Artifact artifact = new DefaultArtifact(groupId, artifactId, "", Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
        List<ArtifactVersion> versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact, getLocalRepository(), convertRepositories(remoteRepositories));
        return ContainerUtil.map(versions, new Function<ArtifactVersion, String>() {

            @Override
            public String fun(ArtifactVersion version) {
                return version.toString();
            }
        });
    } catch (Exception e) {
        Maven3ServerGlobals.getLogger().info(e);
    }
    return Collections.emptyList();
}
Also used : ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) RemoteException(java.rmi.RemoteException) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project bnd by bndtools.

the class IndexerMojo method attach.

private void attach(File file, String type, String extension) {
    DefaultArtifactHandler handler = new DefaultArtifactHandler(type);
    handler.setExtension(extension);
    DefaultArtifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), null, type, null, handler);
    artifact.setFile(file);
    project.addAttachedArtifact(artifact);
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 23 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project kie-wb-common by kiegroup.

the class MavenUtils method createArtifacts.

private static void createArtifacts(List<Dependency> pomDeps, List<Artifact> deps) {
    if (pomDeps != null && pomDeps.size() > 0) {
        for (Dependency dep : pomDeps) {
            Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getScope(), dep.getType(), dep.getClassifier(), new DefaultArtifactHandler());
            deps.add(artifact);
        }
    }
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) Dependency(org.apache.maven.model.Dependency) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 24 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project felix by apache.

the class AbstractBundlePluginTest method getMavenProjectStub.

protected MavenProjectStub getMavenProjectStub() {
    MavenProjectStub project = new MavenProjectStub();
    project.setGroupId("group");
    project.setArtifactId("project");
    project.setVersion("1.2.3.4");
    VersionRange versionRange = VersionRange.createFromVersion(project.getVersion());
    ArtifactHandler artifactHandler = new DefaultArtifactHandler("pom");
    Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), versionRange, null, "pom", null, artifactHandler);
    artifact.setResolved(true);
    project.setArtifact(artifact);
    ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration();
    ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
    ArtifactRepository artifactRepository = new DefaultArtifactRepository("scratch", new File(getBasedir(), "target" + File.separatorChar + "scratch").toURI().toString(), layout);
    projectBuilderConfiguration.setLocalRepository(artifactRepository);
    project.setProjectBuilderConfiguration(projectBuilderConfiguration);
    return project;
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) LegacyRepositoryLayout(org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout) VersionRange(org.apache.maven.artifact.versioning.VersionRange) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) ProjectBuilderConfiguration(org.apache.maven.project.ProjectBuilderConfiguration) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 25 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project drools by kiegroup.

the class MavenProjectLoader method parseMavenPom.

public static MavenProject parseMavenPom(InputStream pomStream, boolean offline) {
    MavenEmbedder mavenEmbedder = null;
    try {
        mavenEmbedder = newMavenEmbedder(offline);
        final MavenProject project = mavenEmbedder.readProject(pomStream);
        if (IS_FORCE_OFFLINE) {
            final Set<Artifact> artifacts = new HashSet<>();
            final RepositorySystemSession session = Aether.getAether().getSession();
            for (Dependency dep : project.getDependencies()) {
                Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getScope(), dep.getType(), dep.getClassifier(), new DefaultArtifactHandler());
                if (resolve(session, artifact)) {
                    artifacts.add(artifact);
                } else {
                    log.error("Artifact can't be resolved {}'", artifact.toString());
                }
            }
            if (!artifacts.isEmpty()) {
                project.setArtifacts(artifacts);
            }
        }
        return project;
    } catch (Exception e) {
        log.error("Unable to create MavenProject from InputStream", e);
        throw new RuntimeException(e);
    } finally {
        if (mavenEmbedder != null) {
            mavenEmbedder.dispose();
        }
    }
}
Also used : RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) Dependency(org.apache.maven.model.Dependency) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) HashSet(java.util.HashSet)

Aggregations

DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)31 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)29 Artifact (org.apache.maven.artifact.Artifact)21 File (java.io.File)20 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)8 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)8 VersionRange (org.apache.maven.artifact.versioning.VersionRange)7 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7 MavenProject (org.apache.maven.project.MavenProject)6 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Map (java.util.Map)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 FileInputStream (java.io.FileInputStream)2 Path (java.nio.file.Path)2 RemoteException (java.rmi.RemoteException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Random (java.util.Random)2 ArtifactMetadataSource (org.apache.maven.artifact.metadata.ArtifactMetadataSource)2