100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
import java.nio.file.Paths
plugins {
id 'java-library'
id 'groovy'
id 'application'
id 'distribution'
id 'maven-publish'
id 'signing'
alias libs.plugins.swagger
}
application {
mainClass = "org.openremote.manager.Main"
}
configurations {
otelJavaAgent {
canBeConsumed = false
canBeResolved = true
transitive = false
}
}
dependencies {
api project(":container")
api project(":agent")
api project(":model")
implementation libs.sqliteJdbc
api libs.ical4j
implementation libs.geotoolsMain
implementation libs.firebaseAdmin
implementation libs.angusMail
implementation libs.swaggerJaxrs2Jakarta
implementation libs.camelUndertow
implementation libs.twelveMonkeysImageIoBmp
// Indirect dep from org.apache.activemq:artemis-mqtt-protocol
api(libs.nettyCodecMqtt) {
version {
strictly libs.versions.netty.get()
}
}
implementation(libs.artemisMqttProtocol) {
exclude group: "org.osgi"
exclude group: "org.jboss.logmanager"
}
// Needed for reference in tests
api(libs.artemisServer) {
exclude group: "org.osgi"
exclude group: "org.jboss.logmanager"
}
implementation(libs.quartz) {
exclude module: "c3p0"
exclude module: "HikariCP-java7"
}
implementation libs.suncalc
implementation libs.prometheusMetricsExporterHttpserver
implementation libs.sshdNetty
otelJavaAgent libs.opentelemetryJavaagent
testImplementation libs.groovyAll
testImplementation platform(libs.spockBom)
testImplementation libs.spockCore
testImplementation libs.byteBuddy
testImplementation libs.byteBuddyAgent
testRuntimeOnly libs.objenesis
}
sourceSets {
test {
groovy.srcDirs = ['src/test/groovy', 'test/src/groovy']
}
}
base {
archivesName = "openremote-${project.name}"
}
configurations {
runtime {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
}
artifacts {
runtime(jar)
}
afterEvaluate {
// Change the working directory for the run task
tasks.run.workingDir = rootProject.projectDir
}
resolve {
outputFileName = 'openapi'
outputFormat = 'JSONANDYAML'
outputDir = layout.buildDirectory.dir("openapi")
prettyPrint = true
sortOutput = true
defaultResponseCode = '200'
classpath = sourceSets.main.runtimeClasspath
// Required so that the plugin itself uses the Jakarta Swagger/JAX-RS
// dependencies from the OpenRemote runtime classpath.
buildClasspath = sourceSets.main.runtimeClasspath
resourcePackages = ['org.openremote.model']
openApiFile = layout.projectDirectory.file('src/main/resources/openapi-base.yaml')
objectMapperProcessorClass = 'org.openremote.manager.web.ManagerObjectMapperProcessor'
}
tasks.withType(Sync).configureEach {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Tar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Zip) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
distributions {
main {
contents {
from(project.projectDir) {
include("*Dockerfile", "entrypoint.sh", "heapdump-rename.sh")
}
into("web") {
from("${rootDir}/LICENSE.txt")
}
into("map") {
from("${projectDir}/src/map")
}
into("opentelemetry") {
from(configurations.otelJavaAgent) {
rename { "opentelemetry-javaagent.jar" }
}
}
}
}
}
javadoc {
failOnError = false
}
java {
withJavadocJar()
withSourcesJar()
}
def openApiYamlFile = layout.buildDirectory.file('openapi/openapi.yaml')
publishing {
publications {
maven(MavenPublication) {
group = "io.openremote"
artifactId = "openremote-${project.name}"
from components.java
artifact(openApiYamlFile) {
classifier = 'openapi'
extension = 'yaml'
builtBy tasks.named('resolve')
}
pom {
name = 'OpenRemote Manager'
description = 'Provides core container services and is the main component of the OpenRemote backend; add maven {url "https://repo.osgeo.org/repository/release/"} and maven {url "https://pkgs.dev.azure.com/OpenRemote/OpenRemote/_packaging/OpenRemote/maven/v1"} to resolve all dependencies'
url = 'https://github.com/openremote/core'
licenses {
license {
name = 'GNU Affero General Public License v3.0'
url = 'https://www.gnu.org/licenses/agpl-3.0.en.html'
}
}
developers {
developer {
id = 'developers'
name = 'Developers'
email = '[email protected]'
organization = 'OpenRemote'
organizationUrl = 'https://openremote.io'
}
}
scm {
connection = 'scm:git:git://github.com/openremote/core.git'
developerConnection = 'scm:git:ssh://github.com:openremote/core.git'
url = 'https://github.com/openremote/core/tree/main'
}
}
}
}
repositories {
maven {
if (!version.endsWith('-LOCAL')) {
credentials {
username = findProperty("publishUsername")
password = findProperty("publishPassword")
}
}
url = version.endsWith('-LOCAL') ? layout.buildDirectory.dir('repo') : version.endsWith('-SNAPSHOT') ? findProperty("snapshotsRepoUrl") : findProperty("releasesRepoUrl")
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
if (signingKey && signingPassword) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
}
}
tasks.named('resolve') {
dependsOn tasks.named('classes')
}
tasks.register('generateOpenApi') {
group = 'documentation'
description = 'Generates the OpenRemote OpenAPI specification'
dependsOn tasks.named('resolve')
}
// Output version.properties file
tasks.register('setVersionProperties', WriteProperties) {
destinationFile = Paths.get(projectDir.path, "src", "main", "resources", "version.properties").toFile()
property 'version', project.version
}
publish.mustRunAfter(setVersionProperties)
publish.dependsOn(setVersionProperties)
processResources.dependsOn(setVersionProperties)
sourcesJar.dependsOn(setVersionProperties)
tasks.named("run", JavaExec) {
def setupType = providers.environmentVariable("OR_SETUP_TYPE")
doFirst {
if (setupType.orNull?.trim()) {
throw new GradleException("OR_SETUP_TYPE is not supported by manager:run. Use setup:run instead.")
}
}
}