diff --git a/examples/gradm-getting-started/gradm/gradm3.yml b/examples/gradm-getting-started/gradm/gradm3.yml index 922ac662..295227a5 100644 --- a/examples/gradm-getting-started/gradm/gradm3.yml +++ b/examples/gradm-getting-started/gradm/gradm3.yml @@ -26,11 +26,11 @@ versions: spotless: "6.18.0" repositories: + mavenLocal: google: mavenCentral: jetbrainsCompose: url: "https://maven.pkg.jetbrains.space/public/p/compose/dev" - mavenLocal: sonatypeSnapshots: url: "https://s01.oss.sonatype.org/content/repositories/snapshots" gradlePluginPortal: diff --git a/examples/gradm-with-composite-build/build-logic/gradm/gradm.yml b/examples/gradm-with-composite-build/build-logic/gradm/gradm.yml index 922ac662..295227a5 100644 --- a/examples/gradm-with-composite-build/build-logic/gradm/gradm.yml +++ b/examples/gradm-with-composite-build/build-logic/gradm/gradm.yml @@ -26,11 +26,11 @@ versions: spotless: "6.18.0" repositories: + mavenLocal: google: mavenCentral: jetbrainsCompose: url: "https://maven.pkg.jetbrains.space/public/p/compose/dev" - mavenLocal: sonatypeSnapshots: url: "https://s01.oss.sonatype.org/content/repositories/snapshots" gradlePluginPortal: diff --git a/examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml b/examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml index 922ac662..295227a5 100644 --- a/examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml +++ b/examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml @@ -26,11 +26,11 @@ versions: spotless: "6.18.0" repositories: + mavenLocal: google: mavenCentral: jetbrainsCompose: url: "https://maven.pkg.jetbrains.space/public/p/compose/dev" - mavenLocal: sonatypeSnapshots: url: "https://s01.oss.sonatype.org/content/repositories/snapshots" gradlePluginPortal: diff --git a/examples/template/gradm.yml b/examples/template/gradm.yml index 922ac662..295227a5 100644 --- a/examples/template/gradm.yml +++ b/examples/template/gradm.yml @@ -26,11 +26,11 @@ versions: spotless: "6.18.0" repositories: + mavenLocal: google: mavenCentral: jetbrainsCompose: url: "https://maven.pkg.jetbrains.space/public/p/compose/dev" - mavenLocal: sonatypeSnapshots: url: "https://s01.oss.sonatype.org/content/repositories/snapshots" gradlePluginPortal: diff --git a/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Formatter.kt b/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Formatter.kt index dadc558e..d5574e62 100644 --- a/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Formatter.kt +++ b/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Formatter.kt @@ -19,6 +19,7 @@ import me.omico.gradm.GradmFormatConfiguration import me.omico.gradm.internal.YamlDocument import me.omico.gradm.internal.YamlObject import me.omico.gradm.internal.asYamlDocument +import me.omico.gradm.internal.config.Repository import me.omico.gradm.internal.config.buildInRepositories import me.omico.gradm.internal.config.format.node.MappingNodeScope import me.omico.gradm.internal.config.format.node.mapping @@ -65,19 +66,27 @@ fun YamlScope.repositoriesSequence(document: YamlDocument) { if (repositories.isEmpty()) return newlineIfNeeded() mapping("repositories") { + // Always place mavenLocal at the top + if (repositories.any { it.id == "mavenLocal" }) { + mapping("mavenLocal") + } + // Place build-in repositories repositories - .filter { !it.noUpdates || it.id == "mavenLocal" } + .filterNot(Repository::noUpdates) .forEach { repository -> mapping(repository.id) repository@{ - if (buildInRepositories.any { it.id == repository.id }) return@repository + if (repository in buildInRepositories) return@repository scalar("url", repository.url, ScalarStyle.DoubleQuoted) } } + // Place no-updates repositories repositories.find { it.id == "noUpdates" }?.id?.let(::mapping) + // Place custom no-updates repositories repositories .filterNot { it.id == "noUpdates" } - .filter { it.noUpdates && it.id != "mavenLocal" } - .sortedBy { it.id } + .filter(Repository::noUpdates) + .filterNot { it.id == "mavenLocal" } + .sortedBy(Repository::id) .forEach { repository -> mapping(repository.id) { if (repository.url.isNotBlank()) { diff --git a/gradm-runtime/src/test/resources/gradm.unformatted.yml b/gradm-runtime/src/test/resources/gradm.unformatted.yml index a22e194f..56d98232 100644 --- a/gradm-runtime/src/test/resources/gradm.unformatted.yml +++ b/gradm-runtime/src/test/resources/gradm.unformatted.yml @@ -17,7 +17,6 @@ versions: okhttp: "4.9.3" repositories: - mavenLocal: customNoUpdates: noUpdates: true google: @@ -29,6 +28,7 @@ repositories: gradlePluginPortal: url: "https://plugins.gradle.org/m2/" noUpdates: + mavenLocal: dependencies: google: