Search in sources :

Example 1 with Wrapper

use of org.gradle.api.tasks.wrapper.Wrapper in project curiostack by curioswitch.

the class CuriostackRootPlugin method apply.

@Override
public void apply(Project rootProject) {
    rootProject.getGradle().getTaskGraph().whenReady(tasks -> {
        if (!rootProject.getGradle().getGradleVersion().equals(ToolDependencies.getGradleVersion(rootProject)) && !tasks.hasTask(":wrapper")) {
            throw new IllegalStateException("Gradle wrapper out-of-date, run ./gradlew :wrapper");
        }
    });
    PluginContainer plugins = rootProject.getPlugins();
    // Provides useful tasks like 'clean', 'assemble' to the root project.
    plugins.apply(BasePlugin.class);
    plugins.apply(AwsSetupPlugin.class);
    plugins.apply(CondaBuildEnvPlugin.class);
    plugins.apply(CurioGenericCiPlugin.class);
    plugins.apply(GcloudPlugin.class);
    plugins.apply(IdeaPlugin.class);
    plugins.apply(NodePlugin.class);
    plugins.apply(ReleasePlugin.class);
    plugins.apply(TerraformSetupPlugin.class);
    plugins.apply(ToolDownloaderPlugin.class);
    var updateGradleWrapper = rootProject.getTasks().register("curioUpdateWrapper", UpdateGradleWrapperTask.class);
    rootProject.getTasks().withType(Wrapper.class).configureEach(wrapper -> {
        wrapper.setGradleVersion(ToolDependencies.getGradleVersion(rootProject));
        wrapper.setDistributionType(DistributionType.ALL);
        wrapper.finalizedBy(updateGradleWrapper);
    });
    rootProject.getTasks().register("setupGitHooks", SetupGitHooks.class);
    var updateShellConfig = rootProject.getTasks().register("updateShellConfig", CreateShellConfigTask.class);
    DownloadToolUtil.getDownloadTask(rootProject, "miniconda-build").configure(t -> t.finalizedBy(updateShellConfig));
    rootProject.getTasks().named("condaInstallPackagesMinicondaBuild", t -> t.mustRunAfter(updateShellConfig));
    var updateIntelliJJdks = rootProject.getTasks().register(UpdateIntelliJSdksTask.NAME, UpdateIntelliJSdksTask.class, t -> t.dependsOn(updateGradleWrapper));
    var idea = rootProject.getTasks().named("idea");
    idea.configure(task -> task.dependsOn(updateIntelliJJdks));
    rootProject.getTasks().register("setup", t -> {
        t.dependsOn(idea);
        t.dependsOn(rootProject.getTasks().named("toolsSetupAll"));
        t.dependsOn(updateShellConfig);
    });
    var updateProjectSettings = rootProject.getTasks().register("updateProjectSettings", UpdateProjectSettingsTask.class);
    rootProject.getTasks().register("generateApiServer", GenerateApiServerTask.class, t -> t.finalizedBy(updateProjectSettings));
    rootProject.afterEvaluate((p) -> rootProject.getPlugins().withType(IdeaPlugin.class, plugin -> {
        var ipr = plugin.getModel().getProject().getIpr();
        ipr.whenMerged(unused -> ipr.withXml(provider -> setupProjectXml(rootProject, provider)));
        var iws = plugin.getModel().getWorkspace().getIws();
        iws.whenMerged(unused -> iws.withXml(provider -> setupWorkspaceXml(rootProject, provider)));
    }));
    rootProject.allprojects(project -> {
        project.getPlugins().withType(JavaPlugin.class, plugin -> setupJavaProject(project, ERROR_PRONE_CHECKS));
        project.getPlugins().withType(VersionsPlugin.class, unused -> {
            project.getTasks().named("dependencyUpdates", DependencyUpdatesTask.class, task -> {
                task.setRevision("release");
                task.setCheckConstraints(true);
                task.rejectVersionIf(filter -> {
                    String version = filter.getCandidate().getVersion();
                    String uppercaseVersion = version.toUpperCase(Locale.ROOT);
                    if (uppercaseVersion.contains("RELEASE") || uppercaseVersion.contains("FINAL") || uppercaseVersion.contains("GA")) {
                        return false;
                    }
                    if (IS_STABLE_VERSION.matcher(version).matches()) {
                        return false;
                    }
                    if (version.endsWith("-jre")) {
                        // Guava
                        return false;
                    }
                    return true;
                });
            });
        });
        project.getPlugins().withType(GolangPlugin.class, unused -> {
            project.getExtensions().getByType(GolangExtension.class).jib(jib -> jib.getCredentialHelper().set(DownloadedToolManager.get(project).getBinDir("gcloud").resolve("docker-credential-gcr")));
            project.getTasks().withType(JibTask.class).configureEach(t -> t.dependsOn(project.getRootProject().getTasks().getByName("gcloudSetup")));
        });
    });
    setupDataSources(rootProject);
    rootProject.getPlugins().withType(GolangSetupPlugin.class, unused -> rootProject.getPlugins().withType(ToolDownloaderPlugin.class, plugin -> plugin.tools().named("go").configure(tool -> tool.getVersion().set(ToolDependencies.getGolangVersion(rootProject)))));
    rootProject.getPlugins().withType(CondaPlugin.class, plugin -> plugin.getCondas().withType(CondaExtension.class).named("miniconda-build").configure(conda -> conda.getVersion().set(ToolDependencies.getMinicondaVersion(rootProject))));
    setupSpotless(rootProject);
}
Also used : ErrorProneOptions(net.ltgt.gradle.errorprone.ErrorProneOptions) AwsSetupPlugin(org.curioswitch.gradle.plugins.aws.AwsSetupPlugin) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) CondaPlugin(org.curioswitch.gradle.conda.CondaPlugin) JavaPlugin(org.gradle.api.plugins.JavaPlugin) IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) MonotonicNonNull(org.checkerframework.checker.nullness.qual.MonotonicNonNull) NodePlugin(org.curioswitch.gradle.plugins.nodejs.NodePlugin) Wrapper(org.gradle.api.tasks.wrapper.Wrapper) PublishingExtension(org.gradle.api.publish.PublishingExtension) Javadoc(org.gradle.api.tasks.javadoc.Javadoc) JibTask(org.curioswitch.gradle.golang.tasks.JibTask) GolangPlugin(org.curioswitch.gradle.golang.GolangPlugin) Locale(java.util.Locale) Map(java.util.Map) ExtensionAware(org.gradle.api.plugins.ExtensionAware) TestExceptionFormat(org.gradle.api.tasks.testing.logging.TestExceptionFormat) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ReleasePlugin(org.curioswitch.gradle.release.ReleasePlugin) Project(org.gradle.api.Project) VariantVersionMappingStrategy(org.gradle.api.publish.VariantVersionMappingStrategy) Predicate(java.util.function.Predicate) CheckSeverity(net.ltgt.gradle.errorprone.CheckSeverity) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SetupGitHooks(org.curioswitch.gradle.plugins.curiostack.tasks.SetupGitHooks) DistributionType(org.gradle.api.tasks.wrapper.Wrapper.DistributionType) Set(java.util.Set) UpdateProjectSettingsTask(org.curioswitch.gradle.plugins.curiostack.tasks.UpdateProjectSettingsTask) SpotlessExtension(com.diffplug.gradle.spotless.SpotlessExtension) XmlParser(groovy.util.XmlParser) Collectors(java.util.stream.Collectors) JavaVersion(org.gradle.api.JavaVersion) StandardCharsets(java.nio.charset.StandardCharsets) NullAwayPlugin(net.ltgt.gradle.nullaway.NullAwayPlugin) UncheckedIOException(java.io.UncheckedIOException) CondaBuildEnvPlugin(org.curioswitch.gradle.conda.CondaBuildEnvPlugin) List(java.util.List) ToolDownloaderPlugin(org.curioswitch.gradle.tooldownloader.ToolDownloaderPlugin) CoreJavadocOptions(org.gradle.external.javadoc.CoreJavadocOptions) VersionsPlugin(com.github.benmanes.gradle.versions.VersionsPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) SAXException(org.xml.sax.SAXException) DependencyUpdatesTask(com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask) Optional(java.util.Optional) PluginContainer(org.gradle.api.plugins.PluginContainer) XmlProvider(org.gradle.api.XmlProvider) Pattern(java.util.regex.Pattern) JooqPlugin(nu.studer.gradle.jooq.JooqPlugin) QName(groovy.xml.QName) GenerateApiServerTask(org.curioswitch.gradle.plugins.curiostack.tasks.GenerateApiServerTask) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) ERROR(net.ltgt.gradle.errorprone.CheckSeverity.ERROR) CurioGenericCiPlugin(org.curioswitch.gradle.plugins.ci.CurioGenericCiPlugin) ErrorPronePlugin(net.ltgt.gradle.errorprone.ErrorPronePlugin) CondaExtension(org.curioswitch.gradle.conda.CondaExtension) HashMap(java.util.HashMap) GolangExtension(org.curioswitch.gradle.golang.GolangExtension) BasePlugin(org.gradle.api.plugins.BasePlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) DownloadToolUtil(org.curioswitch.gradle.tooldownloader.util.DownloadToolUtil) SourceSet(org.gradle.api.tasks.SourceSet) Configuration(org.gradle.api.artifacts.Configuration) TargetJvmVersion(org.gradle.api.attributes.java.TargetJvmVersion) JMHPluginExtension(me.champeau.gradle.JMHPluginExtension) ImmutableList(com.google.common.collect.ImmutableList) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) JooqTask(nu.studer.gradle.jooq.JooqTask) DownloadedToolManager(org.curioswitch.gradle.tooldownloader.DownloadedToolManager) UpdateGradleWrapperTask(org.curioswitch.gradle.plugins.curiostack.tasks.UpdateGradleWrapperTask) CreateShellConfigTask(org.curioswitch.gradle.plugins.curiostack.tasks.CreateShellConfigTask) NodeUtil(org.curioswitch.gradle.plugins.nodejs.util.NodeUtil) Test(org.gradle.api.tasks.testing.Test) OFF(net.ltgt.gradle.errorprone.CheckSeverity.OFF) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) Resources(com.google.common.io.Resources) Files(java.nio.file.Files) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) JacocoPlugin(org.gradle.testing.jacoco.plugins.JacocoPlugin) JMHPlugin(me.champeau.gradle.JMHPlugin) UpdateIntelliJSdksTask(org.curioswitch.gradle.plugins.curiostack.tasks.UpdateIntelliJSdksTask) IOException(java.io.IOException) Node(groovy.util.Node) GcloudPlugin(org.curioswitch.gradle.plugins.gcloud.GcloudPlugin) GolangSetupPlugin(org.curioswitch.gradle.golang.GolangSetupPlugin) SpotlessPlugin(com.diffplug.gradle.spotless.SpotlessPlugin) ResolutionStrategy(org.gradle.api.artifacts.ResolutionStrategy) TerraformSetupPlugin(org.curioswitch.gradle.plugins.terraform.TerraformSetupPlugin) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NullAwayOptions(net.ltgt.gradle.nullaway.NullAwayOptions) JavaExec(org.gradle.api.tasks.JavaExec) WARN(net.ltgt.gradle.errorprone.CheckSeverity.WARN) Plugin(org.gradle.api.Plugin) Copy(org.gradle.api.tasks.Copy) ToolDownloaderPlugin(org.curioswitch.gradle.tooldownloader.ToolDownloaderPlugin) Wrapper(org.gradle.api.tasks.wrapper.Wrapper) GolangExtension(org.curioswitch.gradle.golang.GolangExtension) PluginContainer(org.gradle.api.plugins.PluginContainer) IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) CondaExtension(org.curioswitch.gradle.conda.CondaExtension) JibTask(org.curioswitch.gradle.golang.tasks.JibTask)

Aggregations

SpotlessExtension (com.diffplug.gradle.spotless.SpotlessExtension)1 SpotlessPlugin (com.diffplug.gradle.spotless.SpotlessPlugin)1 VersionsPlugin (com.github.benmanes.gradle.versions.VersionsPlugin)1 DependencyUpdatesTask (com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Resources (com.google.common.io.Resources)1 Node (groovy.util.Node)1 XmlParser (groovy.util.XmlParser)1 QName (groovy.xml.QName)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1