public void deploy(File source,
Artifact artifact,
ArtifactRepository deploymentRepository,
ArtifactRepository localRepository) throws ArtifactDeploymentException {
if ( !wagonManager.isOnline() )
{
// deployment shouldn't silently fail when offline
throw new ArtifactDeploymentException( "System is offline. Cannot deploy artifact: " + artifact + "." );
}
try
{
transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository );
// Copy the original file to the new one if it was transformed
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
if ( !artifactFile.equals( source ) )
{
FileUtils.copyFile( source, artifactFile );
}
wagonManager.putArtifact( source, artifact, deploymentRepository );
// must be after the artifact is installed
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
{
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
repositoryMetadataManager.deploy( metadata, localRepository, deploymentRepository );
}
// TODO: would like to flush this, but the plugin metadata is added in advance, not as an install/deploy transformation
// This would avoid the need to merge and clear out the state during deployment
// artifact.getMetadataList().clear();
}
catch ( TransferFailedException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e );
}
catch ( IOException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e );
}
catch ( RepositoryMetadataDeploymentException e )
{
throw new ArtifactDeploymentException( "Error installing artifact's metadata: " + e.getMessage(), e );
}
}
|