From 4cc52ace38d4bec9d54a0c9c3da597c03c6e7306 Mon Sep 17 00:00:00 2001 From: Jean-Michel Fayard Date: Wed, 18 Sep 2019 17:47:39 +0200 Subject: [PATCH 1/2] #80 Refine naming convention --- plugin/gradle.properties | 4 +- plugin/settings.gradle.kts | 2 +- .../de/fayard/BuildSrcVersionsPlugin.kt | 2 +- .../kotlin/de/fayard/BuildSrcVersionsTask.kt | 15 +++--- .../internal/BuildSrcVersionsExtensionImpl.kt | 2 +- .../de/fayard/internal/DependencyGraph.kt | 14 +++++- .../kotlin/de/fayard/internal/KotlinPoetry.kt | 50 +++++++++---------- .../kotlin/de/fayard/internal/PluginConfig.kt | 46 ++++++++++------- .../fayard/internal/UpdateGradleProperties.kt | 3 +- .../de/fayard/internal/UpdateVersionsOnly.kt | 7 ++- .../kotlin/de/fayard/GradlePropertiesTest.kt | 8 +-- .../test/kotlin/de/fayard/NonRegression.kt | 10 ++-- plugin/src/test/kotlin/de/fayard/UnitTests.kt | 7 --- plugin/src/test/kotlin/de/fayard/Utils.kt | 8 ++- sample-groovy/gradle.properties | 4 +- sample-groovy/settings.gradle | 2 +- sample-kotlin/build.gradle.kts | 4 +- .../buildSrc/src/main/kotlin/Libs.kt | 22 ++++++-- .../buildSrc/src/main/kotlin/Versions.kt | 6 ++- sample-kotlin/gradle.properties | 5 +- sample-kotlin/settings.gradle.kts | 2 +- sample-versionsOnlyMode/GROOVY_EXT.gradle | 10 ++-- sample-versionsOnlyMode/settings.gradle.kts | 2 +- 23 files changed, 131 insertions(+), 104 deletions(-) diff --git a/plugin/gradle.properties b/plugin/gradle.properties index ae4cf730a..5d9d15e6f 100644 --- a/plugin/gradle.properties +++ b/plugin/gradle.properties @@ -4,9 +4,9 @@ plugin.org.gradle.kotlin.kotlin.dsl=1.2.9 # available=1.3.1 plugin.de.fayard.buildsrcversions=0.6.1 -plugin.com.gradle.plugin.publish=0.10.0 +plugin.com.gradle.plugin-publish=0.10.0 # available=0.10.1 -plugin.com.gradle.build.scan=2.4.1 +plugin.com.gradle.build-scan=2.4.1 # available=2.4.2 version.kotlintest.runner.junit5=3.1.9 # available=3.4.1 diff --git a/plugin/settings.gradle.kts b/plugin/settings.gradle.kts index 11534e3f8..f7ec07f69 100644 --- a/plugin/settings.gradle.kts +++ b/plugin/settings.gradle.kts @@ -1,7 +1,7 @@ pluginManagement { val resolutionStrategyConfig: String? by extra resolutionStrategy.eachPlugin { - val property = "plugin.${requested.id.id}".replace("-", ".") + val property = "plugin.${requested.id.id}" if (extra.has(property) && resolutionStrategyConfig != "false") { val version = extra.get(property) as String useVersion(version) diff --git a/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsPlugin.kt b/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsPlugin.kt index af63724de..a5f8c14f5 100644 --- a/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsPlugin.kt +++ b/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsPlugin.kt @@ -65,7 +65,7 @@ fun Project.useVersionsFromGradleProperties() { val gradleProperty = PluginConfig.considerGradleProperties(candidate.group, candidate.name) .firstOrNull { it in properties } ?: return@eachDependency val message = - "ResolutionStrategy for configuration=$configurationName selected version=${properties[gradleProperty]} from property=$gradleProperty with for dependency=${candidate.group}:${candidate.name}" + "ResolutionStrategy selected version=${properties[gradleProperty]} from property=$gradleProperty with for dependency=${candidate.group}:${candidate.name}" if (resolutionStrategyConfig == "verbose") println(message) useVersion(properties[gradleProperty] ?: error(message)) } diff --git a/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt b/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt index 9e1f8ffd6..02af78d7a 100644 --- a/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt +++ b/plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt @@ -63,8 +63,9 @@ open class BuildSrcVersionsTask : DefaultTask() { KOTLIN_OBJECT -> false else -> return } + val versions = unsortedParsedDependencies.sortedBeautifullyBy { it.versionName } - val kotlinPoetry: KotlinPoetry = kotlinpoet(parsedDependencies, dependencyGraph.gradle, extension) + val kotlinPoetry: KotlinPoetry = kotlinpoet(versions, dependencyGraph.gradle, extension) if (shouldGenerateLibsKt) { kotlinPoetry.Libs.writeTo(outputDir) @@ -90,16 +91,16 @@ open class BuildSrcVersionsTask : DefaultTask() { @TaskAction fun versionsOnlyMode() { val extension: BuildSrcVersionsExtensionImpl = extension() - val updateGradleProperties = UpdateGradleProperties(extension, parsedDependencies) + val updateGradleProperties = UpdateGradleProperties(extension) val versionsOnlyMode = when(val mode = extension.versionsOnlyMode) { null, KOTLIN_OBJECT -> return else -> mode } - val dependencies = (parsedDependencies + PluginConfig.gradleVersionsPlugin + PluginConfig.gradleLatestVersion(dependencyGraph)) - .sortedBeautifullyBy { it.versionName } - .distinctBy { it.versionName } + val dependencies = (unsortedParsedDependencies + PluginConfig.gradleVersionsPlugin + PluginConfig.gradleLatestVersion(dependencyGraph)) + .sortedBeautifullyBy { it.versionProperty } + .distinctBy { it.versionProperty } if (versionsOnlyMode == GRADLE_PROPERTIES) { updateGradleProperties.generateVersionProperties(project, dependencies) @@ -132,7 +133,7 @@ open class BuildSrcVersionsTask : DefaultTask() { return@lazy PluginConfig.readGraphFromJsonFile(jsonInput) } - private val parsedDependencies: List by lazy { + private val unsortedParsedDependencies: List by lazy { val useFdqnByDefault = extension().useFqqnFor.map { PluginConfig.escapeVersionsKt(it) } parseGraph(dependencyGraph, useFdqnByDefault + PluginConfig.MEANING_LESS_NAMES) .map { d -> d.maybeUpdate(update) } @@ -148,7 +149,7 @@ open class BuildSrcVersionsTask : DefaultTask() { private fun extension(): BuildSrcVersionsExtensionImpl { val extension: BuildSrcVersionsExtensionImpl = _extension - if (extension.indent == PluginConfig.DEFAULT_INDENT) { + if (extension.indent == PluginConfig.INDENT_FROM_EDITOR_CONFIG) { val findIndentForKotlin = EditorConfig.findIndentForKotlin(project.file("buildSrc/src/main/kotlin")) extension.indent = findIndentForKotlin ?: PluginConfig.DEFAULT_INDENT } diff --git a/plugin/src/main/kotlin/de/fayard/internal/BuildSrcVersionsExtensionImpl.kt b/plugin/src/main/kotlin/de/fayard/internal/BuildSrcVersionsExtensionImpl.kt index 82a1c40a6..701e9b4c6 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/BuildSrcVersionsExtensionImpl.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/BuildSrcVersionsExtensionImpl.kt @@ -7,7 +7,7 @@ import de.fayard.VersionsOnlyMode internal open class BuildSrcVersionsExtensionImpl( override var renameLibs: String = PluginConfig.DEFAULT_LIBS, override var renameVersions: String = PluginConfig.DEFAULT_VERSIONS, - override var indent: String = PluginConfig.DEFAULT_INDENT, + override var indent: String = PluginConfig.INDENT_FROM_EDITOR_CONFIG, override var versionsOnlyMode: VersionsOnlyMode? = null, override var versionsOnlyFile: String? = null ) : BuildSrcVersionsExtension, java.io.Serializable { diff --git a/plugin/src/main/kotlin/de/fayard/internal/DependencyGraph.kt b/plugin/src/main/kotlin/de/fayard/internal/DependencyGraph.kt index 36cdf04e0..2bb509b33 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/DependencyGraph.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/DependencyGraph.kt @@ -33,9 +33,15 @@ data class Dependency( val projectUrl: String? = "", val name: String = "", var escapedName: String = "", - var versionName: String = "", + var mode: VersionMode = VersionMode.MODULE, val available: AvailableDependency? = null ) { + val versionName: String + get() = PluginConfig.versionKtFor(this) + + val versionProperty: String + get() = PluginConfig.versionPropertyFor(this) + fun maybeUpdate(update: Boolean): Dependency { val newerVersion = newerVersion() return when { @@ -46,6 +52,10 @@ data class Dependency( } } +enum class VersionMode { + MODULE, GROUP, GROUP_MODULE +} + data class GradleConfig( val current: GradleVersion, val nightly: GradleVersion, @@ -76,7 +86,7 @@ data class SingleModeResult( companion object { val NEW_FILE = SingleModeResult(0, 0, "") - val BLOC_NOT_FOUND = SingleModeResult(-1, -1, PluginConfig.DEFAULT_INDENT) + val BLOC_NOT_FOUND = SingleModeResult(-1, -1, PluginConfig.INDENT_FROM_EDITOR_CONFIG) } } diff --git a/plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt b/plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt index 27020f8bb..defa65fec 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt @@ -14,6 +14,7 @@ import org.gradle.plugin.use.PluginDependencySpec fun kotlinpoet(versions: List, gradleConfig: GradleConfig, extension: BuildSrcVersionsExtension): KotlinPoetry { + val gradleVersion = constStringProperty( PluginConfig.GRADLE_LATEST_VERSION, gradleConfig.current.version, @@ -130,45 +131,42 @@ fun parseGraph( ): List { val dependencies: List = graph.current + graph.exceeded + graph.outdated + graph.unresolved + return dependencies.checkModeAndNames(useFdqnByDefault).findCommonVersions() +} - val map = mutableMapOf() - for (d: Dependency in dependencies) { - val key = PluginConfig.escapeVersionsKt(d.name) - val fdqnName = d.fqdnName() - - - if (key in useFdqnByDefault) { - d.escapedName = fdqnName - } else if (map.containsKey(key)) { - d.escapedName = fdqnName - - // also use FDQN for the dependency that conflicts with this one - val other = map[key]!! - other.escapedName = other.fqdnName() - } else { - map[key] = d - d.escapedName = key +fun List.checkModeAndNames(useFdqnByDefault: List): List { + groupBy { d -> d.name } + .forEach { (name, list) -> + for (d: Dependency in list) { + d.mode = when { + d.name in useFdqnByDefault -> VersionMode.GROUP_MODULE + list.size >= 2 -> VersionMode.GROUP_MODULE + else -> VersionMode.MODULE + } + d.escapedName = PluginConfig.escapeVersionsKt( + when (d.mode) { + VersionMode.MODULE -> d.name + VersionMode.GROUP -> d.group + VersionMode.GROUP_MODULE -> "${d.group}_${d.name}" + } + ) + } } - } - return dependencies - .findCommonVersions() - .sortedBeautifullyBy(exceptIf = OutputFile.VERSIONS.existed) { it.versionName } + return this } -fun Dependency.fqdnName(): String = PluginConfig.escapeVersionsKt("${group}_${name}") - fun List.orderDependencies(): List { return this.sortedBy { it.gradleNotation() } } + fun List.findCommonVersions(): List { val map = groupBy { d -> d.group } for (deps in map.values) { val groupTogether = deps.size > 1 && deps.map { it.version }.distinct().size == 1 - - for (d in deps) { - d.versionName = if (groupTogether) PluginConfig.escapeVersionsKt(d.group) else d.escapedName + if (groupTogether) { + deps.forEach { d -> d.mode = VersionMode.GROUP } } } return this diff --git a/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt b/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt index 8567e975a..ae9b59cee 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt @@ -3,6 +3,9 @@ package de.fayard.internal import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask import com.squareup.moshi.JsonAdapter import com.squareup.moshi.Moshi +import de.fayard.internal.VersionMode.GROUP +import de.fayard.internal.VersionMode.GROUP_MODULE +import de.fayard.internal.VersionMode.MODULE import okio.buffer import okio.source import org.gradle.util.GradleVersion @@ -46,17 +49,26 @@ object PluginConfig { * $ ./gradlew -Pversion.kotlin.stdlib=1.3.50 * **/ fun considerGradleProperties(group: String, module: String): List = listOf( - escapeGradleProperty("version.$group.$module"), - escapeGradleProperty("version.$module"), - escapeGradleProperty("version.$module") + "version.$group..$module", + "version.$group", + "version.$module" ) - /** Naming convention: replace [:-_] with "." **/ @JvmStatic - fun escapeGradleProperty(name: String): String = - name.replace(":", ".").replace("_", ".").replace("-", ".") + fun versionPropertyFor(d: Dependency): String = when (d.mode) { + MODULE -> d.name + GROUP -> d.group + GROUP_MODULE -> "${d.group}..${d.name}" + } + + fun versionKtFor(d: Dependency): String = escapeVersionsKt( + when (d.mode) { + MODULE -> d.name + GROUP -> d.group + GROUP_MODULE -> "${d.group}:${d.name}" + } + ) - @JvmStatic fun escapeVersionsKt(name: String): String { val escapedChars = listOf('-', '.', ':') return buildString { @@ -69,7 +81,12 @@ object PluginConfig { const val DEFAULT_LIBS = "Libs" const val DEFAULT_VERSIONS = "Versions" - const val DEFAULT_INDENT = "from-editorconfig-file" + const val INDENT_FROM_EDITOR_CONFIG = "from-editorconfig-file" + const val SPACES4 = " " + const val SPACES2 = " " + const val SPACES0 = "" + const val TAB = "\t" + const val DEFAULT_INDENT = SPACES4 const val BENMANES_REPORT_PATH = "build/dependencyUpdates/report.json" /** Documentation **/ @@ -89,7 +106,7 @@ object PluginConfig { * Found many inspiration for bad libs here https://developer.android.com/jetpack/androidx/migrate * **/ val MEANING_LESS_NAMES: List = listOf( - "common", "core", "core-testing", "testing", "runtime", "extensions", + "common", "core", "testing", "runtime", "extensions", "compiler", "migration", "db", "rules", "runner", "monitor", "loader", "media", "print", "io", "media", "collection", "gradle", "android" ) @@ -170,11 +187,6 @@ object PluginConfig { const val GRADLE_LATEST_VERSION = "gradleLatestVersion" - const val SPACES4 = " " - const val SPACES2 = " " - const val SPACES0 = "" - const val TAB = "\t" - fun supportsTaskAvoidance(): Boolean = GradleVersion.current() >= GradleVersion.version("5.0") @@ -189,16 +201,16 @@ object PluginConfig { val gradleVersionsPlugin: Dependency = Dependency( group = "com.github.ben-manes", - name = "gradle-versions-plugin", + name = "$GRADLE_VERSIONS_PLUGIN_ID.gradle.plugin", version = GRADLE_VERSIONS_PLUGIN_VERSION, - versionName = escapeVersionsKt("$GRADLE_VERSIONS_PLUGIN_ID.gradle.plugin"), + mode = MODULE, available = null ) fun gradleLatestVersion(graph: DependencyGraph): Dependency = Dependency( group = "org.gradle", name = GRADLE_LATEST_VERSION, - versionName = GRADLE_LATEST_VERSION, + mode = MODULE, version = graph.gradle.running.version, available = when { graph.gradle.running == graph.gradle.current -> null diff --git a/plugin/src/main/kotlin/de/fayard/internal/UpdateGradleProperties.kt b/plugin/src/main/kotlin/de/fayard/internal/UpdateGradleProperties.kt index 71d5302de..9686688f9 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/UpdateGradleProperties.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/UpdateGradleProperties.kt @@ -4,8 +4,7 @@ import de.fayard.BuildSrcVersionsExtension import org.gradle.api.Project data class UpdateGradleProperties( - val extension: BuildSrcVersionsExtension, - val dependencies: List + val extension: BuildSrcVersionsExtension ) { fun generateVersionProperties(project: Project, dependencies: List) = with(UpdateVersionsOnly) { diff --git a/plugin/src/main/kotlin/de/fayard/internal/UpdateVersionsOnly.kt b/plugin/src/main/kotlin/de/fayard/internal/UpdateVersionsOnly.kt index bea7a6f84..bebb5f313 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/UpdateVersionsOnly.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/UpdateVersionsOnly.kt @@ -11,11 +11,10 @@ object UpdateVersionsOnly { const val newline = "\n" fun Dependency.asGradleProperty(): String { - val escapedVersionName = PluginConfig.escapeGradleProperty(versionName) - val pluginName = escapedVersionName.substringBeforeLast(".gradle.plugin", "") + val pluginName = versionProperty.substringBeforeLast(".gradle.plugin", "") val key = when { pluginName.isNotBlank() -> "plugin.$pluginName" - else -> "version.${escapedVersionName}" + else -> "version.${versionProperty}" } val commentPrefix = " available=" val spacing = PluginConfig.spaces(key.length - commentPrefix.length - 1) @@ -110,7 +109,7 @@ object UpdateVersionsOnly { fun regenerateBlock(mode: VersionsOnlyMode, dependencies: List, indent: String): List { val comment = mode.comment val result = mutableListOf() - var (before, after) = mode.beforeAfter() + val (before, after) = mode.beforeAfter() result += PluginConfig.VERSIONS_ONLY_INTRO.map { "$indent$comment $it" } diff --git a/plugin/src/test/kotlin/de/fayard/GradlePropertiesTest.kt b/plugin/src/test/kotlin/de/fayard/GradlePropertiesTest.kt index d84858d70..237f37e82 100644 --- a/plugin/src/test/kotlin/de/fayard/GradlePropertiesTest.kt +++ b/plugin/src/test/kotlin/de/fayard/GradlePropertiesTest.kt @@ -20,7 +20,7 @@ class GradlePropertiesTest : FreeSpec({ "gradle-versions-plugin" { val gvp = "com.github.ben-manes:gradle-versions-plugin:0.22.0 // 0.25.0".asDependency() gvp.asGradleProperty() shouldBe """ - |version.gradle.versions.plugin=0.22.0 + |version.gradle-versions-plugin=0.22.0 |# # available=0.25.0 """.trimMargin() } @@ -32,7 +32,7 @@ class GradlePropertiesTest : FreeSpec({ "fully qualified domain name" { val guava = "com.google.guava:guava:15.0".asDependency(fqdn = true) - guava.asGradleProperty() shouldBe "version.com.google.guava.guava=15.0" + guava.asGradleProperty() shouldBe "version.com.google.guava..guava=15.0" } "plugin buildSrcVersions" { @@ -42,9 +42,9 @@ class GradlePropertiesTest : FreeSpec({ |# # available=0.6.0""").trimMargin() } - "plugin com.gradle.plugin.publish" { + "plugin com.gradle.plugin-publish" { val publish = "com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:1.0".asDependency() - publish.asGradleProperty() shouldBe "plugin.com.gradle.plugin.publish=1.0" + publish.asGradleProperty() shouldBe "plugin.com.gradle.plugin-publish=1.0" } } } diff --git a/plugin/src/test/kotlin/de/fayard/NonRegression.kt b/plugin/src/test/kotlin/de/fayard/NonRegression.kt index 83a75ecba..6b53c38cd 100644 --- a/plugin/src/test/kotlin/de/fayard/NonRegression.kt +++ b/plugin/src/test/kotlin/de/fayard/NonRegression.kt @@ -52,11 +52,12 @@ fun nonRegressionForFile(json: File, libsFile: File, versionsFile: File) { emptyList() } + println("Comparing identifiers with ${libsFile.absolutePath}") if (missingLibs.isNotEmpty()) { fail( """ - Missing identifiers for ${json.name} compared to ${libsFile.name}: + Missing libs identifiers for ${json.name} compared to ${libsFile.name}: $missingLibs""".trimIndent() ) } else { @@ -65,10 +66,13 @@ fun nonRegressionForFile(json: File, libsFile: File, versionsFile: File) { } if (missingVersions.isNotEmpty()) { + val newVersions = versionsIdentifiers - versionsFile.readLines() fail( """ - Missing identifiers for ${json.name} compared to ${libsFile.name}: - $missingVersions""".trimIndent() + | Missing versions identifiers for ${json.name} compared to ${libsFile.name}: + | missing=$missingVersions + | new=$newVersions + | """.trimMargin() ) } else { versionsFile.writeText(versionsIdentifiers.joinToStringWithNewLines()) diff --git a/plugin/src/test/kotlin/de/fayard/UnitTests.kt b/plugin/src/test/kotlin/de/fayard/UnitTests.kt index 028125807..0dab53971 100644 --- a/plugin/src/test/kotlin/de/fayard/UnitTests.kt +++ b/plugin/src/test/kotlin/de/fayard/UnitTests.kt @@ -4,7 +4,6 @@ import de.fayard.internal.AvailableDependency import de.fayard.internal.Dependencies import de.fayard.internal.Dependency import de.fayard.internal.PluginConfig -import de.fayard.internal.findCommonVersions import de.fayard.internal.gradleNotation import de.fayard.internal.orderDependencies import de.fayard.internal.versionInformation @@ -43,12 +42,6 @@ class UnitTests: FreeSpec({ } - "Finding common versions" { - val versions = dependencies.findCommonVersions().map { it.versionName }.distinct().sorted() - val expected = listOf("android_arch_persistence_room", "compiler", "gradle", "okio", "krangl", "rxjava", "konan-utils", "kotlin-test").sorted() - versions shouldBe expected - } - "Version information" - { "Available" { Dependency(available = AvailableDependency(release = "1.0.0")).versionInformation() should contain("1.0.0") diff --git a/plugin/src/test/kotlin/de/fayard/Utils.kt b/plugin/src/test/kotlin/de/fayard/Utils.kt index 06ae82ba0..d5980070d 100644 --- a/plugin/src/test/kotlin/de/fayard/Utils.kt +++ b/plugin/src/test/kotlin/de/fayard/Utils.kt @@ -2,7 +2,7 @@ package de.fayard import de.fayard.internal.AvailableDependency import de.fayard.internal.Dependency -import de.fayard.internal.fqdnName +import de.fayard.internal.VersionMode import org.intellij.lang.annotations.Language import java.io.File @@ -41,9 +41,7 @@ fun String.asDependency(fqdn: Boolean = false): Dependency { projectUrl = "", name = name, escapedName = name, - versionName = name, + mode = if (fqdn) VersionMode.GROUP_MODULE else VersionMode.MODULE, available = if (available.isBlank()) null else AvailableDependency(release = available) - ).run { - if (fqdn) copy(versionName = fqdnName()) else this - } + ) } diff --git a/sample-groovy/gradle.properties b/sample-groovy/gradle.properties index 40b65d1a6..1ee17989a 100644 --- a/sample-groovy/gradle.properties +++ b/sample-groovy/gradle.properties @@ -5,6 +5,6 @@ resolutionStrategyConfig=verbose # Generated by $ ./gradlew refreshVersions # You can edit the rest of the file, it will be kept intact # See https://github.com/jmfayard/buildSrcVersions/issues/77 -plugin.com.github.ben.manes.versions=0.25.0 -plugin.com.gradle.build.scan=2.4.2 +plugin.com.github.ben-manes.versions=0.25.0 +plugin.com.gradle.build-scan=2.4.2 version.gradleLatestVersion=5.6.2 \ No newline at end of file diff --git a/sample-groovy/settings.gradle b/sample-groovy/settings.gradle index b4c0393a7..5f5ea8606 100644 --- a/sample-groovy/settings.gradle +++ b/sample-groovy/settings.gradle @@ -5,7 +5,7 @@ pluginManagement { } def resolutionStrategyConfig = ext.find("resolutionStrategyConfig") resolutionStrategy.eachPlugin { - def property = "plugin.${requested.id.id}".replaceAll("-", ".") + def property = "plugin.${requested.id.id}" if (settings.ext.has(property) && resolutionStrategyConfig != "false") { def version = settings.ext.get(property) if (resolutionStrategyConfig == "verbose") print("ResolutionStrategy found version=$version from property=$property") diff --git a/sample-kotlin/build.gradle.kts b/sample-kotlin/build.gradle.kts index 3dd2a6a52..3182740e5 100644 --- a/sample-kotlin/build.gradle.kts +++ b/sample-kotlin/build.gradle.kts @@ -19,6 +19,8 @@ repositories { dependencies { implementation("com.google.guava:guava:15.0") implementation("com.google.inject:guice:2.0") + implementation("com.squareup.okhttp3:okhttp:3.10.0") + implementation("com.squareup.okhttp3:okhttp-urlconnection:3.10.0") implementation(kotlin("stdlib-jdk8")) } @@ -43,7 +45,7 @@ tasks.withType { buildSrcVersions { // See configuration options at https://github.com/jmfayard/buildSrcVersions/issues/53 alwaysUpdateVersions() - useFqdnFor("dependency") + useFqdnFor("guice") renameLibs = "Libs" renameVersions = "Versions" // indent = " " diff --git a/sample-kotlin/buildSrc/src/main/kotlin/Libs.kt b/sample-kotlin/buildSrc/src/main/kotlin/Libs.kt index 94391b26a..68a1c1f69 100644 --- a/sample-kotlin/buildSrc/src/main/kotlin/Libs.kt +++ b/sample-kotlin/buildSrc/src/main/kotlin/Libs.kt @@ -13,6 +13,23 @@ object Libs { "com.gradle.build-scan:com.gradle.build-scan.gradle.plugin:" + Versions.com_gradle_build_scan_gradle_plugin + /** + * http://code.google.com/p/google-guice/ + */ + const val com_google_inject_guice: String = "com.google.inject:guice:" + + Versions.com_google_inject_guice + + /** + * https://github.com/square/okhttp + */ + const val okhttp: String = "com.squareup.okhttp3:okhttp:" + Versions.com_squareup_okhttp3 + + /** + * https://github.com/square/okhttp + */ + const val okhttp_urlconnection: String = "com.squareup.okhttp3:okhttp-urlconnection:" + + Versions.com_squareup_okhttp3 + /** * https://kotlinlang.org/ */ @@ -27,9 +44,4 @@ object Libs { Versions.org_jetbrains_kotlin const val guava: String = "com.google.guava:guava:" + Versions.guava - - /** - * http://code.google.com/p/google-guice/ - */ - const val guice: String = "com.google.inject:guice:" + Versions.guice } diff --git a/sample-kotlin/buildSrc/src/main/kotlin/Versions.kt b/sample-kotlin/buildSrc/src/main/kotlin/Versions.kt index 9ae7e47d5..1aef2cb95 100644 --- a/sample-kotlin/buildSrc/src/main/kotlin/Versions.kt +++ b/sample-kotlin/buildSrc/src/main/kotlin/Versions.kt @@ -12,12 +12,14 @@ object Versions { const val com_gradle_build_scan_gradle_plugin: String = "2.4.2" + const val com_google_inject_guice: String = "2.0" + + const val com_squareup_okhttp3: String = "4.2.0" + const val org_jetbrains_kotlin: String = "1.3.50" const val guava: String = "15.0" - const val guice: String = "2.0" - /** * Current version: "5.6.2" * See issue 19: How to update Gradle itself? diff --git a/sample-kotlin/gradle.properties b/sample-kotlin/gradle.properties index 790bf40d1..5ed7e13c8 100644 --- a/sample-kotlin/gradle.properties +++ b/sample-kotlin/gradle.properties @@ -5,9 +5,10 @@ resolutionStrategyConfig=verbose # Generated by $ ./gradlew refreshVersions # You can edit the rest of the file, it will be kept intact # See https://github.com/jmfayard/buildSrcVersions/issues/77 -plugin.com.github.ben.manes.versions=0.25.0 +plugin.com.github.ben-manes.versions=0.25.0 plugin.org.jetbrains.kotlin.jvm=1.3.50 -plugin.com.gradle.build.scan=2.4.2 +plugin.com.gradle.build-scan=2.4.2 +version.com.squareup.okhttp3=4.2.0 version.org.jetbrains.kotlin=1.3.50 version.gradleLatestVersion=5.6.2 version.guava=15.0 diff --git a/sample-kotlin/settings.gradle.kts b/sample-kotlin/settings.gradle.kts index ad93d7858..1c6bdb5e6 100644 --- a/sample-kotlin/settings.gradle.kts +++ b/sample-kotlin/settings.gradle.kts @@ -5,7 +5,7 @@ pluginManagement { } val resolutionStrategyConfig: String? by extra resolutionStrategy.eachPlugin { - val property = "plugin.${requested.id.id}".replace("-", ".") + val property = "plugin.${requested.id.id}" if (extra.has(property) && resolutionStrategyConfig != "false") { val version = extra.get(property) as String if (resolutionStrategyConfig == "verbose") println("ResolutionStrategy used version=$version from property=$property") diff --git a/sample-versionsOnlyMode/GROOVY_EXT.gradle b/sample-versionsOnlyMode/GROOVY_EXT.gradle index 8b27d5e40..8ad854eb9 100644 --- a/sample-versionsOnlyMode/GROOVY_EXT.gradle +++ b/sample-versionsOnlyMode/GROOVY_EXT.gradle @@ -5,15 +5,11 @@ // See https://github.com/jmfayard/buildSrcVersions/issues/54 ext { com_github_ben_manes_versions_gradle_plugin = '0.25.0' - org_lovedev_greeting_kotlin_gradle_plugin = '1.1' org_jetbrains_kotlin_jvm_gradle_plugin = '1.3.50' - ch_tutteli_kotlin_utils_gradle_plugin = '0.29.0' - com_gradle_build_scan_gradle_plugin = '2.4.1' // available: '2.4.2' - nebula_kotlin_gradle_plugin = '1.3.50' org_jetbrains_kotlin = '1.3.50' - gradleLatestVersion = '5.6.2' - guava = '15.0' - guice = '2.0' + gradlelatestversion = '5.5.1' // available: '5.6.1' + okhttp = '4.1.0' // available: '4.1.1' + okio = '2.0.0' } // diff --git a/sample-versionsOnlyMode/settings.gradle.kts b/sample-versionsOnlyMode/settings.gradle.kts index 242a435d2..b41633d06 100644 --- a/sample-versionsOnlyMode/settings.gradle.kts +++ b/sample-versionsOnlyMode/settings.gradle.kts @@ -5,7 +5,7 @@ pluginManagement { } val resolutionStrategyConfig: String? by extra resolutionStrategy.eachPlugin { - val property = "plugin.${requested.id.id}".replace("-", ".") + val property = "plugin.${requested.id.id}" if (extra.has(property) && resolutionStrategyConfig != "false") { val version = extra.get(property) as String if (resolutionStrategyConfig == "verbose") println("ResolutionStrategy used version=$version from property=$property") From 8921d1ea6561d2909a00dcc1835b903ef7e5cba6 Mon Sep 17 00:00:00 2001 From: Jean-Michel Fayard Date: Wed, 18 Sep 2019 17:55:44 +0200 Subject: [PATCH 2/2] Release v0.6.1 and prepare 0.6.2 --- CHANGELOG.md | 8 ++++++++ README.adoc | 2 +- plugin/build.gradle.kts | 4 ++-- .../src/main/kotlin/de/fayard/internal/PluginConfig.kt | 2 +- sample-kotlin/gradle.properties | 4 ++-- sample-versionsOnlyMode/GROOVY_EXT.gradle | 10 +++++++--- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f91b2171d..bdccb4f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Unreleased +# 0.6.1 + + +- #80 Refine naming convention +- Add plugin version in the output +- Restore indent=FOUR_SPACES when no editorconfig is there +- Add "#" at the beginning of a line in "gradle.properties" so that IntelliJ does not refactor/break the alignment + # 0.6.0 Major new feature: diff --git a/README.adoc b/README.adoc index cc0de79c6..1192f7372 100644 --- a/README.adoc +++ b/README.adoc @@ -1,5 +1,5 @@ //include::includes.adoc[] -:plugin_version: 0.6.0 +:plugin_version: 0.6.1 :repo: jmfayard/buildSrcVersions :branch: 26-buildSrcVersions :github: https://github.com/{repo} diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 0c0e1d984..08d95f97b 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("de.fayard.buildSrcVersions") version ("0.6.0") // plugin.de.fayard.buildSrcVersions + id("de.fayard.buildSrcVersions") version ("0.6.1") // plugin.de.fayard.buildSrcVersions id("com.gradle.plugin-publish") `java-gradle-plugin` @@ -11,7 +11,7 @@ plugins { } -version = "0.6.1" // plugin.de.fayard.buildSrcVersions +version = "0.6.2" // plugin.de.fayard.buildSrcVersions group = "de.fayard" diff --git a/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt b/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt index ae9b59cee..9f2879781 100644 --- a/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt +++ b/plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt @@ -17,7 +17,7 @@ object PluginConfig { const val PLUGIN_ID = "de.fayard.buildSrcVersions" - const val PLUGIN_VERSION = "0.6.1" // plugin.de.fayard.buildSrcVersions + const val PLUGIN_VERSION = "0.6.2" // plugin.de.fayard.buildSrcVersions const val GRADLE_VERSIONS_PLUGIN_ID = "com.github.ben-manes.versions" const val GRADLE_VERSIONS_PLUGIN_VERSION = "0.25.0" // Sync with plugin/build.gradle.kts const val EXTENSION_NAME = "buildSrcVersions" diff --git a/sample-kotlin/gradle.properties b/sample-kotlin/gradle.properties index 5ed7e13c8..3fc37fc2c 100644 --- a/sample-kotlin/gradle.properties +++ b/sample-kotlin/gradle.properties @@ -8,8 +8,8 @@ resolutionStrategyConfig=verbose plugin.com.github.ben-manes.versions=0.25.0 plugin.org.jetbrains.kotlin.jvm=1.3.50 plugin.com.gradle.build-scan=2.4.2 +version.com.google.inject..guice=2.0 version.com.squareup.okhttp3=4.2.0 version.org.jetbrains.kotlin=1.3.50 version.gradleLatestVersion=5.6.2 -version.guava=15.0 -version.guice=2.0 \ No newline at end of file +version.guava=15.0 \ No newline at end of file diff --git a/sample-versionsOnlyMode/GROOVY_EXT.gradle b/sample-versionsOnlyMode/GROOVY_EXT.gradle index 8ad854eb9..86dbf6973 100644 --- a/sample-versionsOnlyMode/GROOVY_EXT.gradle +++ b/sample-versionsOnlyMode/GROOVY_EXT.gradle @@ -5,11 +5,15 @@ // See https://github.com/jmfayard/buildSrcVersions/issues/54 ext { com_github_ben_manes_versions_gradle_plugin = '0.25.0' + org_lovedev_greeting_kotlin_gradle_plugin = '1.1' org_jetbrains_kotlin_jvm_gradle_plugin = '1.3.50' + ch_tutteli_kotlin_utils_gradle_plugin = '0.29.0' + com_gradle_build_scan_gradle_plugin = '2.4.1' // available: '2.4.2' + nebula_kotlin_gradle_plugin = '1.3.50' org_jetbrains_kotlin = '1.3.50' - gradlelatestversion = '5.5.1' // available: '5.6.1' - okhttp = '4.1.0' // available: '4.1.1' - okio = '2.0.0' + gradlelatestversion = '5.6.2' + guava = '15.0' + guice = '2.0' } //