You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by sn...@apache.org on 2026/06/11 05:37:10 UTC
(polaris) branch main updated: Build: use typed providers (#4688)
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 cbcbcd2ed8 Build: use typed providers (#4688)
cbcbcd2ed8 is described below
commit cbcbcd2ed8a09f12bc372cb0d7b2e26300604032
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Thu Jun 11 07:37:05 2026 +0200
Build: use typed providers (#4688)
This change removes some build-script lambdas that capture Gradle script state.
It declares the Mockito agent as a proper `@Classpath` input to Test.
More things:
* makes task inputs more explicit and inspectable.
* reduces accidental coupling between task execution and configuration-time objects.
* aligns with Gradle’s lazy/configuration-safe task modeling.
---
build-logic/src/main/kotlin/polaris-java.gradle.kts | 12 +++++++++---
build-logic/src/main/kotlin/polaris-runtime.gradle.kts | 12 +++++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts b/build-logic/src/main/kotlin/polaris-java.gradle.kts
index 1f77f272d7..aecc746548 100644
--- a/build-logic/src/main/kotlin/polaris-java.gradle.kts
+++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts
@@ -22,9 +22,12 @@ import java.util.Properties
import kotlin.jvm.java
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
+import org.gradle.api.file.FileCollection
+import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.named
+import org.gradle.process.CommandLineArgumentProvider
import org.kordamp.gradle.plugin.jandex.JandexExtension
import org.kordamp.gradle.plugin.jandex.JandexPlugin
import publishing.PublishingHelperPlugin
@@ -188,14 +191,17 @@ dependencies {
mockitoAgent(mockitoCoreLib) { isTransitive = false }
}
+private class MockitoJavaAgentArgumentProvider(@get:Classpath val mockitoAgent: FileCollection) :
+ CommandLineArgumentProvider {
+ override fun asArguments(): Iterable<String> = listOf("-javaagent:${mockitoAgent.asPath}")
+}
+
tasks.withType<Test>().configureEach {
systemProperty("file.encoding", "UTF-8")
systemProperty("user.language", "en")
systemProperty("user.country", "US")
systemProperty("user.variant", "")
- jvmArgumentProviders.add(
- CommandLineArgumentProvider { listOf("-javaagent:${mockitoAgent.asPath}") }
- )
+ jvmArgumentProviders.add(MockitoJavaAgentArgumentProvider(mockitoAgent))
}
tasks.withType<Jar>().configureEach {
diff --git a/build-logic/src/main/kotlin/polaris-runtime.gradle.kts b/build-logic/src/main/kotlin/polaris-runtime.gradle.kts
index 741c4ebfa9..0d320926ea 100644
--- a/build-logic/src/main/kotlin/polaris-runtime.gradle.kts
+++ b/build-logic/src/main/kotlin/polaris-runtime.gradle.kts
@@ -15,8 +15,18 @@
*/
import org.gradle.api.plugins.jvm.JvmTestSuite
+import org.gradle.api.tasks.Input
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
+import org.gradle.process.CommandLineArgumentProvider
+
+class QuarkusProfileArgumentProvider(private val profile: String) : CommandLineArgumentProvider {
+ @get:Input
+ val inputProfile: String
+ get() = profile
+
+ override fun asArguments(): Iterable<String> = listOf("-Dquarkus.profile=$profile")
+}
plugins { id("polaris-server") }
@@ -44,7 +54,7 @@ testing {
systemProperty("build.output.directory", layout.buildDirectory.asFile.get())
dependsOn(tasks.named("quarkusBuild"))
// Set the 'it' profile explicitly
- jvmArgumentProviders.add(CommandLineArgumentProvider { listOf("-Dquarkus.profile=it") })
+ jvmArgumentProviders.add(QuarkusProfileArgumentProvider("it"))
}
}
tasks.named(sources.compileJavaTaskName).configure {