Skip to content

Commit

Permalink
Update 'module.properties' / remove "duplicates" (only keep latest)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Mar 24, 2024
1 parent 869b584 commit 37fb7fb
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.util.internal.VersionNumber
import java.util.Properties
import javax.inject.Inject

Expand All @@ -34,12 +35,19 @@ abstract class UniqueModulesPropertiesUpdate : DefaultTask() {

val modulesToRepoLocation = Properties()
modulesToRepoLocation.load(modulesProperties.singleFile.inputStream())
val modulesToCoordinates = modulesToRepoLocation.toSortedMap { e1, e2 -> e1.toString().compareTo(e2.toString()) }.map { entry ->
val modules = modulesToRepoLocation.toSortedMap { e1, e2 -> e1.toString().compareTo(e2.toString()) }.map { entry ->
val split = entry.value.toString().split("/")
val group = split.subList(4, split.size - 3).joinToString(".")
val name = split[split.size - 3]
"${entry.key}=$group:$name\n"
}.joinToString("")
uniqueModulesProperties.get().asFile.writeText(modulesToCoordinates.trim())
val version = split[split.size - 2]
Module(entry.key.toString(), "$group:$name", version)
}.groupBy { it.ga }.values.map { moduleList ->
moduleList.maxBy { VersionNumber.parse(it.version) }
}.sortedBy { it.name }

val modulesToCoordinates = modules.map { "${it.name}=${it.ga}\n" }
uniqueModulesProperties.get().asFile.writeText(modulesToCoordinates.joinToString("").trim())
}

data class Module(val name: String, val ga: String, val version: String)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
com.amihaiemil.eoyaml=com.amihaiemil.web:eo-yaml
com.github.spotbugs.annotations=com.github.spotbugs:spotbugs-annotations
com.github.virtuald.curvesapi=com.github.virtuald:curvesapi
com.google.common.util.concurrent.internal=com.google.guava:failureaccess
com.google.common=com.google.guava:guava
com.google.errorprone.annotations=com.google.errorprone:error_prone_annotations
com.google.gson=com.google.code.gson:gson
com.google.guice.extensions.servlet=com.google.inject.extensions:guice-servlet
com.google.guice=com.google.inject:guice
Expand Down Expand Up @@ -45,7 +45,6 @@ liquibase.core=org.liquibase:liquibase-core
org.antlr.antlr4.runtime=org.antlr:antlr4-runtime
org.apache.commons.codec=commons-codec:commons-codec
org.apache.commons.collections4=org.apache.commons:commons-collections4
org.apache.commons.configuration2=org.apache.commons:commons-configuration2
org.apache.commons.io=commons-io:commons-io
org.apache.commons.logging=org.slf4j:jcl-over-slf4j
org.apache.httpcomponents.httpclient.fluent=org.apache.httpcomponents:fluent-hc
Expand Down
Loading

0 comments on commit 37fb7fb

Please sign in to comment.