redhat-developer / redhat-developer/vscode-java

Cannot build 1.8 maven project with system scope dependency

Open
#1,551 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Maven
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

To run the latest vscode-java extension, i installed JDK to java.home, and configured JDK 1.8 as the build JRE for 1.8 project. But it cannot build my 1.8 project any more because my maven project uses tools.jar as system scope dependency.

user settings:

    "java.home": "C:\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
    "java.configuration.runtimes": [
        {
          "default": true,
          "name": "JavaSE-1.8",
          "path": "C:\\Java\\openjdk8u181-b13",
        }
    ]

pom.xml: (Since tools.jar is not required for JDK 9 and higher, i use a profile to filter whether to enable tools.jar dependency.)

<profiles>
    <profile>
        <id>default-tools.jar</id>
        <activation>
            <jdk>(,9)</jdk>
        </activation>
        <dependencies>
            <dependency>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
                <version>1.8</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
            </dependency>
        </dependencies>
    </profile>
</profiles>

The problem is when the extension imports pom.xml project, it uses the extension runtime (aka. Java 11) to resolve maven dependency, which will ignore tools.jar. But when building project, it uses the JDK 1.8 as the build JRE and fails to resolve tools.jar dependency. Currently i didn't find a good way to workaround this issue, unless update the compliance to 11.

This issue is already tracked in the upstream m2e Bug 432992 - java.home of the Eclipse JRE is used instead of the build JRE.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported java.home and java.configuration.runtimes settings and the pom.xml profile that declares tools.jar. Reproduce Maven project import and build with JDK 11 as the extension runtime and JDK 8 as the build JRE, then compare the behavior with upstream m2e Bug 432992. Done means the Java 8 project resolves tools.jar and builds without requiring compliance level 11.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.