autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Class parameter in annotation detected as api-dependency

Open
#1,533 3 comments 1 reaction 0 assignees View on GitHub
bug help wanted toolchain:java
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**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:
```java
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](https://github.com/user-attachments/files/21995334/repro-annotation.zip)

**Expected behavior**
It should only be an implementation-dependency.

Contributor guide

Open the contributing guide

Research direction

Start with the attached repro annotation.zip and run ./gradlew buildHealth, then inspect ./gradlew :module1:reason --id :module2. Trace why the class parameter in @Import(Module2Config.class) is treated as an exposed class. Done means the dependency remains implementation rather than being advised as api.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.