use of org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact in project gradle by gradle.
the class DistributionPlugin method configureArchiveTask.
private <T extends AbstractArchiveTask> Task configureArchiveTask(Project project, String taskName, final Distribution distribution, Class<T> type) {
final T archiveTask = project.getTasks().create(taskName, type);
archiveTask.setDescription("Bundles the project as a distribution.");
archiveTask.setGroup(DISTRIBUTION_GROUP);
archiveTask.getConventionMapping().map("baseName", new Callable<Object>() {
@Override
public Object call() throws Exception {
if (distribution.getBaseName() == null || distribution.getBaseName().equals("")) {
throw new GradleException("Distribution baseName must not be null or empty! Check your configuration of the distribution plugin.");
}
return distribution.getBaseName();
}
});
Callable<String> baseDir = new Callable<String>() {
@Override
public String call() throws Exception {
return TextUtil.minus(archiveTask.getArchiveName(), "." + archiveTask.getExtension());
}
};
CopySpec childSpec = project.copySpec();
childSpec.into(baseDir);
childSpec.with(distribution.getContents());
archiveTask.with(childSpec);
ArchivePublishArtifact archiveArtifact = new ArchivePublishArtifact(archiveTask);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(archiveArtifact);
return archiveTask;
}
Aggregations