Example usage for org.apache.maven.artifact.metadata ArtifactMetadata storeInLocalRepository

List of usage examples for org.apache.maven.artifact.metadata ArtifactMetadata storeInLocalRepository

Introduction

In this page you can find the example usage for org.apache.maven.artifact.metadata ArtifactMetadata storeInLocalRepository.

Prototype

void storeInLocalRepository(ArtifactRepository localRepository, ArtifactRepository remoteRepository)
        throws RepositoryMetadataStoreException;

Source Link

Document

Store the metadata in the local repository.

Usage

From source file:org.ck.maven.plugins.pom.versions.service.version.PomVersionRepositoryMetadataManager.java

License:Apache License

public void deploy(ArtifactMetadata metadata, ArtifactRepository localRepository,
        ArtifactRepository deploymentRepository) throws RepositoryMetadataDeploymentException {
    if (!wagonManager.isOnline()) {
        // deployment shouldn't silently fail when offline
        throw new RepositoryMetadataDeploymentException(
                "System is offline. Cannot deploy metadata:\n" + metadata.extendedToString());
    }//from w w  w  .ja  v  a2s . c o m

    File file;
    if (metadata instanceof RepositoryMetadata) {
        getLogger().info("Retrieving previous metadata from " + deploymentRepository.getId());
        try {
            file = getArtifactMetadataFromDeploymentRepository(metadata, localRepository, deploymentRepository);
        } catch (TransferFailedException e) {
            throw new RepositoryMetadataDeploymentException(
                    metadata + " could not be retrieved from repository: " + deploymentRepository.getId()
                            + " due to an error: " + e.getMessage(),
                    e);
        }
    } else {
        // It's a POM - we don't need to retrieve it first
        file = new File(localRepository.getBasedir(),
                localRepository.pathOfLocalRepositoryMetadata(metadata, deploymentRepository));
    }

    try {
        metadata.storeInLocalRepository(localRepository, deploymentRepository);
    } catch (RepositoryMetadataStoreException e) {
        throw new RepositoryMetadataDeploymentException("Error installing metadata: " + e.getMessage(), e);
    }

    try {
        wagonManager.putArtifactMetadata(file, metadata, deploymentRepository);
    } catch (TransferFailedException e) {
        throw new RepositoryMetadataDeploymentException("Error while deploying metadata: " + e.getMessage(), e);
    }
}

From source file:org.ck.maven.plugins.pom.versions.service.version.PomVersionRepositoryMetadataManager.java

License:Apache License

public void install(ArtifactMetadata metadata, ArtifactRepository localRepository)
        throws RepositoryMetadataInstallationException {
    try {//from  w  ww .j a  v  a 2  s  . c o m
        metadata.storeInLocalRepository(localRepository, localRepository);
    } catch (RepositoryMetadataStoreException e) {
        throw new RepositoryMetadataInstallationException("Error installing metadata: " + e.getMessage(), e);
    }
}