Skip to content

Commit

Permalink
#84 #92 version 0.6.2 (#93)
Browse files Browse the repository at this point in the history
#84 #92 version 0.6.2
  • Loading branch information
Jean-Michel Fayard authored Oct 1, 2019
2 parents 215b184 + 73f8e84 commit 1199312
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 107 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Unreleased

# 0.6.2

If you want to manage your versions from gradle.properties for better compilation avoidance,
but still want to have buildSrc/src/main/Libs.kt generated in your multi-module Gradle build,
that's now possible.

- Run `$ ./gradlew refreshVersions && ./gradlew buildSrcVersions`
- To look for available dependency updates, run `$ ./gradlew refreshVersions`
- When you add a dependency, run `$ ./gradlew buildSrcVersions`

Other changes

- Fixes #92 gradle.properties is getting updated and Versions.kt stops updating when running buildSrcVersions
- Add non regression for identifiers in gradle.properties
- Add Github issue and pull-request templates
- Improve README
Expand Down
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//include::includes.adoc[]
:plugin_version: 0.6.1
:plugin_version: 0.6.2
:repo: jmfayard/buildSrcVersions
:branch: 26-buildSrcVersions
:github: https://github.com/{repo}
Expand Down Expand Up @@ -114,6 +114,7 @@ Not only code, but also good documentation can help you upgrate an old project t

I have a series of articles called `Built with Gradle`:

- https://dev.to/jmfayard/my-project-is-open-to-kotlin-contributors-m4b[#hacktoberfest : project is open to contributors!]
- https://dev.to/jmfayard/helping-out-with-gradle-builds-for-hacktoberfest-1c1c[Helping out with Gradle builds for hacktoberfest]
- https://dev.to/jmfayard/the-one-gradle-trick-that-supersedes-all-the-others-5bpg[Use the Build Scan ! The one Gradle trick that supersedes all the others]
- https://dev.to/jmfayard/configuring-gradle-with-gradle-properties-211k[Configuring Gradle with the `gradle.properties` file]
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Run task `:publishPlugins`
- Check plugin portal https://plugins.gradle.org/plugin/de.fayard.buildSrcVersions
- Update CHANGELOG
- Create a GitHub release https://github.com/jmfayard/buildSrcVersions/releases/new
- Try the plugin in sample projects
- Update `:plugin_version:` in `README.adoc`
- Otherwise update the README
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.1") // plugin.de.fayard.buildSrcVersions
id("de.fayard.buildSrcVersions") version ("0.6.2") // plugin.de.fayard.buildSrcVersions

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


version = "0.6.2" // plugin.de.fayard.buildSrcVersions
version = "0.6.3" // plugin.de.fayard.buildSrcVersions
group = "de.fayard"


Expand Down
2 changes: 1 addition & 1 deletion plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See https://github.com/jmfayard/buildSrcVersions/issues/77
plugin.org.gradle.kotlin.kotlin.dsl=1.2.9
# available=1.3.1
plugin.de.fayard.buildsrcversions=0.6.1
plugin.de.fayard.buildsrcversions=0.6.2
plugin.com.gradle.plugin-publish=0.10.0
# available=0.10.1
plugin.com.gradle.build-scan=2.4.1
Expand Down
18 changes: 13 additions & 5 deletions plugin/src/main/kotlin/de/fayard/BuildSrcVersionsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ open class BuildSrcVersionsTask : DefaultTask() {
OutputFile.logFileWasModified(OutputFile.LIBS.path, OutputFile.LIBS.existed)
}

kotlinPoetry.Versions.writeTo(outputDir)
OutputFile.logFileWasModified(OutputFile.VERSIONS.path, OutputFile.VERSIONS.existed)
if (PluginConfig.useRefreshVersions.not()) {
kotlinPoetry.Versions.writeTo(outputDir)
OutputFile.logFileWasModified(OutputFile.VERSIONS.path, OutputFile.VERSIONS.existed)
}

