apache / apache/maven-compiler-plugin

[Regression] testCompile goal tries to read target/classes instead of target/test-classes

Open
#1,124 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Java
Stars
261
Forks
191
Avg merge
1d 5h
Merged PRs (30d)
8

Description

### Affected version

3.16.0

### Bug description

Starting with 3.16.0, there is a warning printed that suggests wrong target/ directory is being read. This is especially true when there are no classes being compiled from `src/main/java` and the module contains just tests.

Reproducer: https://github.com/lprimak/maven-test-compiler-reproducer

Error message:
```
[INFO] --- compiler:3.16.0:testCompile (default-testCompile) @ maven-testng-reproducer ---
[WARNING] I/O error reading dependency state: /Users/lprimak/Downloads/maven-testng-reproducer/target/classes: /Users/lprimak/Downloads/maven-testng-reproducer/target/classes
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 3 source files with javac [debug release 21] to target/test-classes
```

The issue is reproducible via maven 3.9.16 and 4-rc-6

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked maven-test-compiler-reproducer and reproduce the warning using Maven 3.9.16 or 4-rc-6 with compiler plugin 3.16.0, especially in a module containing only tests. Trace the testCompile goal's dependency-state path and verify that it reads target/test-classes rather than target/classes; done means the warning is gone and test sources compile successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.