Skip to content

Commit dc963d5

Browse files
committed
Update command timeout configuration and enhance Gradle wrapper for Java 17 compatibility: increase default command timeout, implement dynamic timeout retrieval, and ensure Gradle wrapper is updated for Java 17 in preparation tasks.
1 parent c1b6823 commit dc963d5

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
url = https://github.com/vypdev/stringcare-android-c.git
66
[submodule "example"]
77
path = example
8-
url = https://github.com/vypdev/stringcare-android-sample
8+
url = https://github.com/vypdev/stringcare-android-sample.git

plugin/src/main/kotlin/dev/vyp/stringcare/plugin/internal/Execution.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import dev.vyp.stringcare.plugin.domain.models.ExecutionResult
44
import java.io.IOException
55
import java.util.concurrent.TimeUnit
66

7-
private const val COMMAND_TIMEOUT_SECONDS = 60L
7+
private const val DEFAULT_COMMAND_TIMEOUT_SECONDS = 300L
8+
private const val COMMAND_TIMEOUT_PROPERTY = "stringcare.command.timeout.seconds"
9+
10+
private fun commandTimeoutSeconds(): Long =
11+
System
12+
.getProperty(COMMAND_TIMEOUT_PROPERTY)
13+
?.toLongOrNull()
14+
?.takeIf { it > 0 }
15+
?: DEFAULT_COMMAND_TIMEOUT_SECONDS
816

917
fun execute(command: String): Result<ExecutionResult> = executeShell(shellCommand(command), command)
1018

@@ -29,7 +37,7 @@ private fun executeShell(
2937
process.inputStream.bufferedReader().use { reader ->
3038
reader.readText()
3139
}.replace("\r", "")
32-
val completed = process.waitFor(COMMAND_TIMEOUT_SECONDS, TimeUnit.SECONDS)
40+
val completed = process.waitFor(commandTimeoutSeconds(), TimeUnit.SECONDS)
3341
if (!completed) {
3442
process.destroyForcibly()
3543
return Result.success(

plugin/src/main/kotlin/dev/vyp/stringcare/plugin/internal/Tasks.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ internal fun prepareTask(directory: String): String =
4343
"""
4444
cd $directory &&
4545
git clone https://github.com/StringCare/$testProjectName.git &&
46-
cd $testProjectName
46+
cd $testProjectName &&
47+
${updateWrapperForJava17()}
4748
""".trimIndent()
4849

50+
/**
51+
* Integration fixtures may carry an old wrapper distribution that cannot evaluate scripts
52+
* referencing Java 17 bytecode. Pin to a modern Gradle distribution before executing tasks.
53+
*/
54+
private fun updateWrapperForJava17(): String =
55+
when (getOs()) {
56+
Os.WINDOWS -> "echo Wrapper update skipped on Windows"
57+
Os.OSX, Os.LINUX ->
58+
"sed -i.bak 's#distributionUrl=.*#distributionUrl=https\\\\://services.gradle.org/distributions/gradle-8.11.1-bin.zip#' " +
59+
"gradle/wrapper/gradle-wrapper.properties && rm -f gradle/wrapper/gradle-wrapper.properties.bak"
60+
}
61+
4962
internal fun buildTask(directory: String): String =
5063
"""
5164
cd $directory &&

0 commit comments

Comments
 (0)