littlerobots / version-catalog-update-plugin

Gradle plugin for updating a project version catalog
Apache License 2.0
565 stars 23 forks source link

runtimeOnly dependencies are removed from toml file #42

Closed BigMichi1 closed 2 years ago

BigMichi1 commented 2 years ago

hi, we have in our project some runtime dependencies defined like

dependencies {
    implementation libs.openfeign.error.decoder
    runtimeOnly libs.openfeign.micrometer
}

and in libs.versions.toml the following

[versions]
spring-cloud = "2021.0.3"

[libraries]
spring-cloud-dependencies = { module = "org.springframework.cloud:spring-cloud-dependencies", version.ref = "spring-cloud" }
openfeign-error-decoder = { module = "io.github.openfeign:feign-annotation-error-decoder" }
openfeign-micrometer = { module = "io.github.openfeign:feign-micrometer" }

additionally, we are using the platform plugin to import the openfeign bom to manage the versions so build.gradle for the platform project contains

plugins {
    id 'java-platform'
}

javaPlatform {
    allowDependencies()
}

dependencies {
    api platform(libs.spring.cloud.dependencies)
}

when now running the update task the openfeign-micrometer gets removed but the openfeign-error-decoder stays in the libs.versions.toml file and the build breaks because the runtimeOnly dependency declaration is invalid

hvisser commented 2 years ago

When using a platform you probably have to enable constraints on the versions plugin, did you enable this?

If a dependency is removed, that usually means it's not reported (anymore) by the versions plugin. I'm not sure if that's also the case for runtimeOnly, but you can check report.json generated by the versions plugin to verify if it's in there or not. I'm happy to investigate as well if you have a minimal project that reproduces this.

BigMichi1 commented 2 years ago

still trying to reproduce it, but looks like after using the plugin in multiple projects only one is affected by this "issue" so i assume something is wrong with the project itself. will report back if i find a reproducer