You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gradle-plugin): enhance Spark SQL prep and extension runtime management
- Updated Gradle plugin to support Spark SQL preparation inside Gradle JVM with enhanced logging and module access configuration.
- Added support for Iceberg Spark extensions and shaded runtime artifacts for improved dependency isolation.
- Introduced extension resource directories for better resource management.
- Enhanced extension runtime classpath configuration with added dependencies for AWS SDK, Iceberg AWS bundle, and servlet API.
- Updated documentation to reflect new plugin configurations, logging options, and resource handling.
Copy file name to clipboardExpand all lines: doc/user-guide.adoc
+134-7Lines changed: 134 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1622,7 +1622,7 @@ If `hiveMetastore = true` fails for HMS-backed object-store tables, see link:hiv
1622
1622
1623
1623
== Gradle Plugin
1624
1624
1625
-
Use the Gradle plugin when the test kit should be managed by Gradle instead of the application or test framework. This keeps container startup out of the Spring application context and out of JUnit annotations, while still starting the services before `bootRun`, `run`, `JavaExec`, or `Test` tasks launch their JVMs.
1625
+
Use the Gradle plugin when the test kit should be managed by Gradle instead of the application or test framework. This keeps container startup out of the Spring application context and out of JUnit annotations, while still starting the services before `bootRun`, `run`, or other `JavaExec` tasks launch their JVMs. `Test` task wiring is opt-in.
1626
1626
1627
1627
[source,kotlin]
1628
1628
----
@@ -1689,7 +1689,11 @@ bigDataTest {
1689
1689
1690
1690
Extension provisioning dependencies are resolved into the plugin-owned `bigDataTestExtensionRuntime` configuration. They are not added to the application `implementation`, `runtimeClasspath`, `testImplementation`, or `testRuntimeClasspath` configurations.
1691
1691
1692
-
By default the plugin adds the lightweight `extensions` artifact and then adds runtime libraries based on the configured extension TOML:
1692
+
By default the plugin uses the shaded `extensions:<version>:runtime` artifact. This keeps Spark, Hadoop, Kafka, Avro, thin Iceberg Spark modules, and their transitive runtime dependencies managed by bigdata-test instead of letting the application dependency graph choose those versions. The extension runtime classloader prefers its own jars and delegates shared bigdata-test core types to the Gradle plugin parent classloader.
1693
+
1694
+
Application dependencies such as `implementation`, `runtimeOnly`, `testImplementation`, and `testRuntimeOnly` are not added to the bigdata-test extension runtime. Dependencies explicitly added to `bigDataTestExtensionRuntime` are different: they are intentionally part of the extension runtime and can affect extension execution. Use that configuration only for optional extension-only libraries that bigdata-test does not already provide.
1695
+
1696
+
If you need to debug or override individual runtime dependencies, disable the shaded artifact. In that mode, the plugin adds the lightweight `extensions` artifact and then adds runtime libraries based on the configured extension TOML:
@@ -1701,6 +1705,7 @@ Override dependency versions with the DSL:
1701
1705
----
1702
1706
bigDataTest {
1703
1707
extensionRuntime {
1708
+
useShadedArtifact.set(false)
1704
1709
hadoopVersion.set("3.4.2")
1705
1710
sparkVersion.set("3.5.7")
1706
1711
confluentVersion.set("8.2.1")
@@ -1713,7 +1718,16 @@ bigDataTest {
1713
1718
1714
1719
When Spark and Confluent Kafka dependencies are both present, the plugin selects `at.yawk.lz4:lz4-java` for Gradle's shared `org.lz4:lz4-java` capability. Override `lz4Version` if the selected Confluent line uses a different compatible lz4 artifact.
1715
1720
1716
-
For Hadoop S3A, the plugin excludes `software.amazon.awssdk:bundle` from `hadoop-aws` and adds the modular `software.amazon.awssdk:s3` dependency instead. This keeps the extension runtime focused on S3 support instead of shading every AWS service client.
1721
+
For Hadoop S3A, the plugin excludes `software.amazon.awssdk:bundle` from `hadoop-aws` and adds the modular `software.amazon.awssdk:s3` and `software.amazon.awssdk:s3-transfer-manager` dependencies instead. S3A loads transfer-manager classes at runtime, so both modules are required while still avoiding the full AWS SDK bundle.
1722
+
1723
+
When `spark-sql-prep` is used by `bigDataTestStart` or `bigDataTestRun`, Spark starts inside the Gradle JVM. On Java 17, add Spark's required module access to the Gradle daemon JVM, for example in `gradle.properties`:
These flags cannot be applied after the Gradle daemon has already started. If a daemon was already running without them, stop it with `./gradlew --stop` or run the next command with `--no-daemon`.
1717
1731
1718
1732
When auto-detection is not enough, force dependency groups explicitly:
1719
1733
@@ -1729,7 +1743,7 @@ bigDataTest {
1729
1743
}
1730
1744
----
1731
1745
1732
-
The `extensions` module also publishes a shaded runtime artifact with classifier `runtime`. It bundles the extension runtime dependencies for users who prefer one plugin runtime artifact instead of dynamic dependency sets:
1746
+
The `extensions` module publishes the shaded runtime artifact with classifier `runtime`. This is the default plugin mode:
1733
1747
1734
1748
[source,kotlin]
1735
1749
----
@@ -1741,7 +1755,75 @@ bigDataTest {
1741
1755
}
1742
1756
----
1743
1757
1744
-
With `useShadedArtifact = true`, the plugin resolves `org.openprojectx.bigdata.test.core:extensions:<version>:runtime@jar` into `bigDataTestExtensionRuntime` and skips adding separate Hadoop, Spark, Kafka, and Avro extension runtime dependencies.
1758
+
With `useShadedArtifact = true`, the plugin resolves `org.openprojectx.bigdata.test.core:extensions:<version>:runtime@jar` into `bigDataTestExtensionRuntime` and skips adding separate Hadoop, Spark, Iceberg, Kafka, and Avro extension runtime dependencies.
1759
+
1760
+
The normal `extensions` artifact does not package Spark, Hadoop, Kafka, Log4j, or SLF4J implementations; those dependencies are supplied by the plugin-owned runtime configuration when needed. The shaded `extensions:<version>:runtime` artifact does package extension runtime dependencies, including logging libraries pulled in transitively by Spark such as `slf4j-api`, `log4j-api`, `log4j-core`, and `log4j-slf4j2-impl`. Jackson is relocated inside this shaded artifact to avoid collisions with Jackson versions used by the application or Gradle build logic.
1761
+
1762
+
=== Gradle Plugin Customization Surface
1763
+
1764
+
The Gradle plugin has three separate classpath/resource concepts:
1765
+
1766
+
[cols="1,2,2",options="header"]
1767
+
|===
1768
+
|Area |How to customize |Notes
1769
+
1770
+
|Application classpath
1771
+
|Use normal Gradle configurations such as `implementation`, `runtimeOnly`, `testImplementation`, and `testRuntimeOnly`.
1772
+
|These dependencies are used by the app and tests. They are not added to `bigDataTestRun` or extension provisioning.
1773
+
1774
+
|Extension runtime classpath
1775
+
|Use the `bigDataTestExtensionRuntime` configuration, or set `extensionRuntime.useShadedArtifact.set(false)` and configure `hadoopVersion`, `sparkVersion`, `icebergVersion`, `confluentVersion`, `avroVersion`, `awsSdkVersion`, and `lz4Version`.
1776
+
|This classpath is used only by bigdata-test extension execution. Dependencies added here can affect `spark-sql-prep`, JCEKS generation, Kafka Avro seeding, and other extensions.
1777
+
1778
+
|Extension config and SQL/resource lookup
1779
+
|Use `extensionConfig.add(...)`. `classpath:` resources are searched from the extension runtime first and then from the project's main resource directories, including `src/main/resources` and compiled main resources.
1780
+
|There is no dedicated DSL property for extra arbitrary resource directories today. Put files under main resources, reference an absolute or relative `file:` path, or add a small resource jar to `bigDataTestExtensionRuntime`.
1781
+
1782
+
|Gradle task JVM
1783
+
|Configure Gradle itself with `org.gradle.jvmargs`, `GRADLE_OPTS`, or `JAVA_TOOL_OPTIONS`.
1784
+
|`bigDataTestStart` and `bigDataTestRun` execute inside the Gradle JVM. Spark module-open flags and logging configuration for Spark SQL preparation must be visible when the Gradle daemon starts.
1785
+
1786
+
|Gradle task environment
1787
+
|Set environment variables on the Gradle command, for example `TESTCONTAINERS_RYUK_DISABLED=true ./gradlew bigDataTestRun`.
1788
+
|`bigDataTestRun` is not a `JavaExec` task, so it does not have a task-local `environment {}` API. It sees the Gradle process environment.
1789
+
1790
+
|Application task injected properties
1791
+
|Set `injectRawEndpointProperties`, `injectNamespacedEndpointProperties`, and `injectEnvironmentVariables`.
1792
+
|For auto-wired `JavaExec` and opt-in `Test` tasks, endpoint and extension output values are injected as JVM system properties and, when enabled, environment variables.
Place the script at `src/main/resources/sql/create_tables.sql`, or use a `file:` URL when the SQL lives outside the project resources.
1825
+
1826
+
The shaded runtime jar intentionally favors isolation over small size. It uses the thin Iceberg Spark modules instead of the fat `iceberg-spark-runtime` jar, but still includes enough Hadoop, Spark, Iceberg, Kafka Avro, and AWS runtime code for config-driven provisioning without borrowing the user application's dependency graph. The largest remaining optional payload is `iceberg-aws-bundle`, which is kept for Iceberg S3 FileIO and AWS catalog support. If size or dependency inspection matters more than isolation, set `useShadedArtifact = false` and let the plugin resolve only the runtime families detected from `extensionConfig`, or add the exact artifacts you want to `bigDataTestExtensionRuntime`.
1745
1827
1746
1828
Gradle configuration is Gradle-native; the plugin does not read a Maven POM. When values should come from `gradle.properties` or `-P`, wire them through Gradle providers:
1747
1829
@@ -1763,11 +1845,11 @@ bigDataTest {
1763
1845
1764
1846
The plugin registers:
1765
1847
1766
-
* `bigDataTestStart` - starts the configured kit for the current Gradle build and then returns. This task is intended as a dependency of app/test tasks.
1848
+
* `bigDataTestStart` - starts the configured kit for the current Gradle build and then returns. This task is intended as a dependency of app tasks, or test tasks when explicitly opted in.
1767
1849
* `bigDataTestRun` - starts the configured kit and keeps the Gradle process running until interrupted. Use this for manual troubleshooting.
1768
1850
* `bigDataTestStop` - explicitly stops the kit in the current Gradle build.
1769
1851
1770
-
By default, the plugin wires `bigDataTestStart` before `JavaExec` and `Test` tasks and injects endpoint and extension output properties as JVM system properties immediately before the task launches. It also injects environment variables derived from the same property map. The kit is closed automatically when the Gradle build service closes at the end of the build.
1852
+
By default, the plugin wires `bigDataTestStart` before `JavaExec` tasks and injects endpoint and extension output properties as JVM system properties immediately before the task launches. It also injects environment variables derived from the same property map. `Test` tasks are not auto-wired by default; set `autoConfigureTestTasks.set(true)` when tests should start and receive the kit automatically. The kit is closed automatically when the Gradle build service closes at the end of the build.
1771
1853
1772
1854
`bigDataTestStart` is not an interactive keep-alive command. If you run it directly, it starts the kit, prints the injected property count, and exits when the build finishes. For a long-running local environment, run:
1773
1855
@@ -1783,6 +1865,51 @@ Testcontainers runtime environment variables, such as `TESTCONTAINERS_RYUK_DISAB
`bigDataTestRun` starts the kit and extension provisioning inside the Gradle JVM. Configure JVM logging through Gradle daemon JVM properties, not through the application `bootRun` or `test` task.
1871
+
1872
+
For the default plugin logging backend, use SLF4J Simple properties in `gradle.properties`:
Spark SQL preparation is different when it runs through the Gradle plugin: Spark starts in-process inside the Gradle daemon, and Spark logs are routed through Gradle's logging bridge. Gradle controls the console rendering, so Log4j2 console pattern and ANSI color settings are not honored for those Spark extension logs. Use Gradle flags such as `--info` and extension/Spark log-level settings for verbosity. Full Log4j2 pattern/color control would require a separate Spark preparation JVM instead of the current in-process plugin execution model.
1886
+
1887
+
If a Gradle daemon is already running, restart it before expecting new `org.gradle.jvmargs` values to apply:
Copy file name to clipboardExpand all lines: extensions/src/main/kotlin/org/openprojectx/bigdata/test/extensions/core/BigDataExtensionResourceLoader.kt
0 commit comments