Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Use local NodeJS installation to manage Bower dependencies

Christian Bauerd56372b32af7
diff --git a/.gitignore b/.gitignore
index 0288de323..578b8d179 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ local.properties
build/
.gradle
.vagrant
+.node
bin/
out/
diff --git a/gradle.properties b/gradle.properties
index 75962d772..ad34a809e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -37,3 +37,5 @@ saxonHEVersion = 9.8.0-3
jmxtermVersion = 1.0.0
nettyVersion = 4.1.16.Final
flywaydbVersion = 4.2.0
+nodePluginVersion = 1.2.0
+nodeJSVersion = 8.9.0
\ No newline at end of file
diff --git a/project.gradle b/project.gradle
index b2148a8b1..24cffa9ee 100644
--- a/project.gradle
+++ b/project.gradle
@@ -1,6 +1,19 @@
// Common configuration applied to all projects
import static org.apache.tools.ant.taskdefs.condition.Os.*
+// Build plugins
+buildscript {
+ repositories {
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+ }
+
+ dependencies {
+ classpath "com.moowork.gradle:gradle-node-plugin:$nodePluginVersion"
+ }
+}
+
// Default repositories for dependency resolution
repositories {
mavenCentral()
@@ -39,20 +52,31 @@ if(project.convention.findPlugin(JavaPluginConvention)) {
// subproject, not for its children!)
version = hasProperty("openremoteVersion") ? openremoteVersion : projectVersion
-// Add bower tasks
-task bowerPrune(type: Exec){
- commandLine "bower", "prune"
- standardOutput = new ByteArrayOutputStream()
+// Add console 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)
}
-task bowerUpdate(type: Exec){
- commandLine "bower", "update"
- standardOutput = new ByteArrayOutputStream()
+// Add bower tasks
+task bowerInstall(type: NpmTask) {
+ args = ['install', '--prefix', nodeExtDir, '-g', 'bower']
}
-
-task polymerBuild(type: Exec){
- commandLine "polymer", "build"
- standardOutput = new ByteArrayOutputStream()
+task bowerUpdate(type: NodeTask) {
+ dependsOn bowerInstall
+ script = file("${nodeExtDir}/bin/bower")
+ args = ['update']
+}
+task bowerPrune(type: NodeTask) {
+ dependsOn bowerInstall
+ script = file("${nodeExtDir}/bin/bower")
+ args = ['prune']
}
// Configure Java build