gradlex-org/java-module-dependencies

Deal with name clashes between project names and source set names

Opened this issue · 0 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.