Search in sources :

Example 1 with JavaPluginExtension

use of org.gradle.api.plugins.JavaPluginExtension in project coffeenet-starter by coffeenet.

the class ConventionsPlugin method applyMavenConventions.

private void applyMavenConventions(Project project) {
    // J-
    // @formatter:off
    project.getPlugins().withType(MavenPublishPlugin.class, (mavenPublish) -> {
        PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
        publishing.getPublications().withType(MavenPublication.class).all((publication) -> {
            customizePom(publication.getPom(), project);
        });
    });
    project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
        JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
        extension.withJavadocJar();
        extension.withSourcesJar();
    });
// @formatter:on
// J+
}
Also used : MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 2 with JavaPluginExtension

use of org.gradle.api.plugins.JavaPluginExtension in project spring-boot by spring-projects.

the class MavenPublishingConventions method apply.

void apply(Project project) {
    project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
        PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
        if (project.hasProperty("deploymentRepository")) {
            publishing.getRepositories().maven((mavenRepository) -> {
                mavenRepository.setUrl(project.property("deploymentRepository"));
                mavenRepository.setName("deployment");
            });
        }
        publishing.getPublications().withType(MavenPublication.class).all((mavenPublication) -> customizeMavenPublication(mavenPublication, project));
        project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
            JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
            extension.withJavadocJar();
            extension.withSourcesJar();
        });
    });
}
Also used : MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 3 with JavaPluginExtension

use of org.gradle.api.plugins.JavaPluginExtension in project gradle by gradle.

the class JavaGradlePluginPlugin method createExtension.

private GradlePluginDevelopmentExtension createExtension(Project project) {
    JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
    SourceSet defaultPluginSourceSet = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    SourceSet defaultTestSourceSet = javaPluginExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
    return project.getExtensions().create(EXTENSION_NAME, GradlePluginDevelopmentExtension.class, project, defaultPluginSourceSet, defaultTestSourceSet);
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Example 4 with JavaPluginExtension

use of org.gradle.api.plugins.JavaPluginExtension in project gradle by gradle.

the class ScalaBasePlugin method getToolchainTool.

private <T> Provider<T> getToolchainTool(Project project, BiFunction<JavaToolchainService, JavaToolchainSpec, Provider<T>> toolMapper) {
    final JavaPluginExtension extension = extensionOf(project, JavaPluginExtension.class);
    final JavaToolchainService service = extensionOf(project, JavaToolchainService.class);
    return toolMapper.apply(service, extension.getToolchain());
}
Also used : JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) JavaToolchainService(org.gradle.jvm.toolchain.JavaToolchainService)

Example 5 with JavaPluginExtension

use of org.gradle.api.plugins.JavaPluginExtension in project gradle by gradle.

the class EarPlugin method wireEarTaskConventionsWithJavaPluginApplied.

private void wireEarTaskConventionsWithJavaPluginApplied(final Project project, PluginContainer plugins) {
    plugins.withType(JavaPlugin.class, javaPlugin -> {
        final JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
        project.getTasks().withType(Ear.class).configureEach(task -> {
            task.dependsOn((Callable<FileCollection>) () -> mainSourceSetOf(javaPluginExtension).getRuntimeClasspath());
            task.from((Callable<FileCollection>) () -> mainSourceSetOf(javaPluginExtension).getOutput());
        });
    });
}
Also used : JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) FileCollection(org.gradle.api.file.FileCollection)

Aggregations

JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)13 JavaPlugin (org.gradle.api.plugins.JavaPlugin)7 SourceSet (org.gradle.api.tasks.SourceSet)5 Project (org.gradle.api.Project)4 Configuration (org.gradle.api.artifacts.Configuration)4 FileCollection (org.gradle.api.file.FileCollection)4 TaskProvider (org.gradle.api.tasks.TaskProvider)4 List (java.util.List)3 Action (org.gradle.api.Action)3 Plugin (org.gradle.api.Plugin)3 Task (org.gradle.api.Task)3 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)3 LazyPublishArtifact (org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact)3 BasePlugin (org.gradle.api.plugins.BasePlugin)3 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)3 Jar (org.gradle.api.tasks.bundling.Jar)3 File (java.io.File)2 Collections (java.util.Collections)2 Set (java.util.Set)2 AdhocComponentWithVariants (org.gradle.api.component.AdhocComponentWithVariants)2