Skip to content

Align custom project Gradle lifecycle with Core - #99

Open
wborn wants to merge 4 commits into
mainfrom
fix/gradle-lifecycle-and-yarn-tooling
Open

wborn wants to merge 4 commits into
mainfrom
fix/gradle-lifecycle-and-yarn-tooling

Conversation

@wborn

@wborn wborn commented Nov 12, 2026 •

Copy link
Copy Markdown
Member
  • Add targeted backend and UI test tasks
  • Prepare UI test inputs with optional artifact reuse
  • Coordinate TypeScript builds and fix deployment packaging
  • Add aggregated unit test reports using Core's report task and output path
  • Centralize test groups, reporting, and integration test configuration in testing.gradle
  • Wait up to 30 seconds for PostgreSQL and Keycloak before backend integration test preparation, including direct :test:test runs, and report startup instructions on timeout
  • Document build, test, and report commands, service prerequisites, and custom UI app test dependencies

Similar to openremote/core#3545
Closes openremote/core#3344

- Add targeted backend and UI test tasks
- Prepare UI test inputs with optional artifact reuse
- Coordinate TypeScript builds and fix deployment packaging
- Document build and test commands
- Reuse Core's report task and output path
- Document report generation
@wborn
wborn marked this pull request as ready for review November 12, 2026 10:19
@wborn
wborn requested review from a team and Ekhorn November 12, 2026 10:19

@Miggets7 Miggets7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new lifecycle and test tasks follow openremote/core#3545, and no blocking issues were found. The inline comments cover a few non-blocking points: strict JSON parsing of tsconfig files, an unordered clean and assemble in the rest component tasks, and some duplicated or redundant task wiring.

All 9 changed files were reviewed and compared with the corresponding changes in openremote/core#3545. The parsing of the if (...) return statement in build.gradle was checked separately with Groovy 4.0.33. Gradle builds, the task graph, and the tests were not run for this review.

This review was AI-assisted.

Comment thread ui/build.gradle Outdated
def projects = [configFile] as Set
typeScriptProjects[configFile] = projects
// Track the file read so reference changes invalidate the configuration cache.
def config = new JsonSlurper().parseText(configFile.getText('UTF-8'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parse tsconfig files leniently

tsconfig files are JSONC, but the default JsonSlurper parser rejects comments. If a custom project adds a comment to any tsconfig.json in a reference graph, Gradle configuration fails with a JSON parse error. new JsonSlurper().setType(JsonParserType.LAX) accepts comments. Core has the same code.

Comment thread ui/build.gradle
id 'base'
}

abstract class TypeScriptOutputLock implements BuildService<BuildServiceParameters.None> {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simpler ordering for the TypeScript builds

The output lock and the recursive tsconfig walk add about 50 lines to serialize three TypeScript projects in this repository, and each lock is also held for the whole npmTest run. Making each npmBuild mustRunAfter the npmBuild tasks of its referenced projects would cover the build races with less code. Keeping this file identical to Core is a reasonable argument for leaving it as is.

Comment thread ui/build.gradle Outdated

rootProject.allprojects {
tasks.matching {
it.name in ['installDist', 'prepareUi', 'publishUi', 'npmBuild']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider dropping installDist from this list

This also makes the backend installDist tasks in :manager, :setup, :agent, and :model, which only depend on jar, depend on both generateTypeScript tasks. The UI app installDist tasks already get that dependency through npmBuild. Without installDist here, ./gradlew :manager:installDist no longer generates TypeScript.


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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order clean before assemble

Gradle does not order the tasks in a dependsOn list, so clean can run after assemble and delete its output before npmPrepare runs. This predates the PR, but the line changes here. Adding tasks.named('assemble') { mustRunAfter 'clean' }, for example in the subprojects block of ui/build.gradle, fixes it for both prepareUi and publishUi.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with a dry run

A dry run of :ui:component:rest:prepareUi on main, where this line still reads dependsOn clean, build, npmPrepare, executes the tasks in this order:

:ui:component:rest:build
:ui:component:rest:clean
:ui:component:rest:npmPrepare

clean deletes build/lib, the tsc output that module, types, and exports in package.json point to. npmPrepare only rebuilds build/dist with rspack, so prepareUi leaves an incomplete package. publishUi has the same order. Replacing build with assemble adds no ordering constraint, so this should be fixed in this PR.

@@ -1,5 +1,7 @@
tasks.register('clean', Delete) {
delete layout.buildDirectory
tasks.register('npmBuild', Exec) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider registering npmBuild once

The same npmBuild task is now defined in four build files: custom, custom-react, model, and rest. Registering it once in ui/build.gradle for subprojects that have a package.json, and adding the onlyIf in rest, would keep the definitions from drifting apart. If matching Core's per-module layout matters more, this can stay.

Comment thread build.gradle Outdated

dependencies {
subprojects.forEach { subproject ->
if (subproject.path.startsWith(':ui')) return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the subproject filter easier to read

The extra indentation after return makes the withPlugin block look like the body of the if. Groovy parses it correctly, but it is easy to misread. A single filter avoids that:

dependencies {
  subprojects.findAll { !it.path.startsWith(':ui') && it.path != ':test' }.each { p ->
    p.pluginManager.withPlugin('java') {
      // Aggregate unit test results spread over different projects
      testReportAggregation project(p.path)
    }
  }
}

@Miggets7 Miggets7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordering problem in the rest component's prepareUi and publishUi tasks should be fixed before merge. It predates this PR, but the PR changes those lines, and a dry run confirmed that clean deletes the TypeScript output the package points to. The other inline comments remain non-blocking.

A dry run of :ui:component:rest:prepareUi on main showed clean executing after build and before npmPrepare. The PR branch itself was not run for this review, so its task order was checked by reading the build scripts. Because the rest package is private, the incomplete output cannot be published to npm, but prepareUi still produces a broken package.

This review was AI-assisted.

- Centralize test groups, reporting, and integration test configuration in testing.gradle
- Wait for PostgreSQL and Keycloak before integration test preparation and report startup instructions on timeout
- Document service checks and dependency setup for custom UI app tests
- Parse commented TypeScript configs and handle trailing reference commas
- Order UI cleanup, compilation, and packaging
- Avoid TypeScript generation for backend distribution tasks
- Simplify the unit test reporting filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align Gradle lifecycle tasks with standard conventions

2 participants