INRIA / INRIA/spoon

[Bug]: Duplicate classes when trying to compile in IntelliJ

Open
#6,419 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

### Describe the bug

If you use the `spoon-maven-plugin` in your project, it then seems that you can no longer compile the project in IntelliJ as you get errors about `java: duplicate class: MyClass` for every class that is processed by spoon.

I believe that this is because `src/main/java` contains a copy of the class (.java) file, and then also `target/generated-sources/spoon` contains another (processed) copy of the class (.java) file.

IntelliJ doesn't seem to understand that the original copy in `src/main/java` should be ignored, and there seems to be no easy way to configure this (e.g. remove `src/main/java` as a source root) without breaking many things.

NOTE - the build still works fine outside of IntelliJ when using `mvn` from the CLI; but IntelliJ is probably the most popular IDE, and we need to use it here.

Any ideas?

### Source code you are trying to analyze/transform

Example Maven plugin config from `pom.xml`:

```xml

fr.inria.gforge.spoon
spoon-maven-plugin
3.8.0


spoonify
generate-sources

generate


21
true

xyz.elemental.build.tools.spoon.processors.PermissionRequiredProcessor






fr.inria.gforge.spoon
spoon-core
11.2.1


xyz.elemental
exist-core-build-tools
${project.version}

```

### Spoon Version

spoon: 11.8.2
spoon-maven-plugin: 3.8.0
IntelliJ: 2025.2.1

### JVM Version

21

### What operating system are you using?

macOS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.