Permalink
Browse files

Fixed paths for local NodeJS tasks

  • Loading branch information...
christianbauer committed Nov 24, 2017
1 parent d56372b commit c1c39fdf1af967cb79e28bb74d514e9a84311992
Showing with 26 additions and 9 deletions.
  1. +26 −9 project.gradle
View
@@ -52,31 +52,48 @@ if(project.convention.findPlugin(JavaPluginConvention)) {
// subproject, not for its children!)
version = hasProperty("openremoteVersion") ? openremoteVersion : projectVersion
// Add console NodeJS plugin configuration and tasks
// Add NodeJS plugin configuration and tasks
apply plugin: com.moowork.gradle.node.NodePlugin
def nodeDir = "${rootDir}/.node"
// Configuration of paths is completely broken in the gradle node plugin, this approach
// is the only one that results in a predictable location for installed modules
def nodeExtDir = "${nodeDir}/ext"
node {
download = true
version = nodeJSVersion
workDir = file(nodeDir)
workDir = file("${rootDir}/.node")
}
def nodeDir = {
def osName = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsName()
def osArch = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsArch()
def version = node.version
node.workDir.absolutePath + File.separator + "node-v${version}-${osName}-${osArch}"
}
def nodeModuleDir = {
isFamily(FAMILY_WINDOWS) ? "${nodeDir()}/node_modules" : "${nodeDir()}/lib/node_modules"
}
def nodeModuleGlobal = {
file("${nodeModuleDir()}/${it}/bin/${it}")
}
def nodeModuleLocal = {
file("${projectDir}/node_modules/${it}/bin/${it}")
}
// Add bower tasks
task bowerInstall(type: NpmTask) {
args = ['install', '--prefix', nodeExtDir, '-g', 'bower']
dependsOn nodeSetup
args = ['install', '-g', 'bower']
outputs.upToDateWhen {
nodeModuleGlobal('bower').exists()
}
}
task bowerUpdate(type: NodeTask) {
dependsOn bowerInstall
script = file("${nodeExtDir}/bin/bower")
script = nodeModuleGlobal('bower')
args = ['update']
inputs.file("${project.projectDir}/bower.json")
}
task bowerPrune(type: NodeTask) {
dependsOn bowerInstall
script = file("${nodeExtDir}/bin/bower")
script = nodeModuleGlobal('bower')
args = ['prune']
inputs.file("${project.projectDir}/bower.json")
}
// Configure Java build

0 comments on commit c1c39fd

Please sign in to comment.