Skip to content

Commit

Permalink
Release v0.6.5 (#101)
Browse files Browse the repository at this point in the history
Release v0.6.5
  • Loading branch information
Jean-Michel Fayard authored Oct 10, 2019
2 parents fd2fddf + 3223434 commit b51be65
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 44 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Unreleased

# 0.6.5

- useFqdnFor() should also work for groups #99
- Always update version "_" or "+" #98
- (maybe) Non deterministic behavior #95
- rejectVersionIf { isStable(currentVersion) && isNonStable(candidate.version) } #96

# 0.6.4

- isStable(currentVersion) && isNonStable(candidate.version) #96
- useFqdnFor() should also work for groups #99
-

# 0.6.3

Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// plugin.de.fayard.buildSrcVersions
:plugin_version: 0.6.4
:plugin_version: 0.6.5
:gradle_version: 5.6.2
:repo: jmfayard/buildSrcVersions
:branch: 26-buildSrcVersions
Expand Down
4 changes: 2 additions & 2 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("de.fayard.buildSrcVersions") version ("0.6.4") // plugin.de.fayard.buildSrcVersions
id("de.fayard.buildSrcVersions") version ("0.6.5") // plugin.de.fayard.buildSrcVersions

id("com.gradle.plugin-publish")
`java-gradle-plugin`
Expand All @@ -11,7 +11,7 @@ plugins {
}


version = "0.6.5" // plugin.de.fayard.buildSrcVersions
version = "0.7.0" // plugin.de.fayard.buildSrcVersions
group = "de.fayard"


Expand Down
3 changes: 1 addition & 2 deletions plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ open class BuildSrcVersionsTask : DefaultTask() {
}

private val unsortedParsedDependencies: List<Dependency> by lazy {
val useFdqnByDefault = extension().useFqqnFor.map { PluginConfig.escapeVersionsKt(it) }
parseGraph(dependencyGraph, useFdqnByDefault + PluginConfig.MEANING_LESS_NAMES)
parseGraph(dependencyGraph, extension().useFqqnFor)
.map { d -> d.maybeUpdate(update || extension().alwaysUpdateVersions) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data class Dependency(
var mode: VersionMode = VersionMode.MODULE,
val available: AvailableDependency? = null
) {
val module: String get() = name
val versionName: String
get() = PluginConfig.versionKtFor(this)

Expand Down
36 changes: 16 additions & 20 deletions plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,28 @@ fun Dependency.generateLibsProperty(extension: BuildSrcVersionsExtension): Prope

fun parseGraph(
graph: DependencyGraph,
useFdqnByDefault: List<String>
useFdqn: List<String>
): List<Dependency> {

val dependencies: List<Dependency> = graph.current + graph.exceeded + graph.outdated + graph.unresolved
return dependencies.checkModeAndNames(useFdqnByDefault).findCommonVersions()
val resolvedUseFqdn = PluginConfig.computeUseFqdnFor(dependencies, useFdqn, PluginConfig.MEANING_LESS_NAMES)
return dependencies.checkModeAndNames(resolvedUseFqdn).findCommonVersions()
}

fun List<Dependency>.checkModeAndNames(useFdqnByDefault: List<String>): List<Dependency> {
groupBy { d -> d.name }
.forEach { (name, list) ->
for (d: Dependency in list) {
d.mode = when {
d.name in useFdqnByDefault -> VersionMode.GROUP_MODULE
PluginConfig.escapeVersionsKt(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}"
}
)
}
for (d: Dependency in this) {
d.mode = when {
d.name in useFdqnByDefault -> VersionMode.GROUP_MODULE
PluginConfig.escapeVersionsKt(d.name) in useFdqnByDefault -> 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 this
}

Expand Down
15 changes: 13 additions & 2 deletions plugin/src/main/kotlin/de/fayard/internal/PluginConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object PluginConfig {


const val PLUGIN_ID = "de.fayard.buildSrcVersions"
const val PLUGIN_VERSION = "0.6.5" // plugin.de.fayard.buildSrcVersions
const val PLUGIN_VERSION = "0.7.0" // 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"
Expand Down Expand Up @@ -107,7 +107,7 @@ object PluginConfig {
val MEANING_LESS_NAMES: List<String> = listOf(
"common", "core", "testing", "runtime", "extensions",
"compiler", "migration", "db", "rules", "runner", "monitor", "loader",
"media", "print", "io", "media", "collection", "gradle", "android"
"media", "print", "io", "collection", "gradle", "android"
)

val INITIAL_GITIGNORE = """
Expand Down Expand Up @@ -225,6 +225,17 @@ object PluginConfig {
}
)

fun computeUseFqdnFor(
dependencies: List<Dependency>,
configured: List<String>,
byDefault: List<String> = MEANING_LESS_NAMES
) : List<String> {
val groups = (configured + byDefault).filter { it.contains(".") }.distinct()
val depsFromGroups = dependencies.filter { it.group in groups }.map { it.module }
val ambiguities = dependencies.groupBy { it.module }.filter { it.value.size > 1 }.map { it.key }
return (configured + byDefault + ambiguities + depsFromGroups - groups).distinct().sorted()
}

var useRefreshVersions: Boolean = false

lateinit var configureGradleVersions: (DependencyUpdatesTask.() -> Unit) -> Unit
Expand Down
43 changes: 43 additions & 0 deletions plugin/src/test/kotlin/de/fayard/FqdnTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.fayard

import de.fayard.internal.PluginConfig
import io.kotlintest.matchers.collections.containExactlyInAnyOrder
import io.kotlintest.should
import io.kotlintest.shouldBe
import io.kotlintest.specs.FreeSpec

class FqdnTest: FreeSpec({
val appCompat = "androidx.appcompat:appcompat:_".asDependency()
val asyncLayoutInflater = "androidx.asynclayoutinflater:asynclayoutinflater:_".asDependency()
val browser = "androidx.browser:browser:_".asDependency()
val car = "androidx.car:car:_".asDependency()
val sliceCore = "androidx.slice:slice-core:_".asDependency()
val sliceView = "androidx.slice:slice-view:_".asDependency()

val ALL = listOf(appCompat, asyncLayoutInflater, browser, car, sliceCore, sliceView)
val NO_DEFAULT = emptyList<String>()

with(PluginConfig) {

"Nothing configured -> MEANINGLESS NAMES" {
computeUseFqdnFor(emptyList(), emptyList()) shouldBe MEANING_LESS_NAMES.sorted()
}

"Using a dependency module" {
val result = computeUseFqdnFor(ALL, listOf("car", "car", "browser", "slice-car"), listOf("browser", "gradle"))
result shouldBe listOf("browser", "car", "gradle", "slice-car")
}

"Using a group" {
computeUseFqdnFor(ALL, listOf("androidx.slice", "androidx.browser", "com.example"), NO_DEFAULT) shouldBe listOf("browser", "slice-core", "slice-view")
}

"Ambiguity in module names" {
val annotations = listOf(
"androidx.annotation:annotation:_".asDependency(),
"com.example:annotation:_".asDependency()
)
computeUseFqdnFor(annotations, emptyList(), emptyList()) shouldBe listOf("annotation")
}
}
})
4 changes: 3 additions & 1 deletion sample-groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ repositories {
dependencies {
compile("com.google.guava:guava:15.0")
compile("com.google.inject:guice:2.0")
compile("androidx.annotation:annotation:1.1.0")
compile("org.jetbrains:annotation:17.0.0")
}

def isNonStable = { String version ->
Expand All @@ -32,7 +34,7 @@ def isNonStable = { String version ->
}

buildSrcVersions {
useFqdnFor('module')
useFqdnFor('module', 'com.google.inject')
renameLibs = "Libs"
renameVersions = "Versions"
indent = " "
Expand Down
10 changes: 7 additions & 3 deletions sample-groovy/buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import kotlin.String
*/
object Libs {
const val com_gradle_build_scan_gradle_plugin: String =
"com.gradle.build-scan:com.gradle.build-scan.gradle.plugin:2.4.2"
"com.gradle.build-scan:com.gradle.build-scan.gradle.plugin:2.4.2"

const val guava: String = "com.google.guava:guava:15.0"
const val androidx_annotation_annotation: String = "androidx.annotation:annotation:1.1.0"

const val org_jetbrains_annotation: String = "org.jetbrains:annotation:17.0.0"

const val guice: String = "com.google.inject:guice:2.0"
const val com_google_inject_guice: String = "com.google.inject:guice:2.0"

const val guava: String = "com.google.guava:guava:15.0"
}
8 changes: 5 additions & 3 deletions sample-groovy/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ resolutionStrategyConfig=verbose
# 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.de.fayard.buildSrcVersions=0.6.5
plugin.de.fayard.buildSrcVersions=0.7.0
plugin.com.gradle.build-scan=2.4.2
version.androidx.annotation..annotation=1.1.0
version.org.jetbrains..annotation=17.0.0
version.com.google.inject..guice=2.0
version.gradleLatestVersion=5.6.2
version.guava=15.0
version.guice=2.0
version.guava=15.0
8 changes: 5 additions & 3 deletions sample-kotlin/buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import kotlin.String

/**
* Generated by https://github.com/jmfayard/buildSrcVersions
*
Expand All @@ -6,10 +8,10 @@
*/
object Libs {
const val org_jetbrains_kotlin_jvm_gradle_plugin: String =
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.3.50"
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.3.50"

const val com_gradle_build_scan_gradle_plugin: String =
"com.gradle.build-scan:com.gradle.build-scan.gradle.plugin:2.4.2"
"com.gradle.build-scan:com.gradle.build-scan.gradle.plugin:2.4.2"

const val org_mongodb_mongo_java_driver: String = "org.mongodb:mongo-java-driver:3.11.0"

Expand All @@ -20,7 +22,7 @@ object Libs {
const val okhttp_urlconnection: String = "com.squareup.okhttp3:okhttp-urlconnection:4.2.0"

const val kotlin_scripting_compiler_embeddable: String =
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.50"
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.50"

const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50"

Expand Down
2 changes: 1 addition & 1 deletion sample-kotlin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resolutionStrategyConfig=verbose
# 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.de.fayard.buildSrcVersions=0.6.5
plugin.de.fayard.buildSrcVersions=0.7.0
plugin.org.jetbrains.kotlin.jvm=1.3.50
plugin.com.gradle.build-scan=2.4.2
version.org.mongodb..mongo-java-driver=3.11.0
Expand Down
2 changes: 1 addition & 1 deletion sample-versionsOnlyMode/GROOVY_DEF.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Generated by ./gradle buildSrcVersions
// See https://github.com/jmfayard/buildSrcVersions/issues/54
def com_github_ben_manes_versions_gradle_plugin = '0.25.0'
def de_fayard_buildsrcversions_gradle_plugin = '0.6.5'
def de_fayard_buildsrcversions_gradle_plugin = '0.7.0'
def org_jetbrains_kotlin_jvm_gradle_plugin = '1.3.50'
def org_jetbrains_kotlin = '1.3.50'
def gradlelatestversion = '5.5.1' // available: '5.6.1'
Expand Down
2 changes: 1 addition & 1 deletion sample-versionsOnlyMode/GROOVY_EXT.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See https://github.com/jmfayard/buildSrcVersions/issues/54
ext {
com_github_ben_manes_versions_gradle_plugin = '0.25.0'
de_fayard_buildsrcversions_gradle_plugin = '0.6.5'
de_fayard_buildsrcversions_gradle_plugin = '0.7.0'
org_jetbrains_kotlin_jvm_gradle_plugin = '1.3.50'
org_jetbrains_kotlin = '1.3.50'
gradlelatestversion = '5.5.1' // available: '5.6.1'
Expand Down
2 changes: 1 addition & 1 deletion sample-versionsOnlyMode/KOTLIN_VAL.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Generated by ./gradle buildSrcVersions
// See https://github.com/jmfayard/buildSrcVersions/issues/54
val com_github_ben_manes_versions_gradle_plugin = "0.25.0"
val de_fayard_buildsrcversions_gradle_plugin = "0.6.5"
val de_fayard_buildsrcversions_gradle_plugin = "0.7.0"
val org_jetbrains_kotlin_jvm_gradle_plugin = "1.3.50"
val org_jetbrains_kotlin = "1.3.50"
val gradlelatestversion = "5.5.1" // available: "5.6.1"
Expand Down
5 changes: 2 additions & 3 deletions sample-versionsOnlyMode/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ resolutionStrategyConfig=verbose
# See https://github.com/jmfayard/buildSrcVersions/issues/77
plugin.com.github.ben-manes.versions=0.25.0
plugin.org.lovedev.greeting.kotlin=1.1
plugin.de.fayard.buildSrcVersions=0.6.5
plugin.de.fayard.buildSrcVersions=0.7.0
plugin.org.jetbrains.kotlin.jvm=1.3.50
plugin.ch.tutteli.kotlin.utils=0.29.0
plugin.com.gradle.build-scan=2.4.1
# # available=2.4.2
plugin.com.gradle.build-scan=2.4.2
plugin.nebula.kotlin=1.3.50
version.org.jetbrains.kotlin=1.3.50
version.gradleLatestVersion=5.6.2
Expand Down

0 comments on commit b51be65

Please sign in to comment.