Skip to content

Commit

Permalink
chore: re-enable deps validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeqo committed Mar 15, 2024
1 parent c848484 commit a2e5832
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 38 deletions.
38 changes: 0 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -251,41 +251,3 @@ tasks.distTar {
compression = Compression.GZIP
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}

tasks.register('validateDependencies') {
doLast {
def dependencyVersions = [:]
def conflictsFound = false

subprojects { subproject ->
println "Module: ${subproject.name}"
def runtimeClasspath = subproject.sourceSets.main.runtimeClasspath
runtimeClasspath.each { file ->

def fileName = file.name
def matcher = fileName =~ /(.+)-(\d+\.\d+\.\d+(-.+)?)(\..+)/

if (matcher) {
def artifactId = matcher[0][1]
def version = matcher[0][2]

if (dependencyVersions.containsKey(artifactId)) {
if (dependencyVersions[artifactId] != version) {
println "Conflict found for $artifactId: ${dependencyVersions[artifactId]} vs $version"
conflictsFound = true
}
} else {
dependencyVersions[artifactId] = version
}
}
}
}

assert !conflictsFound : "Dependency conflicts found!"
}
}

// TODO fix GCP dependency issues
//tasks.named("check") {
// dependsOn(tasks.named("validateDependencies"))
//}
51 changes: 51 additions & 0 deletions storage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,54 @@
* limitations under the License.
*/

subprojects { subproject ->
tasks.register("validateDeps") {
doLast {
// Storage module deps versions
def depVersions = [:]
def runtimeClasspath = subproject.sourceSets.main.runtimeClasspath

runtimeClasspath.each { file ->
def fileName = file.name
def matcher = fileName =~ /(.+)-(\d+\.\d+\.\d+(-.+)?)(\..+)/

if (matcher) {
def artifactId = matcher[0][1]
def version = matcher[0][2]
depVersions[artifactId] = version
}
}

// Validate transient dependencies between storage modules and core deps
def coreDeps = [project(":core"), project(":commons")]
def conflictsFound = false

coreDeps.forEach { dep ->
runtimeClasspath = dep.sourceSets.main.runtimeClasspath
runtimeClasspath.each { file ->
def matcher = file.name =~ /(.+)-(\d+\.\d+\.\d+(-.+)?)(\..+)/

if (matcher) {
def artifactId = matcher[0][1]
def version = matcher[0][2]

if (depVersions.containsKey(artifactId)) {
if (depVersions[artifactId] != version) {
println "Conflict found for $artifactId: ${depVersions[artifactId]} vs $version"
conflictsFound = true
}
} else {
depVersions[artifactId] = version
}
}
}
}

assert !conflictsFound: "Dependency conflicts found!"
}
}

tasks.named("check") {
dependsOn(tasks.named("validateDeps"))
}
}

0 comments on commit a2e5832

Please sign in to comment.