Skip to content

armgit / core

Public Imported from GitHub
0

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

Cleanup gradle UI build tasks

Rich Turner8639c590e292
diff --git a/build.gradle b/build.gradle
index a1197139a..975b3f89e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,6 @@ allprojects {
task clean {
if (isCustomProject()) {
doFirst {
- println("DELETE NODE MODULES!!!!!")
delete "node_modules"
}
}
diff --git a/project.gradle b/project.gradle
index 2122fd581..06e462ef3 100644
--- a/project.gradle
+++ b/project.gradle
@@ -1,4 +1,7 @@
// Common configuration applied to all projects
+
+import java.nio.file.Paths
+
import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS
import static org.apache.tools.ant.taskdefs.condition.Os.isFamily
import static org.jetbrains.gradle.ext.ShortenCommandLine.MANIFEST
@@ -144,6 +147,21 @@ def resolveTask(String path) {
tasks.getByPath(resolvePath(path))
}
+def getYarnInstallTask() {
+ if (isCustomProject()) {
+ def customPackageJsonFile = Paths.get(rootProject.projectDir.path, "package.json").toFile()
+ if (!customPackageJsonFile.exists()) {
+ // No custom project yarn package.json so use standard openremote repo package.json
+ return resolveTask(":yarnInstall")
+ } else {
+ return tasks.getByPath(":yarnInstall")
+ }
+ } else {
+ // Just use openremote repo yarn install
+ resolveTask(":yarnInstall")
+ }
+}
+
ext {
resolvePath = this.&resolvePath
resolveProject = this.&resolveProject
@@ -181,32 +199,32 @@ task npmInstall(type: Exec){
commandLine npmCommand("npm"), "install"
}
task npmClean(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "clean"
}
task npmBuild(type: Exec){
mustRunAfter npmClean
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "build"
}
task npmTest(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "test"
}
task npmServe(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "serve"
}
task npmPrepare(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "prepublishOnly"
}
task npmPublish(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "publish"
}
task npmServeProduction(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
+ dependsOn getYarnInstallTask()
commandLine npmCommand("npm"), "run-script", "serveProduction"
}
diff --git a/ui/build.gradle b/ui/build.gradle
index 020c52ddb..97df27d70 100644
--- a/ui/build.gradle
+++ b/ui/build.gradle
@@ -1,38 +1,13 @@
-import java.nio.file.Paths
afterEvaluate {
-
- // Ensure main repo ui installDist tasks are performed before the custom projects
- if (isCustomProject() && parent == rootProject) {
- def customUi = findProject(':ui')
- if (customUi != null) {
- customUi.getTasksByName('installDist', true).forEach {
- it.mustRunAfter(project(":openremote:ui").getTasksByName('installDist', true))
- it.mustRunAfter(resolveTask(":deployment:installDist"))
- }
- }
- }
-
- // Ensure yarn install in openremote repo is run if no package.json in custom project
- if (isCustomProject() && parent != rootProject) {
- def packageJsonFile = Paths.get(rootProject.projectDir.path, "package.json").toFile()
- if (!packageJsonFile.exists()) {
- println("Adding dependency on openremote yarn install to root project yarn install")
- tasks.getByPath(":yarnInstall").dependsOn(resolveTask(":yarnInstall"))
- }
- }
-
// Add dependencies on model and rest typescript generation
- it.getTasksByName('prepareUi', true).forEach {
- it.dependsOn resolveTask(":ui:component:model:generateTypeScript"), resolveTask(":ui:component:rest:generateTypeScript")
- }
- it.getTasksByName('publishUi', true).forEach {
+ rootProject.getTasksByName('prepareUi', true).forEach {
it.dependsOn resolveTask(":ui:component:model:generateTypeScript"), resolveTask(":ui:component:rest:generateTypeScript")
}
- it.getTasksByName('npmBuild', true).forEach {
+ rootProject.getTasksByName('publishUi', true).forEach {
it.dependsOn resolveTask(":ui:component:model:generateTypeScript"), resolveTask(":ui:component:rest:generateTypeScript")
}
- it.getTasksByName('installDist', true).forEach {
+ rootProject.getTasksByName('npmBuild', true).forEach {
it.dependsOn resolveTask(":ui:component:model:generateTypeScript"), resolveTask(":ui:component:rest:generateTypeScript")
}
}