This is an automated email from the ASF dual-hosted git repository.
snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 867dda5c Add specialized `polaris-quarkus` build-plugin (#787)
867dda5c is described below
commit 867dda5c732d413a27095b25b5b79583f394cb20
Author: Robert Stupp <[email protected]>
AuthorDate: Wed Jan 15 20:26:11 2025 +0100
Add specialized `polaris-quarkus` build-plugin (#787)
This change adds a `polaris-quarkus` build-plugin based on
`polaris-server`. It has the specialties for Quarkus based projects, like the
implicit `intTest` suite.
This has the nice side effect of not having an unused `intTest` test suite
in every project, and removes a bunch of `if`s.
---
.../src/main/kotlin/polaris-java.gradle.kts | 72 +++++-----------------
.../src/main/kotlin/polaris-quarkus.gradle.kts | 66 ++++++++++++++++++++
quarkus/admin/build.gradle.kts | 2 +-
quarkus/server/build.gradle.kts | 2 +-
quarkus/service/build.gradle.kts | 2 +-
5 files changed, 85 insertions(+), 59 deletions(-)
diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts
b/build-logic/src/main/kotlin/polaris-java.gradle.kts
index 43f25f8b..e5ff7cc5 100644
--- a/build-logic/src/main/kotlin/polaris-java.gradle.kts
+++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts
@@ -98,54 +98,26 @@ testing {
}
)
}
-
- targets.all {
- if (testTask.name != "test") {
- testTask.configure { shouldRunAfter("test") }
- }
- }
}
+ }
+}
- register<JvmTestSuite>("intTest") {
- val libs = versionCatalogs.named("libs")
- useJUnitJupiter(
- libs
- .findLibrary("junit-bom")
- .orElseThrow { GradleException("junit-bom not declared in
libs.versions.toml") }
- .map { it.version!! }
- )
-
- testType = TestSuiteType.INTEGRATION_TEST
-
- dependencies { implementation.add(project()) }
-
- val hasQuarkus = plugins.hasPlugin("io.quarkus")
-
- targets.all {
- testTask.configure {
- shouldRunAfter("test")
-
- // For Quarkus...
- //
- //
io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory(java.net.URL)
- // is not smart enough :(
- if (hasQuarkus) {
- systemProperty("build.output.directory",
layout.buildDirectory.asFile.get())
- dependsOn(tasks.named("quarkusBuild"))
- }
- }
-
- if (hasQuarkus) {
- tasks.named("compileIntTestJava").configure {
- dependsOn(tasks.named("compileQuarkusTestGeneratedSourcesJava"))
+// Special handling for test-suites with type `manual-test`, which are
intended to be run on demand
+// rather than implicitly via `check`.
+afterEvaluate {
+ testing {
+ suites {
+ withType<JvmTestSuite> {
+ // Need to do this check in an afterEvaluate, because the `withType`
above gets called
+ // before the configure() of a registered test suite runs.
+ if (testType.get() != "manual-test") {
+ targets.all {
+ if (testTask.name != "test") {
+ testTask.configure { shouldRunAfter("test") }
+ tasks.named("check").configure { dependsOn(testTask) }
+ }
}
}
-
- tasks.named("check").configure { dependsOn(testTask) }
- }
-
- if (hasQuarkus) {
- sources { java.srcDirs(tasks.named("quarkusGenerateCodeTests")) }
}
}
}
@@ -264,15 +236,3 @@ configurations.all {
}
}
}
-
-// Let the test's implementation config extend testImplementation, so it also
inherits the
-// project's "main" implementation dependencies (not just the "api"
configuration)
-configurations.named("intTestImplementation").configure {
- extendsFrom(configurations.getByName("testImplementation"))
-}
-
-dependencies { add("intTestImplementation",
java.sourceSets.getByName("test").output.dirs) }
-
-configurations.named("intTestRuntimeOnly").configure {
- extendsFrom(configurations.getByName("testRuntimeOnly"))
-}
diff --git a/build-logic/src/main/kotlin/polaris-quarkus.gradle.kts
b/build-logic/src/main/kotlin/polaris-quarkus.gradle.kts
new file mode 100644
index 00000000..bea3484b
--- /dev/null
+++ b/build-logic/src/main/kotlin/polaris-quarkus.gradle.kts
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import gradle.kotlin.dsl.accessors._fa00c0b20184971a79f32516372275b9.testing
+import org.gradle.api.attributes.TestSuiteType
+import org.gradle.api.plugins.jvm.JvmTestSuite
+import org.gradle.kotlin.dsl.register
+import org.gradle.kotlin.dsl.withType
+
+plugins { id("polaris-server") }
+
+testing {
+ suites {
+ withType<JvmTestSuite> {
+ targets.all {
+ if (testTask.name != "test") {
+ testTask.configure {
+ // For Quarkus...
+ //
+ //
io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory(java.net.URL)
+ // is not smart enough :(
+ systemProperty("build.output.directory",
layout.buildDirectory.asFile.get())
+ dependsOn(tasks.named("quarkusBuild"))
+ }
+ }
+ }
+ }
+ register<JvmTestSuite>("intTest") {
+ testType = TestSuiteType.INTEGRATION_TEST
+ targets.all {
+ tasks.named("compileIntTestJava").configure {
+ dependsOn(tasks.named("compileQuarkusTestGeneratedSourcesJava"))
+ }
+ }
+ sources { java.srcDirs(tasks.named("quarkusGenerateCodeTests")) }
+ }
+ }
+}
+
+// Let the test's implementation config extend testImplementation, so it also
inherits the
+// project's "main" implementation dependencies (not just the "api"
configuration)
+configurations.named("intTestImplementation").configure {
+ extendsFrom(configurations.getByName("testImplementation"))
+}
+
+dependencies { add("intTestImplementation",
java.sourceSets.getByName("test").output.dirs) }
+
+configurations.named("intTestRuntimeOnly").configure {
+ extendsFrom(configurations.getByName("testRuntimeOnly"))
+}
diff --git a/quarkus/admin/build.gradle.kts b/quarkus/admin/build.gradle.kts
index 145340c7..959fece4 100644
--- a/quarkus/admin/build.gradle.kts
+++ b/quarkus/admin/build.gradle.kts
@@ -23,7 +23,7 @@ plugins {
alias(libs.plugins.quarkus)
alias(libs.plugins.jandex)
alias(libs.plugins.openapi.generator)
- id("polaris-server")
+ id("polaris-quarkus")
id("polaris-license-report")
id("distribution")
}
diff --git a/quarkus/server/build.gradle.kts b/quarkus/server/build.gradle.kts
index f83bb131..48598518 100644
--- a/quarkus/server/build.gradle.kts
+++ b/quarkus/server/build.gradle.kts
@@ -20,7 +20,7 @@
plugins {
alias(libs.plugins.quarkus)
alias(libs.plugins.openapi.generator)
- id("polaris-server")
+ id("polaris-quarkus")
id("polaris-license-report")
id("distribution")
}
diff --git a/quarkus/service/build.gradle.kts b/quarkus/service/build.gradle.kts
index 4695a64a..7ff53779 100644
--- a/quarkus/service/build.gradle.kts
+++ b/quarkus/service/build.gradle.kts
@@ -20,7 +20,7 @@
plugins {
alias(libs.plugins.quarkus)
alias(libs.plugins.jandex)
- id("polaris-server")
+ id("polaris-quarkus")
}
dependencies {