Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

versionsOnlyMode for single-module Gradle projects #55

Closed
jmfayard opened this issue Aug 26, 2019 · 0 comments
Closed

versionsOnlyMode for single-module Gradle projects #55

jmfayard opened this issue Aug 26, 2019 · 0 comments
Assignees
Labels
Milestone

Comments

@jmfayard
Copy link
Member

jmfayard commented Aug 26, 2019

Status:
Improved and now part of "gradle :refreshVersions" generates gradle.properties with versions and available updates


Status: released in v0.5.0

Context: my Gradle plugin buildSrcVersions extends the gradle-versions-plugin. It scan your Gradle builds to search for available updates to your dependencies and generate code to make it extra-convenient. This new feature is designed for simple (single-module) Gradle projects for which it provides an easy solution to a simple problem.

New feature: versionsOnlyMode

The plugin can now be configured like this

pluginVersion

// build.gradle.kts
plugins {
  id("de.fayard.buildSrcVersions").version("0.5.0")
}

buildSrcVersions {
   versionsOnlyMode = VersionsOnlyMode.KOTLIN_VAL
   versionsOnlyFile = "build.gradle.kts"
}

or

// build.gradle
plugins {
  id 'de.fayard.buildSrcVersions ' version '0.5.0'
}
buildSrcVersions {
   versionsOnlyMode = "GROOVY_DEV"
   versionsOnlyFile = "build.gradle"
}

versionsOnlyMode is an enum:

First run

The first time you run ./gradle buildSrcVersions, it will print something like:

// <buildSrcVersions>
// Generated by ./gradle buildSrcVersions
// See https://github.com/jmfayard/buildSrcVersions/issues/55
val org_jetbrains_kotlin_jvm_gradle_plugin = "1.3.11"  // available: "1.3.50"
val kotlin_stdlib_jdk8 = "1.3.50"
val okhttp = "4.1.0"
val okio = "2.0.0"
// </buildSrcVersions>

Copy/paste this snippet in versionsOnlyFile at whichever place makes sense for your build.

Use those versions like you already do.

dependencies {
    // <buildSrcVersions>
    // Generated by ./gradle buildSrcVersions
    // See https://github.com/jmfayard/buildSrcVersions/issues/55
    val okio = "2.0.0"
    val okhttp = "4.1.0" // available: "4.1.1"
    val org_jetbrains_kotlin = "1.3.50"
    // </buildSrcVersions>

    implementation(kotlin("stdlib-jdk8", org_jetbrains_kotlin))
    implementation("com.squareup.okhttp3:okhttp:$okhttp")
    implementation("com.squareup.okio:okio:$okio")
}

Dependency updates

Next time you want to search for dependencies updates, run again

./gradle buildSrcVersions,

The plugin will regenerate the block <buildSrcVersions>....</buildSrcVersions> inside buildFile

It's the same approach that works well for the default mode of the plugin: a comment inform you about the update. You can update the build:

(Press Delete to update.)

Context and Motivation

Simple things should be easy, complex things should be possible
-- Larry Wall

The basic idea of the Gradle buildSrcVersions plugin has been until now to generate two files, Libs.kt and Versions.kt inside the buildSrc

I'm coming from an android background where the build is by default multi-modules and where the Android Gradle Plugin in particular is very complex. In this context, the buildSrc is an elegant and powerful tool to maintain developer sanity. It solves the complex things should be possible part.

As I have migrated to the backend though, I now have much simpler, single-module Gradle builds. Sure, I can still extract my dependencies to buildSrc, but why, you may ask, is it useful to extract there my dependencies used exactly oncer?

The correct answer: It is useless. I only need the Versions

The versionsOnlyMode is the attempt to get right the part: Simple things should be easy part

@jmfayard jmfayard self-assigned this Aug 26, 2019
jmfayard pushed a commit that referenced this issue Aug 26, 2019
@jmfayard jmfayard changed the title versionsOnlyMode versionsOnlyMode for single-module Gradle projects Aug 27, 2019
jmfayard pushed a commit that referenced this issue Sep 3, 2019
jmfayard pushed a commit that referenced this issue Sep 3, 2019
jmfayard pushed a commit that referenced this issue Sep 3, 2019
jmfayard pushed a commit that referenced this issue Sep 3, 2019
jmfayard pushed a commit that referenced this issue Sep 4, 2019
jmfayard pushed a commit that referenced this issue Sep 5, 2019
versionsOnlyMode #55
@jmfayard jmfayard added this to the 0.5.0 milestone Sep 11, 2019
This was referenced Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant