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")));
}
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");
}
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")));
}
Aggregations