Search in sources :

Example 1 with Os

use of org.apache.tools.ant.taskdefs.condition.Os in project curiostack by curioswitch.

the class CuriostackPlugin method apply.

@Override
public void apply(Project rootProject) {
    PluginContainer plugins = rootProject.getPlugins();
    // Provides useful tasks like 'clean', 'assemble' to the root project.
    plugins.apply(BasePlugin.class);
    plugins.apply(BaselineIdea.class);
    plugins.apply(CurioGenericCiPlugin.class);
    plugins.apply(GcloudPlugin.class);
    plugins.apply(NodePlugin.class);
    plugins.apply(PythonEnvsPlugin.class);
    setupPyenvs(rootProject);
    YarnInstallTask yarnTask = rootProject.getTasks().withType(YarnInstallTask.class).getByName("yarn");
    yarnTask.setArgs(ImmutableList.of("--frozen-lockfile"));
    YarnInstallTask yarnUpdateTask = rootProject.getTasks().create("yarnUpdate", YarnInstallTask.class);
    Task yarnWarning = rootProject.getTasks().create("yarnWarning", task -> {
        task.onlyIf(unused -> yarnTask.getState().getFailure() != null);
        task.doFirst(unused -> rootProject.getLogger().warn("yarn task failed. If you have updated a dependency and the " + "error says 'Your lockfile needs to be updated.', run \n\n" + "./gradlew " + yarnUpdateTask.getPath()));
    });
    yarnTask.finalizedBy(yarnWarning);
    rootProject.getTasks().create("setupGitHooks", SetupGitHooks.class);
    CreateShellConfigTask rehash = rootProject.getTasks().create("rehash", CreateShellConfigTask.class, t -> t.path(CommandUtil.getPythonBinDir(rootProject, "dev")).path(CommandUtil.getGcloudSdkBinDir(rootProject)));
    setupNode(rootProject, rehash);
    rootProject.getTasks().create("setup", t -> {
        t.dependsOn("gcloudSetup");
        t.dependsOn("pythonSetup");
        t.dependsOn("nodeSetup");
        t.dependsOn("yarnSetup");
        t.dependsOn("rehash");
    });
    String baselineFiles;
    try {
        baselineFiles = Resources.toString(Resources.getResource("META-INF/org.curioswitch.curiostack.baseline_manifest.txt"), StandardCharsets.UTF_8);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    Task baselineUpdateConfig = rootProject.getTasks().create("baselineUpdateConfig").doLast(task -> {
        File baselineDir = rootProject.file(".baseline");
        baselineDir.mkdirs();
        for (String filePath : NEW_LINE_SPLITTER.split(baselineFiles)) {
            Path path = Paths.get(filePath);
            Path outputDirectory = Paths.get(baselineDir.getAbsolutePath()).resolve(path.getParent());
            rootProject.file(outputDirectory.toAbsolutePath()).mkdirs();
            try (FileOutputStream os = new FileOutputStream(outputDirectory.resolve(path.getFileName()).toFile());
                InputStream is = Resources.getResource(filePath).openStream()) {
                ByteStreams.copy(is, os);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    });
    if (!rootProject.file(".baseline").exists()) {
        rootProject.getTasks().getByName("ideaProject").dependsOn(baselineUpdateConfig);
    }
    rootProject.afterEvaluate((p) -> rootProject.getPlugins().withType(IdeaPlugin.class, plugin -> {
        plugin.getModel().getProject().getIpr().withXml(provider -> setupProjectXml(rootProject, provider));
        plugin.getModel().getWorkspace().getIws().withXml(provider -> setupWorkspaceXml(rootProject, provider));
    }));
    rootProject.allprojects(project -> {
        setupRepositories(project);
        project.getPlugins().apply(ResolutionRulesPlugin.class);
        project.getPlugins().withType(JavaPlugin.class, plugin -> setupJavaProject(project));
        project.getPlugins().withType(LicensePlugin.class, unused -> {
            LicenseExtension license = project.getExtensions().getByType(LicenseExtension.class);
            license.exclude("**/*.json");
            license.setHeader(rootProject.file("LICENSE"));
            license.mapping(ImmutableMap.of("conf", "DOUBLESLASH_STYLE", "java", "SLASHSTAR_STYLE", "proto", "SLASHSTAR_STYLE", "yml", "SCRIPT_STYLE"));
        });
    });
    setupDataSources(rootProject);
}
Also used : CreateShellConfigTask(org.curioswitch.gradle.plugins.curiostack.tasks.CreateShellConfigTask) Path(java.nio.file.Path) AptIdeaPlugin(net.ltgt.gradle.apt.AptIdeaPlugin) Closure(groovy.lang.Closure) JavaPlugin(org.gradle.api.plugins.JavaPlugin) IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) ModuleAptConvention(net.ltgt.gradle.apt.AptIdeaPlugin.ModuleAptConvention) DependencyManagementPlugin(io.spring.gradle.dependencymanagement.DependencyManagementPlugin) DslObject(org.gradle.api.internal.plugins.DslObject) Task(org.gradle.api.Task) Javadoc(org.gradle.api.tasks.javadoc.Javadoc) YarnTask(com.moowork.gradle.node.yarn.YarnTask) Map(java.util.Map) LicensePlugin(nl.javadude.gradle.plugins.license.LicensePlugin) ExtensionAware(org.gradle.api.plugins.ExtensionAware) Splitter(com.google.common.base.Splitter) Path(java.nio.file.Path) PythonEnvsExtension(com.jetbrains.python.envs.PythonEnvsExtension) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) Delete(org.gradle.api.tasks.Delete) ImmutableMap(com.google.common.collect.ImmutableMap) Project(org.gradle.api.Project) NodeTask(com.moowork.gradle.node.task.NodeTask) Predicate(java.util.function.Predicate) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ProtobufPlugin(com.google.protobuf.gradle.ProtobufPlugin) SetupGitHooks(org.curioswitch.gradle.plugins.curiostack.tasks.SetupGitHooks) SpotlessExtension(com.diffplug.gradle.spotless.SpotlessExtension) AptPlugin(net.ltgt.gradle.apt.AptPlugin) JavaVersion(org.gradle.api.JavaVersion) StandardCharsets(java.nio.charset.StandardCharsets) UncheckedIOException(java.io.UncheckedIOException) JavaLibraryPlugin(org.gradle.api.plugins.JavaLibraryPlugin) List(java.util.List) CoreJavadocOptions(org.gradle.external.javadoc.CoreJavadocOptions) VersionsPlugin(com.github.benmanes.gradle.versions.VersionsPlugin) YarnInstallTask(com.moowork.gradle.node.yarn.YarnInstallTask) BaselineIdea(com.palantir.baseline.plugins.BaselineIdea) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) PluginContainer(org.gradle.api.plugins.PluginContainer) ExecSpec(org.gradle.process.ExecSpec) DependencySet(org.curioswitch.gradle.plugins.curiostack.StandardDependencies.DependencySet) XmlProvider(org.gradle.api.XmlProvider) LicenseExtension(nl.javadude.gradle.plugins.license.LicenseExtension) JooqPlugin(nu.studer.gradle.jooq.JooqPlugin) CurioGenericCiPlugin(org.curioswitch.gradle.plugins.ci.CurioGenericCiPlugin) ErrorPronePlugin(net.ltgt.gradle.errorprone.ErrorPronePlugin) NodePlugin(com.moowork.gradle.node.NodePlugin) HashMap(java.util.HashMap) BasePlugin(org.gradle.api.plugins.BasePlugin) SourceSet(org.gradle.api.tasks.SourceSet) Configuration(org.gradle.api.artifacts.Configuration) JMHPluginExtension(me.champeau.gradle.JMHPluginExtension) ImmutableList(com.google.common.collect.ImmutableList) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) DependencyManagementExtension(io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) JooqTask(nu.studer.gradle.jooq.JooqTask) CreateShellConfigTask(org.curioswitch.gradle.plugins.curiostack.tasks.CreateShellConfigTask) NodeExtension(com.moowork.gradle.node.NodeExtension) Test(org.gradle.api.tasks.testing.Test) PythonEnvsPlugin(com.jetbrains.python.envs.PythonEnvsPlugin) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) Resources(com.google.common.io.Resources) NpmTask(com.moowork.gradle.node.npm.NpmTask) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) Jar(org.gradle.jvm.tasks.Jar) FileOutputStream(java.io.FileOutputStream) JMHPlugin(me.champeau.gradle.JMHPlugin) SpotlessTask(com.diffplug.gradle.spotless.SpotlessTask) IOException(java.io.IOException) Node(groovy.util.Node) GcloudPlugin(org.curioswitch.gradle.plugins.gcloud.GcloudPlugin) File(java.io.File) SpotlessPlugin(com.diffplug.gradle.spotless.SpotlessPlugin) ProtobufSourceDirectorySet(com.google.protobuf.gradle.ProtobufSourceDirectorySet) Os(org.apache.tools.ant.taskdefs.condition.Os) Paths(java.nio.file.Paths) ResolutionRulesPlugin(nebula.plugin.resolutionrules.ResolutionRulesPlugin) CommandUtil(org.curioswitch.gradle.plugins.shared.CommandUtil) JavaExec(org.gradle.api.tasks.JavaExec) LambdaClosure(org.curioswitch.gradle.common.LambdaClosure) Plugin(org.gradle.api.Plugin) Copy(org.gradle.api.tasks.Copy) InputStream(java.io.InputStream) Task(org.gradle.api.Task) YarnTask(com.moowork.gradle.node.yarn.YarnTask) NodeTask(com.moowork.gradle.node.task.NodeTask) YarnInstallTask(com.moowork.gradle.node.yarn.YarnInstallTask) JooqTask(nu.studer.gradle.jooq.JooqTask) CreateShellConfigTask(org.curioswitch.gradle.plugins.curiostack.tasks.CreateShellConfigTask) NpmTask(com.moowork.gradle.node.npm.NpmTask) SpotlessTask(com.diffplug.gradle.spotless.SpotlessTask) PluginContainer(org.gradle.api.plugins.PluginContainer) LicenseExtension(nl.javadude.gradle.plugins.license.LicenseExtension) InputStream(java.io.InputStream) AptIdeaPlugin(net.ltgt.gradle.apt.AptIdeaPlugin) IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) YarnInstallTask(com.moowork.gradle.node.yarn.YarnInstallTask) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Aggregations

