khalilou88 / jnxplus

Nx plugins that adds Java/Kotlin monorepo support to Nx workspace using Gradle and Maven
MIT License
65 stars 16 forks source link

Affected detection for version variables and gradle catalog #1359

Open MrSinisterX opened 1 month ago

MrSinisterX commented 1 month ago

I believe it would be nice to support detecting affected modules based on version variables changes.

For instance if you have in your root build.gradle variables for the versions:

ext {
   spring_boot_version = "3.3.4"
}

And then you use this variables across the modules, if you change the version in the variable, then currently modules that depend on it won't be seen as affected, even though they actually are.

The same applies if you are using the gradle catalog https://docs.gradle.org/current/userguide/platforms.html

khalilou88 commented 1 month ago

Hi @MrSinisterX, Is your issue the same as https://github.com/khalilou88/jnxplus/issues/1020?

MrSinisterX commented 1 month ago

Hi @khalilou88 It is related to #1020 but in your example in the comment:

I tried to reproduce the issue with https://github.com/khalilou88/jnxplus-examples and everything works fine:

  • clone repo
  • run npm i
  • run nx run-many --target=build
  • run nx graph --affected: No project should be marked as affected
  • update {workspaceRoot}/nx-gradle/gradle/libs.versions.toml by adding a new variable for example
  • run nx graph --affected again: All gradle projects should be marked as affected

This is slightly different from what I meant. In your case it marks as affected all the the gradle projects, however, it should only mark as affected the projects that are actually affected. Meaning that for instance if I change the micronaut version, only the projects that use that dependency should be marked as affected and not all the gradle projects.

Same if you add a new variable, only the projects that use it should be marked as affected.

In the particular case of the jnxplus-examples, you are using all of them in the root build.gradle, but in my case, we have multiple gradle projects in the same repo, and a common catalog, but not all projects use all the variables in the catalog. So when we change a version, we would like to see as affected only the projects that use the variable that we changed. In our case, marking as affected works, but it marks everything as affected, even though they are not using the variable that we changed.