Skip to content

armgit / core

Public Imported from GitHub
0

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

Use demo sourceSet for demo extensions (#3271)

Wouter Bornc7c1c4c962c6
diff --git a/manager/build.gradle b/manager/build.gradle
index d7835a01c..4a860415d 100644
--- a/manager/build.gradle
+++ b/manager/build.gradle
@@ -14,10 +14,6 @@ application {
mainClass = "org.openremote.manager.Main"
}
-configurations {
- demoExtension
-}
-
dependencies {
api project(":container")
@@ -62,12 +58,6 @@ dependencies {
implementation libs.sshdNetty
- // Select the newest published demo extension up to and including the
- // current project version, falling back to an earlier version when the
- // current version has not been published yet.
- def demoExtensionMaxVersion = project.version.toString().replaceFirst(/-SNAPSHOT$/, "")
- demoExtension "io.openremote.extension:openremote-demo-setup-extension:(,${demoExtensionMaxVersion}]"
-
testImplementation libs.groovyAll
testImplementation platform(libs.spockBom)
testImplementation libs.spockCore
@@ -127,7 +117,7 @@ tasks.withType(Sync).configureEach {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
-tasks.withType(Tar){
+tasks.withType(Tar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
@@ -253,17 +243,11 @@ publish.dependsOn(setVersionProperties)
processResources.dependsOn(setVersionProperties)
sourcesJar.dependsOn(setVersionProperties)
-
tasks.named("run", JavaExec) {
- def setupType = System.getenv("OR_SETUP_TYPE")
- if (setupType != null) {
- classpath += configurations.demoExtension
- classpath += files({
- def setupProject = project(':setup')
- def targetSourceSet = setupProject.sourceSets.findByName(setupType)
- if (targetSourceSet != null) {
- return targetSourceSet.output
- }
- })
+ doFirst {
+ def setupType = providers.environmentVariable("OR_SETUP_TYPE").orNull?.trim()
+ if (setupType) {
+ throw new GradleException("OR_SETUP_TYPE is not supported by manager:run. Use setup:run instead.")
+ }
}
}
diff --git a/project.gradle b/project.gradle
index 9065bb367..9f46f2648 100644
--- a/project.gradle
+++ b/project.gradle
@@ -162,7 +162,7 @@ if (project == rootProject) {
workingDirectory = projectDir.toString()
}
"Demo Setup"(Application) {
- moduleName = getProject().idea.module.name + ".manager.main"
+ moduleName = getProject().idea.module.name + ".setup.demo"
envs = [
OR_SETUP_TYPE: "demo"
]
diff --git a/setup/build.gradle b/setup/build.gradle
index 0523c06fb..68a0d5503 100644
--- a/setup/build.gradle
+++ b/setup/build.gradle
@@ -2,7 +2,7 @@ plugins {
id 'java-library'
}
-var setupJar = project.hasProperty("SETUP_JAR") ? project.getProperties().get("SETUP_JAR") : ""
+var setupJar = project.hasProperty("SETUP_JAR") ? project.property("SETUP_JAR") : ""
base {
archivesName = "openremote-${setupJar}-${project.name}"
@@ -10,6 +10,7 @@ base {
sourceSets {
clustering
+ demo
integration
load1
load2
@@ -19,6 +20,7 @@ sourceSets {
// dependencies declaration
configurations {
clusteringImplementation.extendsFrom(implementation)
+ demoImplementation.extendsFrom(implementation)
integrationImplementation.extendsFrom(implementation)
load1Implementation.extendsFrom(implementation)
load2Implementation.extendsFrom(implementation)
@@ -27,6 +29,14 @@ configurations {
dependencies {
implementation project(":manager")
+
+ // Select the newest published extensions up to and including the
+ // current project version, falling back to an earlier version when the
+ // current version has not been published yet.
+ def extensionMaxVersion = project.version.toString().replaceFirst(/-SNAPSHOT$/, "")
+ demoRuntimeOnly("io.openremote.extension:openremote-demo-setup-extension:(,${extensionMaxVersion}]") {
+ exclude group: "io.openremote"
+ }
}
tasks.register('clusteringJar', Jar) {
@@ -63,3 +73,17 @@ tasks.register('installDist', Copy) {
into project(":manager").layout.buildDirectory.dir("install/manager/deployment/manager/extensions")
}
}
+
+tasks.register("run", JavaExec) {
+ group = "application"
+ description = "Runs the manager with the setup selected by OR_SETUP_TYPE"
+ mainClass = "org.openremote.manager.Main"
+ workingDir = rootProject.projectDir
+
+ def setupType = providers.environmentVariable("OR_SETUP_TYPE").orNull?.trim()
+ if (!setupType || !sourceSets.names.contains(setupType)) {
+ classpath = sourceSets.main.runtimeClasspath
+ } else {
+ classpath = sourceSets.named(setupType).get().runtimeClasspath
+ }
+}