val renamedVersionsKt: File? = when(extension.versionsOnlyMode to extension.versionsOnlyFile) {
null to null -> null
Expand All @@ -97,12 +99,15 @@ open class BuildSrcVersionsTask : DefaultTask() {
val extension: BuildSrcVersionsExtensionImpl = extension()
val updateGradleProperties = UpdateGradleProperties(extension)

val specialDependencies =
listOf(PluginConfig.gradleVersionsPlugin, PluginConfig.buildSrcVersionsPlugin, PluginConfig.gradleLatestVersion(dependencyGraph))

val versionsOnlyMode = when(val mode = extension.versionsOnlyMode) {
null, KOTLIN_OBJECT -> return
else -> mode
}

val dependencies = (unsortedParsedDependencies + PluginConfig.gradleVersionsPlugin + PluginConfig.gradleLatestVersion(dependencyGraph))
val dependencies = (unsortedParsedDependencies + specialDependencies)
.sortedBeautifullyBy { it.versionProperty }
.distinctBy { it.versionProperty }

Expand All @@ -123,7 +128,7 @@ open class BuildSrcVersionsTask : DefaultTask() {

val message = with(PluginConfig) {
"""
|Running plugins.id("$PLUGIN_ID").version("$PLUGIN_VERSION") with configuration: $extension
|Running plugins.id("$PLUGIN_ID").version("$PLUGIN_VERSION") with useRefreshVersions=${useRefreshVersions} and extension: $extension
|See documentation at $issue53PluginConfiguration
|
""".trimMargin()
Expand All @@ -147,7 +152,9 @@ open class BuildSrcVersionsTask : DefaultTask() {
private lateinit var _extension: BuildSrcVersionsExtensionImpl

fun configure(action: Action<BuildSrcVersionsExtension>) {
this._extension = project.extensions.getByType<BuildSrcVersionsExtension>() as BuildSrcVersionsExtensionImpl
val projectExtension = project.extensions.getByType<BuildSrcVersionsExtension>() as BuildSrcVersionsExtensionImpl
this._extension = projectExtension.defensiveCopy()

action.execute(this._extension)
if (_extension.indent == PluginConfig.INDENT_FROM_EDITOR_CONFIG) {
val findIndentForKotlin = EditorConfig.findIndentForKotlin(project.file("buildSrc/src/main/kotlin"))
Expand All @@ -156,6 +163,7 @@ open class BuildSrcVersionsTask : DefaultTask() {
if (_extension.alwaysUpdateVersions) {
update = true
}
PluginConfig.useRefreshVersions = project.hasProperty("plugin.de.fayard.buildSrcVersions")
}

private fun extension(): BuildSrcVersionsExtensionImpl = _extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ internal open class BuildSrcVersionsExtensionImpl(
override var versionsOnlyMode: VersionsOnlyMode? = null,
override var versionsOnlyFile: String? = null
) : BuildSrcVersionsExtension, java.io.Serializable {

// Necessary because of https://github.com/jmfayard/buildSrcVersions/issues/92
fun defensiveCopy(): BuildSrcVersionsExtensionImpl = BuildSrcVersionsExtensionImpl(
renameLibs, renameVersions, indent, versionsOnlyMode, versionsOnlyFile
).also {
it.alwaysUpdateVersions = this.alwaysUpdateVersions
it.useFqqnFor = this.useFqqnFor
}

override fun alwaysUpdateVersions() {
this.alwaysUpdateVersions = true
}
Expand Down
6 changes: 4 additions & 2 deletions plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ fun Dependency.newerVersion(): String? =
}

fun Dependency.generateLibsProperty(extension: BuildSrcVersionsExtension): PropertySpec {
val libValue = when(version) {
"none" -> CodeBlock.of("%S", "$group:$name")
val libValue = when {
version == "none" -> CodeBlock.of("%S", "$group:$name")
PluginConfig.useRefreshVersions -> CodeBlock.of("%S", "$group:$name:$version")
else -> CodeBlock.of("%S + ${extension.renameVersions}.%L", "$group:$name:", versionName)
}

val libComment = when {
projectUrl == null -> null
PluginConfig.useRefreshVersions -> null
else -> CodeBlock.of("%L", this.projectUrl)
}

Expand Down
11 changes: 10 additions & 1 deletion 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.2" // plugin.de.fayard.buildSrcVersions
const val PLUGIN_VERSION = "0.6.3" // 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 @@ -207,6 +207,14 @@ object PluginConfig {
available = null
)

val buildSrcVersionsPlugin: Dependency = Dependency(
group = "de.fayard",
name = "$PLUGIN_ID.gradle.plugin",
version = PLUGIN_VERSION,
mode = MODULE,
available = null
)

fun gradleLatestVersion(graph: DependencyGraph): Dependency = Dependency(
group = "org.gradle",
name = GRADLE_LATEST_VERSION,
Expand All @@ -218,6 +226,7 @@ object PluginConfig {
}
)

var useRefreshVersions: Boolean = false

lateinit var configureGradleVersions: (DependencyUpdatesTask.() -> Unit) -> Unit

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

const val guava: String = "com.google.guava:guava:" + Versions.guava
const val guava: String = "com.google.guava:guava:15.0"

/**
* http://code.google.com/p/google-guice/
*/
const val guice: String = "com.google.inject:guice:" + Versions.guice
const val guice: String = "com.google.inject:guice:2.0"
}
5 changes: 2 additions & 3 deletions sample-groovy/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ 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.3
plugin.com.gradle.build-scan=2.4.2
version.gradleLatestVersion=5.6.2
version.guava=15.0
# # available=23.0
version.guice=2.0
# # available=4.2.2
version.guice=2.0
4 changes: 2 additions & 2 deletions sample-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tasks.withType(JavaExec::class.java) {

// How to update Gradle itself? https://github.com/jmfayard/buildSrcVersions/issues/19
tasks.withType<Wrapper> {
gradleVersion = Versions.gradleLatestVersion
gradleVersion = findProperty("gradleLatestVersion") as? String ?: gradle.gradleVersion
distributionType = Wrapper.DistributionType.ALL
}

Expand All @@ -49,7 +49,7 @@ buildSrcVersions {
useFqdnFor("guice", "mongo-java-driver")
renameLibs = "Libs"
renameVersions = "Versions"
indent = " "
indent = " "
rejectVersionIf {
isNonStable(candidate.version) && isNonStable(currentVersion).not()
}
Expand Down
53 changes: 14 additions & 39 deletions sample-kotlin/buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,23 @@
*/
object Libs {
const val org_jetbrains_kotlin_jvm_gradle_plugin: String =
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:" +
Versions.org_jetbrains_kotlin_jvm_gradle_plugin
"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:" +
Versions.com_gradle_build_scan_gradle_plugin

/**
* http://www.mongodb.org
*/
const val org_mongodb_mongo_java_driver: String = "org.mongodb:mongo-java-driver:" +
Versions.org_mongodb_mongo_java_driver

/**
* 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/
*/
"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"

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

const val okhttp: String = "com.squareup.okhttp3:okhttp:4.2.0"

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:" +
Versions.org_jetbrains_kotlin
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.50"

/**
* https://kotlinlang.org/
*/
const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:" +
Versions.org_jetbrains_kotlin
const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50"

const val guava: String = "com.google.guava:guava:" + Versions.guava
const val guava: String = "com.google.guava:guava:15.0"
}
31 changes: 0 additions & 31 deletions sample-kotlin/buildSrc/src/main/kotlin/Versions.kt

This file was deleted.

1 change: 1 addition & 0 deletions sample-kotlin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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.3
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
3 changes: 2 additions & 1 deletion sample-versionsOnlyMode/GROOVY_DEF.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
// 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.3'
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'
def gradlelatestversion = '5.5.1' // available: '5.6.1'
def okhttp = '4.1.0' // available: '4.1.1'
def okio = '2.0.0'
// </buildSrcVersions>
Expand Down
11 changes: 4 additions & 7 deletions sample-versionsOnlyMode/GROOVY_EXT.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
// 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'
de_fayard_buildsrcversions_gradle_plugin = '0.6.3'
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'
}
// </buildSrcVersions>

Expand Down
3 changes: 2 additions & 1 deletion sample-versionsOnlyMode/KOTLIN_VAL.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
// 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.3"
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"
val gradlelatestversion = "5.5.1" // available: "5.6.1"
val okhttp = "4.1.0" // available: "4.1.1"
val okio = "2.0.0"
// </buildSrcVersions>
Expand Down
Loading

0 comments on commit 1199312

Please sign in to comment.