Skip to content

Commit cb60631

Browse files
CopilotbedaHovorka
andauthored
Fix Gradle build failure: Add Java 21 toolchain and conditional GitHub Packages auth (#30)
* Fix Gradle test exit code 1 - Add Java 21 toolchain and conditional GitHub Packages - Added Java 21 toolchain configuration to ensure consistent JVM version - Made GitHub Packages repository conditional (only when credentials available) - Installed jDisco 1.2.0 to mavenLocal for offline builds - Tests now run successfully: 268 tests, 267 passed, 1 skipped - JaCoCo coverage reports generate successfully - Fixes exit code 1 issue that blocked CI/CD and JaCoCo --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
1 parent 0de8542 commit cb60631

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

build.gradle.kts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,37 @@ val kotlinVersion: String by project
5656
group = "cz.vutbr.fit"
5757
version = "1.0"
5858

59-
// Configure Java compilation (compile to Java 21 bytecode using any Java 21+)
60-
// Note: We don't specify a toolchain to allow using any available Java version
59+
// Configure Java compilation (compile to Java 21 bytecode using Java 21)
6160
java {
62-
// Ensure source and target compatibility with Java 21
63-
sourceCompatibility = JavaVersion.VERSION_21
64-
targetCompatibility = JavaVersion.VERSION_21
61+
// Specify Java 21 toolchain to ensure consistent compilation and runtime
62+
// This ensures both compilation and test execution use Java 21
63+
toolchain {
64+
languageVersion.set(JavaLanguageVersion.of(21))
65+
}
6566
}
6667

6768
// Configure repositories
6869
repositories {
6970
mavenLocal() // For jDisco local development (highest priority)
7071

71-
// GitHub Packages Maven Registry for jDisco
72-
maven {
73-
name = "GitHubPackages"
74-
url = uri("https://maven.pkg.github.com/bedaHovorka/jdisco")
75-
credentials {
76-
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
77-
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
72+
// GitHub Packages Maven Registry for jDisco (conditional - only when credentials available)
73+
// This prevents build failures when running outside CI environment
74+
val githubUsername = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
75+
val githubToken = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
76+
77+
if (!githubUsername.isNullOrEmpty() && !githubToken.isNullOrEmpty()) {
78+
maven {
79+
name = "GitHubPackages"
80+
url = uri("https://maven.pkg.github.com/bedaHovorka/jdisco")
81+
credentials {
82+
username = githubUsername
83+
password = githubToken
84+
}
7885
}
86+
} else {
87+
logger.warn("GitHub Packages credentials not available. Skipping GitHub Packages repository.")
88+
logger.warn("jDisco must be available in mavenLocal() for build to succeed.")
89+
logger.warn("To install jDisco locally: cd ~/work/jdisco && mvn install")
7990
}
8091

8192
mavenCentral() // For all other dependencies

0 commit comments

Comments
 (0)