java-module-dependencies icon indicating copy to clipboard operation
java-module-dependencies copied to clipboard

[Maybe] Deal with name clashes between project names and source set names

Open jjohannes opened this issue 2 years ago • 1 comments

Consider the following setup:

settings.gradle

include("module-a") // applies 'java-test-fixtures' plugin
include("module-a-test")
include("module-b")

module-info.java of module-b

module org.example.module.b {
  requires org.example.module.a.test.fixtures;
}

In such a scenario, org.example.module.a.test.fixtures can point at two things:

  1. project: module-a source set: test-fixtures
  2. project: module-a-test source set: fixtures

Currently, the plugin chooses (2) as the longer project name is considered the better match. In this scenario (1) would be the right choice, but that's only the case here. In theory (2) could be the right choice in other setups.

The way to tell for sure would be to test if the chosen project has an outgoing variant with the capability that corresponds to the source set, to determine if the source set actually exists (in the example, fixtures does not exist in module-a-test). This can maybe be done by doing a "small" detached dependency resolution.

If this is difficult to solve automatically, the plugin can give a warning, that two solutions exist and prompt the user to define an explicit mapping for the right solution.

jjohannes avatar Nov 28 '23 13:11 jjohannes

When using the "Settings Plugin Approach" the plugin no longer does guesswork on how module names and source sets relate. This issue does not longer appears. On the long run, we should promote that approach. Not sure if we still want to do something on this issue.

jjohannes avatar Feb 15 '25 13:02 jjohannes