use of org.gradle.api.publish.PublishingExtension 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.publish.PublishingExtension in project wildfly-gradle-tools by wildfly.
the class GradleArtifactFileResolver method extractPublishingExtension.
/**
* @param project
* @return the list of PublishingExtension(s), if some are defined: this will depend on the project (could be empty).
*/
private static PublishingExtension extractPublishingExtension(final Project project) {
final ExtensionContainer extensions = project.getExtensions();
final Object publishing = extensions.findByName("publishing");
if (publishing == null) {
return null;
}
if (!PublishingExtension.class.isAssignableFrom(publishing.getClass())) {
throw new RuntimeException("The registered 'publishing' extension is not of the expected type PublishingExtension");
}
return (PublishingExtension) publishing;
}
use of org.gradle.api.publish.PublishingExtension in project spring-boot by spring-projects.
the class MavenPluginPlugin method configurePomPackaging.
private void configurePomPackaging(Project project) {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().withType(MavenPublication.class, this::setPackaging);
}
use of org.gradle.api.publish.PublishingExtension 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);
});
}
use of org.gradle.api.publish.PublishingExtension in project spring-security by spring-projects.
the class ManagementConfigurationPlugin method apply.
@Override
public void apply(Project project) {
ConfigurationContainer configurations = project.getConfigurations();
configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> {
management.setVisible(false);
management.setCanBeConsumed(false);
management.setCanBeResolved(false);
PluginContainer plugins = project.getPlugins();
plugins.withType(JavaPlugin.class, (javaPlugin) -> {
configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
});
plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> {
configurations.getByName("testFixturesCompileClasspath").extendsFrom(management);
configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management);
});
plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> {
mavenPublication.versionMapping((versions) -> versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()));
}));
});
plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> {
configurations.getByName("optional").extendsFrom(management);
configurations.getByName("provided").extendsFrom(management);
}));
});
}
Aggregations