Example usage for org.apache.maven.artifact.installer ArtifactInstaller install

List of usage examples for org.apache.maven.artifact.installer ArtifactInstaller install

Introduction

In this page you can find the example usage for org.apache.maven.artifact.installer ArtifactInstaller install.

Prototype

void install(File source, Artifact artifact, ArtifactRepository localRepository)
        throws ArtifactInstallationException;

Source Link

Document

Install an artifact from a particular file.

Usage

From source file:hudson.gridmaven.reporters.MavenArtifactRecord.java

License:Open Source License

/**
 * Installs the artifact to the local Maven repository.
 *//*from  www .  j av a 2 s . c om*/
public void install(MavenEmbedder embedder)
        throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactInstallationException {
    ArtifactHandlerManager handlerManager = embedder.lookup(ArtifactHandlerManager.class);
    ArtifactInstaller installer = embedder.lookup(ArtifactInstaller.class);
    ArtifactFactory factory = embedder.lookup(ArtifactFactory.class);

    Artifact main = mainArtifact.toArtifact(handlerManager, factory, parent);
    if (!isPOM())
        main.addMetadata(new ProjectArtifactMetadata(main, pomArtifact.getFile(parent)));
    installer.install(mainArtifact.getFile(parent), main, embedder.getLocalRepository());

    for (MavenArtifact aa : attachedArtifacts)
        installer.install(aa.getFile(parent), aa.toArtifact(handlerManager, factory, parent),
                embedder.getLocalRepository());
}

From source file:org.gradle.api.publication.maven.internal.action.MavenInstallAction.java

License:Apache License

@Override
protected void publishArtifact(Artifact artifact, File artifactFile, ArtifactRepository localRepo) {
    ArtifactInstaller installer = lookup(ArtifactInstaller.class);
    try {/* w ww .j av  a 2  s .  c  o m*/
        installer.install(artifactFile, artifact, localRepo);
    } catch (ArtifactInstallationException e) {
        throw new GradleException(
                "Error installing artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e);
    }
}

From source file:org.hardisonbrewing.maven.core.DependencyService.java

License:Open Source License

public static final void install(File src, Artifact artifact) throws ArtifactInstallationException {

    try {//from   w  w  w .  ja v  a 2s .c om
        artifact.addMetadata(createArtifactMetadata(artifact));
    } catch (IOException e) {
        throw new ArtifactInstallationException(e.getMessage(), e);
    }

    ArtifactInstaller artifactInstaller = getArtifactInstaller();
    artifactInstaller.install(src, artifact, DependencyService.getLocalRepository());
}

From source file:org.sourcepit.common.maven.testing.ArtifactRepositoryFacade.java

License:Apache License

private void deploy(final File source, Model pom, boolean install, boolean deploy) {
    final ArtifactRepository localRepository = embeddedMaven.getLocalRepository();

    final File localRepo = new File(localRepository.getBasedir());

    final MavenExecutionResult2 result = embeddedMaven.buildStubProject(localRepo);

    final MavenSession session = legacySupport.getSession();
    try {//from w  w  w  . j  av a 2 s  .  co m
        final ArtifactInstaller installer = install ? plexus.lookup(ArtifactInstaller.class) : null;
        final ArtifactDeployer deployer = deploy ? plexus.lookup(ArtifactDeployer.class) : null;

        legacySupport.setSession(result.getSession());

        final ArtifactRepository deploymentRepository = embeddedMaven.getRemoteRepository();

        final Artifact artifact = embeddedMaven.createArtifact(pom);
        if (install) {
            installer.install(source, artifact, localRepository);
        }
        if (deploy) {
            deployer.deploy(source, artifact, deploymentRepository, localRepository);
        }

        if (!"pom".equals(pom.getPackaging())) {
            final Artifact pomArtifact = embeddedMaven.createProjectArtifact(pom);
            final File pomFile = File.createTempFile(pom.getArtifactId() + "-" + pom.getVersion(), ".pom",
                    localRepo);
            try {
                new DefaultModelWriter().write(pomFile, null, pom);
                if (install) {
                    installer.install(pomFile, pomArtifact, localRepository);
                }
                if (deploy) {
                    deployer.deploy(pomFile, pomArtifact, deploymentRepository, localRepository);
                }
            } finally {
                FileUtils.forceDelete(pomFile);
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new IllegalStateException(e);
    } finally {
        legacySupport.setSession(session);
    }
}