Search in sources :

Example 6 with JavaPlugin

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

the class EclipseWtpPlugin method configureEclipseWtpFacet.

private void configureEclipseWtpFacet(final Project project, final EclipseModel eclipseModel) {
    TaskProvider<GenerateEclipseWtpFacet> task = project.getTasks().register(ECLIPSE_WTP_FACET_TASK_NAME, GenerateEclipseWtpFacet.class, eclipseModel.getWtp().getFacet());
    task.configure(new Action<GenerateEclipseWtpFacet>() {

        @Override
        public void execute(final GenerateEclipseWtpFacet task) {
            task.setDescription("Generates the Eclipse WTP facet settings file.");
            task.setInputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));
            task.setOutputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));
        }
    });
    addWorker(task, ECLIPSE_WTP_FACET_TASK_NAME);
    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {

        @Override
        public void execute(JavaPlugin javaPlugin) {
            if (hasWarOrEarPlugin(project)) {
                return;
            }
            ((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {

                @Override
                public List<Facet> call() throws Exception {
                    return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.java", null), new Facet(Facet.FacetType.installed, "jst.utility", "1.0"), new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getExtensions().getByType(JavaPluginExtension.class).getSourceCompatibility())));
                }
            });
        }
    });
    project.getPlugins().withType(WarPlugin.class, new Action<WarPlugin>() {

        @Override
        public void execute(WarPlugin warPlugin) {
            ((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {

                @Override
                public List<Facet> call() throws Exception {
                    return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.java", null), new Facet(Facet.FacetType.fixed, "jst.web", null), new Facet(Facet.FacetType.installed, "jst.web", "2.4"), new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getExtensions().getByType(JavaPluginExtension.class).getSourceCompatibility())));
                }
            });
        }
    });
    project.getPlugins().withType(EarPlugin.class, new Action<EarPlugin>() {

        @Override
        public void execute(EarPlugin earPlugin) {
            ((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {

                @Override
                public List<Facet> call() throws Exception {
                    return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.ear", null), new Facet(Facet.FacetType.installed, "jst.ear", "5.0"));
                }
            });
        }
    });
}
Also used : JavaPlugin(org.gradle.api.plugins.JavaPlugin) Callable(java.util.concurrent.Callable) IConventionAware(org.gradle.api.internal.IConventionAware) WarPlugin(org.gradle.api.plugins.WarPlugin) Facet(org.gradle.plugins.ide.eclipse.model.Facet) EarPlugin(org.gradle.plugins.ear.EarPlugin)

Example 7 with JavaPlugin

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

the class EarPlugin method setupEarTask.

private void setupEarTask(final Project project, EarPluginConvention convention, PluginContainer plugins) {
    TaskProvider<Ear> ear = project.getTasks().register(EAR_TASK_NAME, Ear.class, new Action<Ear>() {

        @Override
        public void execute(Ear ear) {
            ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
            ear.setGroup(BasePlugin.BUILD_GROUP);
            ear.getGenerateDeploymentDescriptor().convention(convention.getGenerateDeploymentDescriptor());
            plugins.withType(JavaPlugin.class, javaPlugin -> {
                final JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
                SourceSet sourceSet = mainSourceSetOf(javaPluginExtension);
                sourceSet.getResources().srcDir(ear.getAppDirectory());
            });
        }
    });
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new LazyPublishArtifact(ear, ((ProjectInternal) project).getFileResolver()));
    project.getTasks().withType(Ear.class).configureEach(new Action<Ear>() {

        @Override
        public void execute(Ear task) {
        }
    });
}
Also used : LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) Action(org.gradle.api.Action) Project(org.gradle.api.Project) JavaPlugin(org.gradle.api.plugins.JavaPlugin) Callable(java.util.concurrent.Callable) BasePlugin(org.gradle.api.plugins.BasePlugin) FileCollection(org.gradle.api.file.FileCollection) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) ObjectFactory(org.gradle.api.model.ObjectFactory) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) PluginContainer(org.gradle.api.plugins.PluginContainer) DeploymentDescriptor(org.gradle.plugins.ear.descriptor.DeploymentDescriptor) Dependency(org.gradle.api.artifacts.Dependency) Plugin(org.gradle.api.Plugin) JvmPluginServices(org.gradle.api.plugins.jvm.internal.JvmPluginServices) SourceSet(org.gradle.api.tasks.SourceSet) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) DeploymentDescriptor(org.gradle.plugins.ear.descriptor.DeploymentDescriptor) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Example 8 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project gradle-apt-plugin by tbroyer.

the class AptPlugin25to211 method ensureCompileOnlyConfiguration.

@Override
protected void ensureCompileOnlyConfiguration(final Project project, final SourceSet sourceSet, AptPlugin.AptSourceSetConvention convention) {
    Configuration configuration = project.getConfigurations().create(convention.getCompileOnlyConfigurationName());
    configuration.setVisible(false);
    configuration.setDescription("Compile-only classpath for " + sourceSet.getName());
    configuration.extendsFrom(project.getConfigurations().findByName(sourceSet.getCompileConfigurationName()));
    sourceSet.setCompileClasspath(configuration);
    if (SourceSet.TEST_SOURCE_SET_NAME.equals(sourceSet.getName())) {
        final Configuration conf = configuration;
        project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {

            @Override
            public void execute(JavaPlugin javaPlugin) {
                sourceSet.setCompileClasspath(project.files(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(), conf));
            }
        });
    }
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) JavaPlugin(org.gradle.api.plugins.JavaPlugin)

Example 9 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-boot-data-geode by spring-projects.

the class MavenPublishingConventionsPlugin method customizeJavaPlugin.

private void customizeJavaPlugin(Project project) {
    project.getPlugins().withType(JavaPlugin.class).all(javaPlugin -> {
        JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
        extension.withJavadocJar();
        extension.withSourcesJar();
    });
}
Also used : JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Example 10 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-session by spring-projects.

the class MavenPublishingConventionsPlugin method customizeJavaPlugin.

private void customizeJavaPlugin(Project project) {
    project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
        JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
        extension.withJavadocJar();
        extension.withSourcesJar();
    });
}
Also used : JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Aggregations

JavaPlugin (org.gradle.api.plugins.JavaPlugin)21 Configuration (org.gradle.api.artifacts.Configuration)9 Project (org.gradle.api.Project)8 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)8 Plugin (org.gradle.api.Plugin)7 PublishingExtension (org.gradle.api.publish.PublishingExtension)7 MavenPublication (org.gradle.api.publish.maven.MavenPublication)7 PluginContainer (org.gradle.api.plugins.PluginContainer)6 MavenPublishPlugin (org.gradle.api.publish.maven.plugins.MavenPublishPlugin)6 File (java.io.File)5 Callable (java.util.concurrent.Callable)4 Action (org.gradle.api.Action)4 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)4 JavaTestFixturesPlugin (org.gradle.api.plugins.JavaTestFixturesPlugin)4 SourceSet (org.gradle.api.tasks.SourceSet)4 PropDepsPlugin (org.springframework.gradle.propdeps.PropDepsPlugin)3 SpotlessExtension (com.diffplug.gradle.spotless.SpotlessExtension)2 SpotlessPlugin (com.diffplug.gradle.spotless.SpotlessPlugin)2 VersionsPlugin (com.github.benmanes.gradle.versions.VersionsPlugin)2 ImmutableList (com.google.common.collect.ImmutableList)2