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

version-catalog-update-plugin should also inspect dependencies in buildSrc #111

Open
SchlauFuchs opened this issue May 15, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@SchlauFuchs
Copy link

SchlauFuchs commented May 15, 2023

Please describe your feature request, and some context why this would be useful to you and others using the plugin.
Hi,

I have added library capability to my project buildSrc by adding this block to buildSrc/settings.gradle.kts

dependencyResolutionManagement {
    versionCatalogs {
        create("libs")  {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}

The project compiles well. But when I use the versionCatalogUpdate task, the records in libs/versions.toml are stripped away causing of course buildSrc to be no longer compilable.

Either the task needs to analyse/update the buildSrc dependencies, or we need to tell it to not delete unused rows.

@SchlauFuchs SchlauFuchs added the enhancement New feature or request label May 15, 2023
@hvisser
Copy link
Contributor

hvisser commented May 15, 2023

There's not much I can do here as the actual version resolving is done by the versions-plugin. There are some issues on that to report buildSrc dependencies, like ben-manes/gradle-versions-plugin#283 and ben-manes/gradle-versions-plugin#478. It looks like Gradle isn't making those dependencies visible to the versions plugin.

As a workaround you can set the keep option to true, so that missing dependencies are not removed from the toml file.

@matejdro
Copy link

matejdro commented Nov 10, 2023

What if an option is added to this plugin to declare extra versions plugin files? Something like this:

versionCatalogUpdate {
   readVersionsReport("../buildSrc/build/dependencyUpdates/versions.json")
}

Then, we could manually run dependency updates on the buildSrc + version catalog update like this:

./gradlew :buildSrc:dependencyUpdates versionCatalogUpdate

@hvisser
Copy link
Contributor

hvisser commented Nov 11, 2023

I think that would probably complicate things alot. Buildsrc is now implemented as an included build which means it can declare its own dependencies. This is (probably) also why the dependency versions plugin doesn't pick up the dependencies, it's a separate project. Different versions means potential conflicts that would need to be resolved.

I haven't tested if you can also apply the dependency versions plugin to the buildsrc Gradle file. For normal modules the dependency versions plugin will create an aggregated report, if it does the same for buildsrc then everything should just work. But it's probably not that simple :)

@matejdro
Copy link

Yes, you can apply dependency versions plugin to buildsrc. That's why I recommended this above, problem is only that this plugin will not collect dependency versions plugin's report from build src. My workaround would solve this.

@hvisser
Copy link
Contributor

hvisser commented Nov 11, 2023

I know you can do that since it's the same as any other project. I just haven't tested if running the plugin from the root project will create a report.json for all dependencies. If you are able to try, that would be great.

Like I said.I don't think merging two separate report files is practically possible as there are many edge cases, so it's not some I'm considering for that reason.

@matejdro
Copy link

If I remember correctly, it only creates report json for dependencies in buildSrc.

@matejdro
Copy link

Yup, just checked, versions.json inside buildSrc only contains dependencies from buildSrc. So they would have to be merged with the main project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants