Skip to content

armgit / core

Public Imported from GitHub
0

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

2.7 KB
Raw Blame
plugins {
  id 'java-library'
}

var setupJar = project.hasProperty("SETUP_JAR") ? project.property("SETUP_JAR") : ""

base {
  archivesName = "openremote-${setupJar}-${project.name}"
}

sourceSets {
  clustering
  datetime
  demo
  integration
  load1
  load2
  notification
}

// dependencies declaration
configurations {
  clusteringImplementation.extendsFrom(implementation)
  datetimeImplementation.extendsFrom(implementation)
  demoImplementation.extendsFrom(implementation)
  integrationImplementation.extendsFrom(implementation)
  load1Implementation.extendsFrom(implementation)
  load2Implementation.extendsFrom(implementation)
  notificationImplementation.extendsFrom(implementation)
}

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) {
  archiveBaseName.set("openremote-clustering-${project.name}")
  from sourceSets.clustering.output
}

tasks.register('datetimeJar', Jar) {
  archiveBaseName.set("openremote-datetime-${project.name}")
  from sourceSets.datetime.output
}

tasks.register('load1Jar', Jar) {
  archiveBaseName.set("openremote-load1-${project.name}")
  from sourceSets.load1.output
}

tasks.register('load2Jar', Jar) {
  archiveBaseName.set("openremote-load2-${project.name}")
  from sourceSets.load2.output
}

tasks.register('notificationJar', Jar) {
  archiveBaseName.set("openremote-notification-${project.name}")
  from sourceSets.notification.output
}

tasks.named("compileJava") {
  dependsOn("load1Jar", "load2Jar")
}

tasks.register('installDist', Copy) {
  def setupTask = getTasksByName("${setupJar}Jar", false)[0] as org.gradle.jvm.tasks.Jar
  if (setupTask != null) {
    System.out.println(setupTask.name)
    dependsOn setupTask
    dependsOn ":manager:installDist"
    from setupTask.archiveFile
    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
  }
}