Skip to content

Extend Gradle integration test to check checksums and metadata marker #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ val modulesWithoutGradleMetadata = listOf(
)

dependencies {
implementation(platform("com.fasterxml.jackson:jackson-bom:+"))
// implementation(platform("com.fasterxml.jackson:jackson-bom:+"))

// 28-Apr-2023, tatu: Uncomment following (and comment ^^^) to test SNAPSHOT versions
// implementation(platform("com.fasterxml.jackson:jackson-bom:2.15.1-SNAPSHOT"))
// repositories.maven("https://oss.sonatype.org/content/repositories/snapshots")
// repositories.mavenCentral()
implementation(platform("com.fasterxml.jackson:jackson-bom:2.19.0-SNAPSHOT"))
repositories.maven("https://oss.sonatype.org/content/repositories/snapshots")
}

repositories.mavenCentral()
Expand All @@ -41,6 +40,8 @@ tasks.register("checkMetadata") {

// Create dependencies to all Modules references in the BOM
val allModules = configurations.detachedConfiguration(*allJacksonModule.map { dependencies.create(it) }.toTypedArray())
val modulesWithGradleMetadata = allJacksonModule.filter { m -> modulesWithoutGradleMetadata.none { m.startsWith(it) } }

// Tell Gradle to do the dependency resolution and return the result with dependency information
val allModulesResolved = resolveJacksonModules(allModules)

Expand Down Expand Up @@ -72,9 +73,29 @@ tasks.register("checkMetadata") {
message += "Dependencies of ${pomModule.id} are wrong in Gradle Metadata:" +
"\n POM: ${pomDependencies.joinToString()}" +
"\n Gradle: ${gmmDependencies.joinToString()}" +
"\n"
"\n\n"
}
}

val pomMetadataFiles = configurations.detachedConfiguration(*modulesWithGradleMetadata.map { dependencies.create("$it@pom") }.toTypedArray())
val gradleMetadataFiles = configurations.detachedConfiguration(*modulesWithGradleMetadata.map { dependencies.create("$it@module") }.toTypedArray())
val checksumFiles = configurations.detachedConfiguration(*modulesWithGradleMetadata.map { dependencies.create("$it@jar.md5") }.toTypedArray())

val pomsWithoutMarker = pomMetadataFiles.files.filter { !it.readText().contains("<!-- do_not_remove: published-with-gradle-metadata -->") }.map { it.name }
if (pomsWithoutMarker.isNotEmpty()) {
message += "POMs without Gradle Metadata marker:\n - ${pomsWithoutMarker.joinToString("\n - ")}\n\n"
}

val checksumsFromFile = checksumFiles.associate { it.name.substringBeforeLast("-") to it.readText() }
val checksumsFromMetadata = gradleMetadataFiles.associate { it.name.substringBeforeLast("-") to it.readText().lines().first {
it.contains("\"md5\"") }.substringAfterLast(": \"").replace("\"", "").padStart(32, '0')
}
val checksumsDiff = checksumsFromFile.filter { (k,v) -> checksumsFromMetadata[k] != v }
if (checksumsDiff.isNotEmpty()) {
message += "Checksums in Gradle Metadata are wrong:\n - ${checksumsDiff.keys.joinToString("\n - ")}\n\n"
throw RuntimeException(message)
}

if (message.isNotEmpty()) {
throw RuntimeException(message)
}
Expand Down