The Gradle plugin de.fayard.refreshVersions
goal is to make it as painless as possible to upgrade your project to the latest and greatest version of everything.
It does that by extracting all your dependencies, searching for available dependencies updates and generating Kotlin code, Groovy code or Gradle properties.
The plugin was called before de.fayard.buildSrcVersions
, which still exists and is currently identical.
[The goal in the future is to focus on :refreshVersions](Splitties#104)
Edit your root build.gradle(.kts)
file
We recommend to use the plugins
block:
buildscript {
//...
}
plugins {
id("de.fayard.refreshVersions") version "0.7.0"
}
// Don't put any code before the buildscripts {} and plugins {} block
Updating Gradle is usually a good idea. You get less bugs, more features and more build speed, and it’s as simple as this:
$ ./gradlew wrapper --gradle-version 5.6.2
If you have to, use instead the legacy buildscript { … }
syntax
Legacy buildscript syntax - click to expand
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "de.fayard.refrshVersions:de.fayard.refrshVersions.gradle.plugin:0.7.0"
}
}
apply plugin: "de.fayard.refrshVersions"
The plugin provides two tasks: :refreshVersions
and :buildSrcVersions
The task :refreshVersions
was introduced in the version 0.6.0
of the plugin.
It provides just the versions and their available updates and is a good solution for simple, single-module Gradle projects.
The task :buildSrcVersions
is well suited for complex multi-module Gradle projects: Android, Kotlin multi-platform, …
It generates this kind of code inside the Gradle buildSrc
module.
Not only code, but also good documentation can help you upgrate an old project to the latest and greatest.
I have a series of articles called Built with Gradle
:
You can follow me at https://dev.to/jmfayard
No configuration is required, but some things are configurable.
The default configuration is:
// See Plugin configuration at https://github.com/jmfayard/buildSrcVersions/issues/53
buildSrcVersions {
rejectVersionIf {
isNonStable(candidate.version)
}
orderBy = OrderBy.GROUP_AND_LENGTH
indent = "from-editorconfig-file"
renameLibs = "Libs"
renameVersions = "Versions"
useFdqnFor() // nothing
}
-
Kotlin, JVM and Android projects.
-
Gradle 4.3+ and Gradle 5.0+
-
The IDE integration works
-
for both
build.gradle
(Groovy) andbuild.gradle.kts
(Kotlin) files. -
in IntelliJ IDEA 2018.03 and better
-
in Android Studio 3.5 and better. It was broken in 3.3 and 3.4 due bug #123032843: IDE integration with the buildSrc
-
-
First, to do no harm. The plugin should never update itself or otherwise break an existing build. The plugin should do nothing unless it’s explicitely called.
-
Be Lazy. Use code generation to avoid writing tedious code manually. Find available updates automatically instead of googling them. The plugin should do the right thing by default, no configuration should be mandatory. Leverage IDE tooling support (auto-completion, …).
-
Be Humble. Render to the programmer the things that are the programmer’s. This include using the generated code and updating the dependencies.
Questions? Look at the existing issues, then ask your own.
See CHANGELOG.md
If you migrate from an older version, two configuration options have been removed: rejectedVersionKeywords
and useFdqnFor
.
-
This project is licensed under the MIT License. See LICENSE.txt
-
Explain your use case and start the discussion before your submit a pull-request
-
Your feature request or bug report may be better adressed by the parent plugin. Check out ben-manes/gradle-versions-plugin.
-
CONTRIBUTING.md describes the process for submitting pull requests.
Gradle and JetBrains have made this plugin possible
by working on improving the IDE support for Kotlin code from the buildSrc
module.
This plugin embraces and extends Ben Manes’s wonderful "Versions" plugin.
The Kotlin code generation is powered by Square’s Kotlinpoet