Java 类org.apache.maven.project.artifact.ProjectArtifactMetadata 实例源码

项目:minecraft-maven-plugin    文件:AbstractArtifactMojo.java   
/**
 * Installs a passed artifact into the local repository.
 */
protected void installArtifact(@Nonnull Artifact artifact, @Nonnull Path modelPath, @Nonnull Path artifactPath) throws ArtifactInstallationException {
    this.getLog().debug("Installing artifact " + this.getArtifactCoordinateString(artifact));

    ArtifactMetadata metadata = new ProjectArtifactMetadata(artifact, modelPath.toFile());
    artifact.addMetadata(metadata);

    this.getArtifactInstaller().install(artifactPath.toFile(), artifact, this.getSession().getLocalRepository());
}
项目:oceano    文件:DefaultArtifactInstaller.java   
public void install( File source, Artifact artifact, ArtifactRepository localRepository )
    throws ArtifactInstallationException
{
    RepositorySystemSession session =
        LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem );

    InstallRequest request = new InstallRequest();

    request.setTrace( DefaultRequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );

    org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
    mainArtifact = mainArtifact.setFile( source );
    request.addArtifact( mainArtifact );

    for ( ArtifactMetadata metadata : artifact.getMetadataList() )
    {
        if ( metadata instanceof ProjectArtifactMetadata )
        {
            org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
            pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
            request.addArtifact( pomArtifact );
        }
        else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
            || metadata instanceof ArtifactRepositoryMetadata )
        {
            // eaten, handled by repo system
        }
        else
        {
            request.addMetadata( new MetadataBridge( metadata ) );
        }
    }

    try
    {
        repoSystem.install( session, request );
    }
    catch ( InstallationException e )
    {
        throw new ArtifactInstallationException( e.getMessage(), e );
    }

    /*
     * NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin.
     */

    if ( artifact.isSnapshot() )
    {
        Snapshot snapshot = new Snapshot();
        snapshot.setLocalCopy( true );
        artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) );
    }

    Versioning versioning = new Versioning();
    versioning.updateTimestamp();
    versioning.addVersion( artifact.getBaseVersion() );
    if ( artifact.isRelease() )
    {
        versioning.setRelease( artifact.getBaseVersion() );
    }
    artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) );
}