microsoft / vscode-maven

VSCode extension "Maven for Java"
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
Other
179 stars 88 forks source link

${env.JAVA_HOME} in systemPath cannot be recognized by this plugin #1001

Closed fwhdzh closed 8 months ago

fwhdzh commented 10 months ago

Describe the bug In my pom.xml, I add a dependcy of the tools.jar in jdk

<dependency>
      <groupId>jdk.tools</groupId>
      <artifactId>jdk.tools</artifactId>
      <version>1.8</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>

A wave line appears under this dependency. When we move our mouse on it, it will show "Project build error: 'dependencies.dependency.systemPath' for jdk.tools:jdk.tools:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/tools.jar".

However, this dependency is correct. If I use mvn install directly in bash terminal, maven will successfully complier the project and install it to local repository. If I set maven.executable.path, the mvn install can also work in the terminal in VScode. In another word, I think it is just a misinformation in the panel.

To Reproduce Steps to reproduce the behavior:

  1. Download and unzip a jdk whose version is 1.8.
  2. Set correctly JAVA_HOME environment variable as the directory of jdk installation. Ensure $JAVA_HOME/lib/tools.jar exists.
  3. Create a new maven project.
  4. Add dependency mentioned above.

Expected behavior There should be no error shown in VSCode Panel.

Environments (please complete the following information as much as possible):

Screenshots

image

The wave line shows there is an error.

image

The detailed error information.

image

If we run mvn install command in bash terminal, everything is ok.

image

Terminal built-in VSCode also works well to handle this dependency.

testforstephen commented 8 months ago

This error comes from RedHat Java language support extension. It duplicates with https://github.com/redhat-developer/vscode-java/issues/1551

Winson-Huang commented 6 months ago

I find a wired situation, when using {env.JAVA_HOME} in systemPath, now there is no error wave line, but when using {java.home} it still exists. I find it in Linux with OpenJDK 8.