use of org.gradle.api.NamedDomainObjectList in project gradle by gradle.
the class IvyPublishPlugin method createTasksLater.
private void createTasksLater(final Project project, final PublishingExtension publishingExtension, final DirectoryProperty buildDir) {
final TaskContainer tasks = project.getTasks();
final NamedDomainObjectSet<IvyPublicationInternal> publications = publishingExtension.getPublications().withType(IvyPublicationInternal.class);
final NamedDomainObjectList<IvyArtifactRepository> repositories = publishingExtension.getRepositories().withType(IvyArtifactRepository.class);
repositories.all(repository -> tasks.register(publishAllToSingleRepoTaskName(repository), publish -> {
publish.setDescription("Publishes all Ivy publications produced by this project to the " + repository.getName() + " repository.");
publish.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
}));
publications.all(publication -> {
final String publicationName = publication.getName();
createGenerateIvyDescriptorTask(tasks, publicationName, publication, buildDir);
createGenerateMetadataTask(tasks, publication, publications, buildDir, repositories);
createPublishTaskForEachRepository(tasks, publication, publicationName, repositories);
});
}
use of org.gradle.api.NamedDomainObjectList in project gradle by gradle.
the class IvyPublishPlugin method disableGradleMetadataGenerationIfCustomLayout.
private void disableGradleMetadataGenerationIfCustomLayout(NamedDomainObjectList<IvyArtifactRepository> repositories, GenerateModuleMetadata generateTask) {
AtomicBoolean didWarn = new AtomicBoolean();
Spec<? super Task> checkStandardLayout = task -> {
boolean standard = repositories.stream().allMatch(this::hasStandardPattern);
if (!standard && !didWarn.getAndSet(true)) {
LOGGER.warn("Publication of Gradle Module Metadata is disabled because you have configured an Ivy repository with a non-standard layout");
}
return standard;
};
Spec<TaskInternal> spec = new AndSpec<TaskInternal>(generateTask.getOnlyIf(), checkStandardLayout);
generateTask.setOnlyIf(Cast.<Spec<? super Task>>uncheckedCast(spec));
}
use of org.gradle.api.NamedDomainObjectList in project gradle by gradle.
the class MavenPublishPlugin method realizePublishingTasksLater.
private void realizePublishingTasksLater(final Project project, final PublishingExtension extension) {
final NamedDomainObjectSet<MavenPublicationInternal> mavenPublications = extension.getPublications().withType(MavenPublicationInternal.class);
final TaskContainer tasks = project.getTasks();
final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
final TaskProvider<Task> publishLifecycleTask = tasks.named(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
final TaskProvider<Task> publishLocalLifecycleTask = tasks.named(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
final NamedDomainObjectList<MavenArtifactRepository> repositories = extension.getRepositories().withType(MavenArtifactRepository.class);
repositories.all(repository -> tasks.register(publishAllToSingleRepoTaskName(repository), publish -> {
publish.setDescription("Publishes all Maven publications produced by this project to the " + repository.getName() + " repository.");
publish.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
}));
mavenPublications.all(publication -> {
createGenerateMetadataTask(tasks, publication, mavenPublications, buildDirectory);
createGeneratePomTask(tasks, publication, buildDirectory, project);
createLocalInstallTask(tasks, publishLocalLifecycleTask, publication);
createPublishTasksForEachMavenRepo(tasks, publishLifecycleTask, publication, repositories);
});
}
Aggregations