eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Can't build project with JDT as a dependency when using Java modules

Open
#2,780 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

When using the jdt.core library as a dependency (`org.eclipse.jdt:org.eclipse.jdt.core:3.38.0` from maven central) to a Java 21 Gradle project which also makes use of the Java module system, the compilation fails due to a number of packages being _provided_ multiple times by the library.

Excerpt of build output:

```log
Task :compileJava FAILED
1 actionable task: 1 executed

error: the unnamed module reads package org.eclipse.jdt.internal.compiler from both org.eclipse.jdt.core and org.eclipse.jdt.core.compiler.batch
error: the unnamed module reads package org.eclipse.jdt.internal.compiler.parser from both org.eclipse.jdt.core and org.eclipse.jdt.core.compiler.batch
error: the unnamed module reads package org.eclipse.jdt.core from both org.eclipse.jdt.core and org.eclipse.jdt.core.compiler.batch
error: the unnamed module reads package org.eclipse.jdt.core.compiler from both org.eclipse.jdt.core and org.eclipse.jdt.core.compiler.batch
error: the unnamed module reads package org.eclipse.core.runtime from both org.eclipse.equinox.common and org.eclipse.equinox.registry
error: the unnamed module reads package org.eclipse.core.runtime from both org.eclipse.equinox.common and org.eclipse.core.runtime
error: the unnamed module reads package org.eclipse.core.internal.runtime from both org.eclipse.equinox.common and org.eclipse.core.runtime
error: module org.eclipse.core.resources reads package org.eclipse.jdt.core from both org.eclipse.jdt.core.compiler.batch and org.eclipse.jdt.core
error: module org.eclipse.core.resources reads package org.eclipse.jdt.core.compiler from both org.eclipse.jdt.core.compiler.batch and org.eclipse.jdt.core
error: module org.eclipse.core.resources reads package org.eclipse.jdt.internal.compiler from both org.eclipse.jdt.core.compiler.batch and org.eclipse.jdt.core
...
```

Example of a `module-info.java` of the module that makes use of the jdt library:

```java
module example {
requires org.eclipse.jdt.core;
}
```

I have provided a repository which should help you reproduce and investigate the issue here: https://github.com/bvlj/eclipse_jdt_issue_module

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.