public static void write(Set<Artifact> artifacts, String targetDirectory) throws MojoExecutionException { RepositoryLayout m2layout = new MavenDefaultLayout(); for (Artifact artifact : artifacts) { File src = artifact.getFile(); // set the version (which could be a resolved snapshot) to the base version (which in that case would be // literally SNAPSHOT), because that is what lily runtime expects. artifact = artifact.setVersion(artifact.getBaseVersion()); File dest = new File(targetDirectory, m2layout.getPath(artifact).getPath()); try { System.out.println("Copying " + src + " to " + dest); FileUtils.copyFile(src, dest); } catch (IOException e) { throw new MojoExecutionException("Error copying file " + src + " to " + dest); } // Lily Runtime does not need the pom files, but let's copy them anyway, for informational purposes File srcPom = pomFile(src); File destPom = pomFile(dest); if (srcPom != null && srcPom.exists()) { try { FileUtils.copyFile(srcPom, destPom); } catch (IOException e) { throw new MojoExecutionException("Error copying file " + srcPom + " to " + destPom); } } } }
private DefaultTransferResource newResource( TransferWrapper transfer, RemoteRepository repository ) { String resourceName = null; switch ( transfer.getType() ) { case ARTIFACT: Artifact artifact = transfer.getArtifact(); resourceName = layout.getPath( artifact ).getPath(); break; case METADATA: Metadata metadata = transfer.getMetadata(); resourceName = layout.getPath( metadata ).getPath(); break; } return new DefaultTransferResource( PathUtils.decode( repository.getUrl() ), resourceName, transfer.getFile(), transfer.getTrace() ); }
public void put( Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads ) { if ( closed ) { throw new IllegalStateException( "connector closed" ); } artifactUploads = safe( artifactUploads ); metadataUploads = safe( metadataUploads ); for ( ArtifactUpload upload : artifactUploads ) { String path = layout.getPath( upload.getArtifact() ).getPath(); PutTask<?> task = new PutTask<ArtifactTransfer>( path, upload.getFile(), upload, ARTIFACT ); task.run(); } for ( MetadataUpload upload : metadataUploads ) { String path = layout.getPath( upload.getMetadata() ).getPath(); PutTask<?> task = new PutTask<MetadataTransfer>( path, upload.getFile(), upload, METADATA ); task.run(); } }
String resource = layout.getPath( download.getMetadata() ).getPath(); GetTask<?> task = new GetTask<MetadataTransfer>( resource, download.getFile(), download.getChecksumPolicy(), download, String resource = layout.getPath( download.getArtifact() ).getPath(); GetTask<?> task = new GetTask<ArtifactTransfer>( resource, download.isExistenceCheck() ? null : download.getFile(),
String resource = layout.getPath( download.getMetadata() ).getPath(); GetTask<?> task = new GetTask<MetadataTransfer>( resource, download.getFile(), download.getChecksumPolicy(), latch, String resource = layout.getPath( download.getArtifact() ).getPath(); GetTask<?> task = new GetTask<ArtifactTransfer>( resource, download.isExistenceCheck() ? null : download.getFile(),
String resource = layout.getPath( download.getMetadata() ).getPath(); GetTask<?> task = new GetTask<MetadataTransfer>( resource, download.getFile(), download.getChecksumPolicy(), latch, String resource = layout.getPath( download.getArtifact() ).getPath(); GetTask<?> task = new GetTask<ArtifactTransfer>( resource, download.isExistenceCheck() ? null : download.getFile(),