redhat-developer / redhat-developer/vscode-java

Cannot build 1.8 maven project with system scope dependency

Offen
#1,551 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Maven
Vorherrschende Sprache
TypeScript
Sterne
2.3k
Forks
546
Ø Merge
20 Std. 1 Min.
Gemergte PRs (30 T.)
11

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
build-system, developer-experience
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.