dependency-analysis-gradle-plugin icon indicating copy to clipboard operation
dependency-analysis-gradle-plugin copied to clipboard

Class parameter in annotation detected as api-dependency

Open balrok opened this issue 4 months ago • 3 comments

Plugin version: 3.0.1 Gradle version: 9.0.0 JDK version: 21 Describe the bug After issue #1210 I was under the impression, that following code would add module2 only as implementation dependency:

package com.example.demo;

import com.example.module2.Module2Config;
import org.springframework.context.annotation.Import;

@Import(Module2Config.class)
public class Module1Config {
}

But fails with:

./gradlew buildHealth
  Existing dependencies which should be modified to be as indicated:
    api project(':module2') (was implementation)

With reason:

./gradlew :module1:reason --id :module2
Source: main
------------
* Exposes 1 class: com.example.module2.Module2Config (implies api).

To Reproduce I have a small example project to reproduce it: repro-annotation.zip

Expected behavior It should only be an implementation-dependency.

balrok avatar Aug 26 '25 20:08 balrok

@Vampire would you mind taking a look and reminding me of the expectation in this case?

autonomousapps avatar Aug 28 '25 22:08 autonomousapps

Import is runtime retention and Module2Config is from a different "jar", so this is like the JUnit 4 runner case as far as the annotations are concerned, so regarding the annotations I would agree that it should be implementation.

Not sure from the top of my head what the "Exposes 1 class" reason is, but I think it is something different from the annotations?

Vampire avatar Aug 28 '25 23:08 Vampire

Alright, thanks. I can take a look at the repro and get a better trace as to why it's saying that.

autonomousapps avatar Aug 29 '25 00:08 autonomousapps