SpotlessExtension (com.diffplug.gradle.spotless.SpotlessExtension)1 SpotlessPlugin (com.diffplug.gradle.spotless.SpotlessPlugin)1 SpotlessTask (com.diffplug.gradle.spotless.SpotlessTask)1 VersionsPlugin (com.github.benmanes.gradle.versions.VersionsPlugin)1 Splitter (com.google.common.base.Splitter)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ByteStreams (com.google.common.io.ByteStreams)1 Resources (com.google.common.io.Resources)1 ProtobufPlugin (com.google.protobuf.gradle.ProtobufPlugin)1 ProtobufSourceDirectorySet (com.google.protobuf.gradle.ProtobufSourceDirectorySet)1 PythonEnvsExtension (com.jetbrains.python.envs.PythonEnvsExtension)1 PythonEnvsPlugin (com.jetbrains.python.envs.PythonEnvsPlugin)1 NodeExtension (com.moowork.gradle.node.NodeExtension)1 NodePlugin (com.moowork.gradle.node.NodePlugin)1 NpmTask (com.moowork.gradle.node.npm.NpmTask)1 NodeTask (com.moowork.gradle.node.task.NodeTask)1 YarnInstallTask (com.moowork.gradle.node.yarn.YarnInstallTask)1 YarnTask (com.moowork.gradle.node.yarn.YarnTask)1