From efe1fd278481bb0d3ab1ce67b47ed655d9427e22 Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Thu, 16 Jul 2026 10:39:06 +0200 Subject: [PATCH] Improve Gradle configuration * Use version properties for plugins * Fix deprecations * Enable configuration caching --- build.gradle | 2 +- .../main/groovy/TestSummaryListener.groovy | 32 +++++++++++++++++++ gradle.properties | 4 +++ project.gradle | 15 ++------- settings.gradle | 31 ++++++++++++++---- 5 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 buildSrc/src/main/groovy/TestSummaryListener.groovy diff --git a/build.gradle b/build.gradle index cbe69f0..c0e159b 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ scmVersion { allprojects { // Apply common project setup apply from: "${project.rootDir}/project.gradle" - version = scmVersion.version + version = rootProject.scmVersion.version } subprojects { diff --git a/buildSrc/src/main/groovy/TestSummaryListener.groovy b/buildSrc/src/main/groovy/TestSummaryListener.groovy new file mode 100644 index 0000000..caf5a38 --- /dev/null +++ b/buildSrc/src/main/groovy/TestSummaryListener.groovy @@ -0,0 +1,32 @@ +import org.gradle.api.tasks.testing.TestDescriptor +import org.gradle.api.tasks.testing.TestListener +import org.gradle.api.tasks.testing.TestResult + +class TestSummaryListener implements TestListener, Serializable { + + @Override + void beforeSuite(TestDescriptor suite) {} + + @Override + void afterSuite(TestDescriptor desc, TestResult result) { + if (desc.parent == null) { + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)" + def startItem = '| ' + def endItem = ' |' + def repeatLength = startItem.length() + output.length() + endItem.length() + + println '\n' + + ('-' * repeatLength) + '\n' + + startItem + output + endItem + '\n' + + ('-' * repeatLength) + } + } + + @Override + void beforeTest(TestDescriptor desc) {} + + @Override + void afterTest(TestDescriptor desc, TestResult result) { + println "${desc.className} > ${desc.name} took: ${(result.endTime - result.startTime)}ms" + } +} diff --git a/gradle.properties b/gradle.properties index dcda3f8..c793aca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ +org.gradle.configuration-cache=true org.gradle.jvmargs=-Xmx3g org.gradle.parallel=false @@ -15,5 +16,8 @@ projectName = openremote-extensions openremoteVersion = 1.27.0-SNAPSHOT +axionReleasePluginVersion = 1.21.2 +gradleNexusPublishPluginVersion = 2.0.0 +ideaExtPluginVersion = 1.2 testLoggerVersion = 4.0.0 diff --git a/project.gradle b/project.gradle index 8e2f64d..671dd28 100644 --- a/project.gradle +++ b/project.gradle @@ -174,20 +174,9 @@ plugins.withType(JavaPlugin).whenPluginAdded { } info.events = debug.events info.exceptionFormat = debug.exceptionFormat - - afterTest { desc, result -> - logger.quiet "${desc.className} > ${desc.name} took: ${(result.endTime - result.startTime)}ms" - } - - afterSuite { desc, result -> - if (!desc.parent) { // will match the outermost suite - def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)" - def startItem = '| ', endItem = ' |' - def repeatLength = startItem.length() + output.length() + endItem.length() - println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) - } - } } + + addTestListener(new TestSummaryListener()) } } diff --git a/settings.gradle b/settings.gradle index 3a3c7c1..9dac229 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,15 +1,32 @@ plugins { - id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' apply false - id "org.jetbrains.gradle.plugin.idea-ext" version "1.3" apply false - id 'pl.allegro.tech.build.axion-release' version '1.21.1' apply false + id 'io.github.gradle-nexus.publish-plugin' version "$gradleNexusPublishPluginVersion" apply false + id 'org.jetbrains.gradle.plugin.idea-ext' version "$ideaExtPluginVersion" apply false + id 'pl.allegro.tech.build.axion-release' version "$axionReleasePluginVersion" apply false } rootProject.name = "$projectName" // Include sub-projects dynamically, every directory with a build.gradle (and no .buildignore) -fileTree(dir: rootDir, include: "**/build.gradle", excludes: ["**/node_modules/**", "**/generic_app/**"]) - .filter { it.parent != rootDir } - .filter { !file("${it.parent}/.buildignore").exists() } +fileTree( + dir: rootDir, + include: "**/build.gradle", + excludes: [ + ".git/**", + "**/.git/**", + ".gradle/**", + "**/.gradle/**", + "**/build/**", + "**/node_modules/**", + "**/generic_app/**", + "**/dist/**", + "**/lib/**" + ] +) + .filter { it.parentFile != rootDir } + .filter { !new File(it.parentFile, ".buildignore").exists() } .each { - include it.parent.replace(rootDir.canonicalPath, "").replace("\\", ":").replace("/", ":") + include it.parentFile.canonicalPath + .replace(rootDir.canonicalPath, "") + .replace("\\", ":") + .replace("/", ":") }