Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,30 @@ task testJar(type: JavaExec) {
classpath = files(jar.archiveFile)
javaLauncher = javaToolchains.launcherFor(java.toolchain)

// Capture standard output
standardOutput = new ByteArrayOutputStream()

doFirst {
// println "Testing jar: ${jar.archiveFile.get().asFile.absolutePath}"
}

doLast {
// Get the version printed by the jar
def printedVersion = standardOutput.toString().trim()

// Get the expected version from git state
def expectedVersion = generateVersion()

// Compare versions
if (printedVersion != expectedVersion) {
throw new GradleException(
"Version mismatch! Jar printed version '${printedVersion}' " +
"but expected version from git state is '${expectedVersion}'"
)
}

logger.lifecycle("✓ Jar version validation passed: ${printedVersion}")
}
}

// Run validation before compilation
Expand Down