Skip to content

Commit c76c7aa

Browse files
committed
feat: add bigDataTestRun task for interactive troubleshooting mode
- Introduced `bigDataTestRun` Gradle task for starting containers and keeping them active until interrupted, enabling manual debugging workflows. - Updated Spring plugin README and user guide with usage instructions and examples. - Bumped `org.openprojectx.bigdata-test` version to `0.1.17-SNAPSHOT`.
1 parent 45cfdd4 commit c76c7aa

5 files changed

Lines changed: 48 additions & 6 deletions

File tree

doc/user-guide.adoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,11 +1544,19 @@ bigDataTest {
15441544

15451545
The plugin registers:
15461546

1547-
* `bigDataTestStart` - starts the configured kit in the Gradle daemon.
1548-
* `bigDataTestStop` - explicitly stops it.
1547+
* `bigDataTestStart` - starts the configured kit for the current Gradle build and then returns. This task is intended as a dependency of app/test tasks.
1548+
* `bigDataTestRun` - starts the configured kit and keeps the Gradle process running until interrupted. Use this for manual troubleshooting.
1549+
* `bigDataTestStop` - explicitly stops the kit in the current Gradle build.
15491550

15501551
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.
15511552

1553+
`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:
1554+
1555+
[source,bash]
1556+
----
1557+
GRADLE_USER_HOME=/data/.gradle ./gradlew bigDataTestRun
1558+
----
1559+
15521560
Disable automatic task wiring when you want explicit task dependencies:
15531561

15541562
[source,kotlin]

example/spring-gradle-plugin/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ cd example/spring-gradle-plugin
1616
GRADLE_USER_HOME=/data/.gradle ../../gradlew bootRunLocal
1717
```
1818

19+
For manual troubleshooting without starting the Spring app, keep the containers running with:
20+
21+
```bash
22+
GRADLE_USER_HOME=/data/.gradle ../../gradlew bigDataTestRun
23+
```
24+
1925
The Gradle plugin starts Kerberos, HDFS, and LocalStack S3 before `bootRunLocal` launches the
2026
Spring JVM, runs the TOML extensions, and injects endpoint/extension output as JVM system
2127
properties and environment variables. The application reads the JVM properties from

example/spring-gradle-plugin/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ plugins {
33
kotlin("plugin.spring") version "2.2.21"
44
id("org.springframework.boot") version "4.0.5"
55
id("io.spring.dependency-management") version "1.1.7"
6-
id("org.openprojectx.bigdata-test") version "0.1.12-SNAPSHOT"
6+
id("org.openprojectx.bigdata-test") version "0.1.17-SNAPSHOT"
77
}
88

99
group = "org.openprojectx.bigdata.test.example"
10-
version = "0.1.12-SNAPSHOT"
10+
version = "0.1.17-SNAPSHOT"
1111

1212
kotlin {
1313
jvmToolchain(17)

gradle-plugin/src/main/kotlin/org/openprojectx/bigdata/test/gradle/BigDataTestGradlePlugin.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ class BigDataTestGradlePlugin : Plugin<Project> {
115115

116116
val startTask = project.tasks.register("bigDataTestStart", BigDataTestStartTask::class.java) { task ->
117117
task.group = "bigdata-test"
118-
task.description = "Start configured bigdata-test containers in the Gradle daemon."
118+
task.description = "Start configured bigdata-test containers for this Gradle build."
119+
task.kitService.set(service)
120+
task.usesService(service)
121+
}
122+
project.tasks.register("bigDataTestRun", BigDataTestRunTask::class.java) { task ->
123+
task.group = "bigdata-test"
124+
task.description = "Start configured bigdata-test containers and keep them running until the Gradle process is interrupted."
119125
task.kitService.set(service)
120126
task.usesService(service)
121127
}
@@ -132,7 +138,9 @@ class BigDataTestGradlePlugin : Plugin<Project> {
132138

133139
if (extension.enabled.get() && extension.autoConfigureJavaExecTasks.get()) {
134140
project.tasks.withType(JavaExec::class.java).configureEach { task ->
135-
if (task.name == "bigDataTestStart" || task.name == "bigDataTestStop") return@configureEach
141+
if (task.name == "bigDataTestStart" || task.name == "bigDataTestRun" || task.name == "bigDataTestStop") {
142+
return@configureEach
143+
}
136144
task.dependsOn(startTask)
137145
task.usesService(service)
138146
task.doFirst {

gradle-plugin/src/main/kotlin/org/openprojectx/bigdata/test/gradle/BigDataTestTasks.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ abstract class BigDataTestStartTask : DefaultTask() {
1818
}
1919
}
2020

21+
@DisableCachingByDefault(because = "Starts external Docker containers and waits for user interruption.")
22+
abstract class BigDataTestRunTask : DefaultTask() {
23+
@get:Internal
24+
abstract val kitService: Property<BigDataTestGradleService>
25+
26+
@TaskAction
27+
fun run() {
28+
val properties = kitService.get().startIfNeeded()
29+
logger.lifecycle("bigdata-test started; injected ${properties.size} properties")
30+
logger.lifecycle("bigdata-test is running. Press Ctrl+C to stop the Gradle process and close containers.")
31+
try {
32+
while (!Thread.currentThread().isInterrupted) {
33+
Thread.sleep(1_000)
34+
}
35+
} catch (_: InterruptedException) {
36+
Thread.currentThread().interrupt()
37+
}
38+
}
39+
}
40+
2141
@DisableCachingByDefault(because = "Stops external Docker containers and has no cacheable outputs.")
2242
abstract class BigDataTestStopTask : DefaultTask() {
2343
@get:Internal

0 commit comments

Comments
 (0)