Skip to content

Commit

Permalink
Use UI JARs in IDE and some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wborn committed Sep 27, 2024
1 parent e68340e commit 74986ab
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 51 deletions.
4 changes: 2 additions & 2 deletions agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: "java-library"

dependencies {
api resolveDependency(":agent")
api project(":model")
api "io.openremote:openremote-agent:$openremoteVersion"
}

task installDist {
tasks.register('installDist') {
dependsOn jar
}
6 changes: 3 additions & 3 deletions deployment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies {
api project(":setup")
}

task license {
tasks.register('license') {
doLast {
def licenseFiles = new ArrayList<>()
if (findProject(":openremote")) {
Expand All @@ -25,9 +25,9 @@ task license {
}
}

task installDist(type: Copy) {
tasks.register('installDist', Copy) {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
dependsOn (parent.getTasksByName('installDist', true).findAll {
dependsOn(parent.getTasksByName('installDist', true).findAll {
// Don't create circular dependency or depend on built in openremote submodule apps
it.project != project && !it.project.path.startsWith(":openremote:ui:app")
})
Expand Down
6 changes: 3 additions & 3 deletions manager/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: "java-library"

dependencies {
api resolveDependency(":container")
api resolveDependency(":manager")
api project(":agent")
api project(":model")
api "io.openremote:openremote-container:$openremoteVersion"
api "io.openremote:openremote-manager:$openremoteVersion"
}

task installDist {
tasks.register('installDist') {
dependsOn jar
}
4 changes: 2 additions & 2 deletions model/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apply plugin: "java-library"

dependencies {
api resolveDependency(":model")
api "io.openremote:openremote-model:$openremoteVersion"
}

task installDist {
tasks.register('installDist') {
dependsOn jar
}
49 changes: 25 additions & 24 deletions project.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Common configuration applied to all projects
import java.nio.file.*
import java.nio.file.attribute.*
import java.util.Set
import java.util.stream.Collectors
import java.util.stream.Stream
import java.util.stream.StreamSupport

import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS
Expand Down Expand Up @@ -152,6 +152,7 @@ repositories {
maven {
url "https://pkgs.dev.azure.com/OpenRemote/OpenRemote/_packaging/OpenRemote/maven/v1"
}
mavenLocal()
maven {
url "https://s01.oss.sonatype.org/content/repositories/snapshots"
}
Expand Down Expand Up @@ -242,10 +243,10 @@ def createTSGeneratorConfig(boolean outputAPIClient, String outputFileName, Proj
srcPath = files[0]
}
}
java.nio.file.Path packagePath = it.toPath().relativize(srcPath.toPath())
Path packagePath = it.toPath().relativize(srcPath.toPath())
return StreamSupport
.stream(packagePath.spliterator(), false)
.map(java.nio.file.Path::toString)
.map(Path::toString)
.collect(Collectors.joining(".")) + (outputAPIClient ? ".**Resource" : ".**")
}
}.toList()
Expand Down Expand Up @@ -288,10 +289,6 @@ def createTSGeneratorConfig(boolean outputAPIClient, String outputFileName, Proj
}
}

def resolveDependency(String path) {
"io.openremote:openremote-" + path.substring(1) + ":" + version
}

def resolveTask(String path) {
tasks.getByPath(path)
}
Expand All @@ -313,18 +310,22 @@ def getDeploymentJars(Project project = project) {
return []
}

return project.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.findAll {
dep -> dep.name != "openremote-manager" }.collect {
println "CopyLibs Artifact: ${it.file.path}"
return it.file
}
def excludedDepNames = Stream.of("console_loader", "insights", "manager", "shared", "swagger")
.map(s -> "openremote-" + s)
.collect(Collectors.toSet())

return project.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts
.findAll { !excludedDepNames.contains(it.name) }
.collect {
println "CopyLibs Artifact: ${it.file.path}"
return it.file
}
}

ext {
resolveTask = this.&resolveTask
getYarnInstallTask = this.&getYarnInstallTask
getDeploymentJars = this.&getDeploymentJars
resolveDependency = this.&resolveDependency
createTSGeneratorConfigForClient = this.&createTSGeneratorConfigForClient
createTSGeneratorConfigForModel = this.&createTSGeneratorConfigForModel
}
Expand All @@ -336,45 +337,45 @@ ext.npmCommand = {
}

// Add yarn tasks
task yarnInstall(type: Exec){
tasks.register('yarnInstall', Exec) {
commandLine npmCommand("yarn"), "install"
}
task yarnInstallForce(type: Exec){
tasks.register('yarnInstallForce', Exec) {
commandLine npmCommand("yarn"), "install", "--force"
}

task npmClean(type: Exec){
tasks.register('npmClean', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "clean"
}
task npmBuild(type: Exec){
tasks.register('npmBuild', Exec) {
mustRunAfter npmClean
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "build"
}
task npmTest(type: Exec){
tasks.register('npmTest', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "test"
}
task npmServe(type: Exec){
tasks.register('npmServe', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "serve"
}
task npmPrepare(type: Exec){
tasks.register('npmPrepare', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "prepublishOnly"
}
task npmPublish(type: Exec){
tasks.register('npmPublish', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "publish"
}
task npmServeProduction(type: Exec) {
tasks.register('npmServeProduction', Exec) {
dependsOn getYarnInstallTask()
commandLine npmCommand("yarn"), "run", "serveProduction"
}

// Add typescript tasks
task tscWatch(type: Exec) {
tasks.register('tscWatch', Exec) {
commandLine npmCommand("npx"), "tsc", "-b", "--watch"
}

Expand All @@ -396,7 +397,7 @@ plugins.withType(JavaPlugin).whenPluginAdded {
}

// Allow dependencyInsight checks across all projects
task allDependencyInsight(type: DependencyInsightReportTask) {}
tasks.register('allDependencyInsight', DependencyInsightReportTask) {}

// JAR/ZIP base name is the fully qualified subproject name
archivesBaseName = "${rootProject.name}${path.replaceAll(":", "-")}"
Expand Down
8 changes: 7 additions & 1 deletion setup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ dependencies {
api project(":agent")
api project(":model")
api project(":manager")

implementation "io.openremote.ui:openremote-console_loader:$openremoteVersion"
implementation "io.openremote.ui:openremote-insights:$openremoteVersion"
implementation "io.openremote.ui:openremote-manager:$openremoteVersion"
implementation "io.openremote.ui:openremote-shared:$openremoteVersion"
implementation "io.openremote.ui:openremote-swagger:$openremoteVersion"
}

task installDist {
tasks.register('installDist') {
dependsOn jar
}
2 changes: 1 addition & 1 deletion test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
api project(":manager")
api project(":model")
api project(":agent")
testImplementation(resolveDependency(":test"))
testImplementation "io.openremote:openremote-test:$openremoteVersion"
// testImplementation(testFixtures())
}

Expand Down
4 changes: 2 additions & 2 deletions ui/app/custom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
buildDir = "dist"

task clean {
tasks.register('clean') {
dependsOn npmClean
}

task installDist(type: Copy) {
tasks.register('installDist', Copy) {
dependsOn npmBuild
mustRunAfter(resolveTask(":manager:installDist"))
from project.buildDir
Expand Down
2 changes: 1 addition & 1 deletion ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ afterEvaluate {
}
}

task modelWatch {
tasks.register('modelWatch') {
dependsOn resolveTask(":ui:component:model:build"), resolveTask(":ui:component:rest:build")
}
11 changes: 5 additions & 6 deletions ui/component/model/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "cz.habarta.typescript-generator:typescript-generator-gradle-plugin:$typescriptGeneratorVersion"
Expand All @@ -15,9 +14,9 @@ plugins {
}

dependencies {
compileOnly resolveDependency(":model-util")
implementation findProject(":model")
implementation findProject(":agent")
compileOnly "io.openremote:openremote-model-util:$openremoteVersion"
implementation project(":agent")
implementation project(":model")
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion"
implementation "com.fasterxml.jackson.module:jackson-module-parameter-names:$jacksonVersion"
Expand All @@ -36,10 +35,10 @@ clean {
}
}

task prepareUi() {
tasks.register('prepareUi') {
dependsOn clean, npmPrepare
}

task publishUi() {
tasks.register('publishUi') {
dependsOn clean, npmPublish
}
11 changes: 5 additions & 6 deletions ui/component/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ apply plugin: "cz.habarta.typescript-generator"
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "cz.habarta.typescript-generator:typescript-generator-gradle-plugin:$typescriptGeneratorVersion"
}
}

dependencies {
compileOnly resolveDependency(":model-util")
implementation findProject(":model")
implementation findProject(":agent")
compileOnly "io.openremote:openremote-model-util:$openremoteVersion"
implementation project(":agent")
implementation project(":model")
implementation "cz.habarta.typescript-generator:typescript-generator-core:$typescriptGeneratorVersion"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion"
Expand All @@ -34,10 +33,10 @@ clean {
build.dependsOn generateTypeScript, npmBuild
npmBuild.dependsOn generateTypeScript

task prepareUi() {
tasks.register('prepareUi') {
dependsOn clean, build, npmPrepare
}

task publishUi() {
tasks.register('publishUi') {
dependsOn clean, build, npmPublish
}

0 comments on commit 74986ab

Please sign in to comment.