Search in sources :

Example 1 with NodeExtension

use of com.moowork.gradle.node.NodeExtension in project curiostack by curioswitch.

the class CuriostackPlugin method setupProjectXml.

private static void setupProjectXml(Project project, XmlProvider xml) {
    NodeExtension nodeConfig = project.getExtensions().getByType(NodeExtension.class);
    Node typescriptCompiler = findOrCreateChild(xml.asNode(), "component", "TypeScriptCompiler");
    setOption(typescriptCompiler, "typeScriptServiceDirectory", project.file("node_modules/typescript").getAbsolutePath());
    setOption(typescriptCompiler, "nodeInterpreterTextField", nodeConfig.getVariant().getNodeExec());
    setOption(typescriptCompiler, "versionType", "SERVICE_DIRECTORY");
    Node angularComponent = findOrCreateChild(xml.asNode(), "component", "AngularJSSettings");
    setOption(angularComponent, "useService", "false");
    Node inspectionManager = findOrCreateChild(xml.asNode(), "component", "InspectionProjectProfileManager");
    Node profile = findChild(inspectionManager, n -> n.name().equals("profile")).orElseGet(() -> inspectionManager.appendNode("profile", ImmutableMap.of("version", "1.0")));
    setOption(profile, "myName", "Project Default");
    findChild(profile, n -> n.name().equals("inspection_tool") && "TsLint".equals(n.attribute("class"))).orElseGet(() -> profile.appendNode("inspection_tool", ImmutableMap.of("class", "TsLint", "enabled", "true", "level", "ERROR", "enabled_by_default", "true")));
}
Also used : 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) Node(groovy.util.Node) NodeExtension(com.moowork.gradle.node.NodeExtension)

Example 2 with NodeExtension

use of com.moowork.gradle.node.NodeExtension in project curiostack by curioswitch.

the class CuriostackPlugin method setupWorkspaceXml.

private static void setupWorkspaceXml(Project project, XmlProvider xml) {
    NodeExtension nodeConfig = project.getExtensions().getByType(NodeExtension.class);
    Node properties = findOrCreateChild(xml.asNode(), "component", "PropertiesComponent");
    setProperty(properties, "node.js.path.for.package.tslint", nodeConfig.getVariant().getNodeExec());
    setProperty(properties, "node.js.detected.package.tslint", "true");
    setProperty(properties, "node.js.selected.package.tslint", project.file("node_modules/tslint").getAbsolutePath());
    setProperty(properties, "typescript-compiler-editor-notification", "false");
}
Also used : Node(groovy.util.Node) NodeExtension(com.moowork.gradle.node.NodeExtension)

Example 3 with NodeExtension

use of com.moowork.gradle.node.NodeExtension in project curiostack by curioswitch.

the class CuriostackPlugin method setupNode.

private static void setupNode(Project project, CreateShellConfigTask rehash) {
    NodeExtension node = project.getExtensions().getByType(NodeExtension.class);
    node.setVersion(NODE_VERSION);
    node.setYarnVersion(YARN_VERSION);
    node.setDownload(true);
    Closure<?> pathOverrider = LambdaClosure.of((ExecSpec exec) -> {
        String actualCommand = exec.getExecutable() + " " + String.join(" ", exec.getArgs());
        exec.setCommandLine("bash", "-c", ". " + CommandUtil.getCondaBaseDir(project).resolve("etc/profile.d/conda.sh").toString() + " && conda activate > /dev/null && cd " + exec.getWorkingDir().toString() + " && " + actualCommand);
        exec.getEnvironment().put("PATH", CommandUtil.getPythonBinDir(project, "build") + File.pathSeparator + exec.getEnvironment().get("PATH"));
    });
    project.getTasks().withType(NodeTask.class, t -> t.setExecOverrides(pathOverrider));
    project.getTasks().withType(NpmTask.class, t -> t.setExecOverrides(pathOverrider));
    project.getTasks().withType(YarnTask.class, t -> t.setExecOverrides(pathOverrider));
    node.setWorkDir(CommandUtil.getNodeDir(project).toFile());
    node.setNpmWorkDir(CommandUtil.getNpmDir(project).toFile());
    node.setYarnWorkDir(CommandUtil.getYarnDir(project).toFile());
    project.afterEvaluate(n -> {
        rehash.path(node.getVariant().getNodeBinDir().toPath());
        rehash.path(node.getVariant().getYarnBinDir().toPath());
        rehash.path(node.getVariant().getNpmBinDir().toPath());
    });
    project.getTasks().getByName("nodeSetup", t -> {
        t.dependsOn("pythonSetup");
        t.onlyIf(unused -> !node.getVariant().getNodeDir().exists());
    });
    project.getTasks().findByName("yarnSetup").onlyIf(t -> !node.getVariant().getYarnDir().exists());
    // Since yarn is very fast, go ahead and clean node_modules too to prevent
    // inconsistency.
    project.getPluginManager().apply(BasePlugin.class);
    project.getTasks().getByName(BasePlugin.CLEAN_TASK_NAME, task -> ((Delete) task).delete(project.file("node_modules")));
}
Also used : NodeExtension(com.moowork.gradle.node.NodeExtension) ExecSpec(org.gradle.process.ExecSpec)

Aggregations

NodeExtension (com.moowork.gradle.node.NodeExtension)3 Node (groovy.util.Node)2 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 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