kevcodez / gradle-upgrade-interactive

CLI to interactively upgrade gradle dependencies, inspired by yarn.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: support versions specified in separate file

arhohuttunen opened this issue · comments

Thanks for making something possible in Gradle that has been available for Maven for a long time :)

One possible improvement could be to provide support for versions that are defined in another file, such as gradle/dependencies.gradle.

The separate file is only part of the problem. Some like to define the dependency itself like:

ext {
    versions = [
        springBootVersion: '2.2.2.RELEASE',
    ]
    libs = [
        springBootStarterWeb: "org.springframework.boot:spring-boot-starter-web:${versions.springBootVersion}",
}

In such case the dependency would be referenced in build.gradle with something like implementation libs.springBootStarterWeb.

Quickly browsing through the code it seems that it's just reading the build file as a string and doing string replacements. Do you think it would be feasible to try to implement separate file support with the current approach?

Was able to solve this in the PR by providing the external file as an argument and then modifying the structure of the dependencies.gradle file a bit:

ext {
    springBootVersion = '2.2.2.RELEASE'

    libs = [
        springBootStarterWeb: "org.springframework.boot:spring-boot-starter-web:${springBootVersion}",
}

Now the string replacement is able to find the version and you should be able to have your dependencies in a separate file.

Version 0.4.0 has been released including your PR. I will close this issue for now.

Again, thank you very much for contributing :)

I will also refactor the code a bit, so multiple build files are supported (basically just iterating the logic over multiple files).

Released 0.4.1

  • Improved the handling of external build files so
    • Multiple files can be inspected
    • Build.gradle(.kts) will still be inspected, when an external file is given
    • Documented the parameter in the README

Awesome, thanks! Happy holidays!