IntelliJ IDEA 未对 GraalVM 库进行索引。

huangapple go评论133阅读模式
英文:

IntelliJ IDEA not indexing GraalVM libraries

问题

我对GraalVM这个东西还有点新,所以请帮助我一下。我在使用IntelliJ IDEA作为我的集成开发环境,以及Gradle作为标准构建系统。我正在使用内置的GraalVM JDK(它基于Java 11)来进行所有项目的开发。所以,我的问题是,当我尝试导入org.graalvm.polyglot或类似的包时,它会在导入下面划出一个波浪线,这表示IntelliJ IDEA无法识别这个包并对其进行索引。但是当我使用Gradle或任何方法运行它时,导入的包是有效的。IDE的自动完成功能无法使用。就像在记事本中编程时一样,逐字输入整个类和方法的名称有点烦人。我看过一些关于这方面的教程,建议我将graal-sdk.jar作为依赖项添加,但是在Java 11版本的GraalVM中找不到这个jar文件。我甚至将整个lib文件夹添加到了IntelliJ的Project StructureLibraries部分中。所有这些方法都没有奏效。有谁能帮我解决一下这个问题吗?

英文:

I'm kinda new to this GraalVM stuff so please help me. I am using IntelliJ IDEA as my IDE and Gradle as my standard build system. I'm using the inbuilt GraalVM JDK (it's based on Java 11) for all of my projects. So, my problem is when I try to import the org.graalvm.polyglot or any such package it draws a squiggly line under the import which signifies that IntelliJ IDEA doesn't recognize the package and hasn't indexed it. But when I run it with gradle or any method, the imported packages work. The IDE's autocomplete doesn't work. It is kinda irritating to type out the whole name of the class and method just like one would while programming in Notepad. I have seen some tutorials for this which suggested that I add the graal-sdk.jar as a dependency but the jar file wasn't to be found in the Java 11 version of GraalVM. I even added the whole lib folder to IntelliJ's Libraries section in Project Structure. All of these did not work out. Could anybody help me out with this?

答案1

得分: 2

一种让IDEA识别graal-sdk.jar类的方法是通过构建工具将其添加到依赖项中。该jar文件可在Maven Central上获得:https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk/20.2.0

因此,通过在Maven中使用范围为provided的依赖项将其添加到依赖项中,将使IDEA对其进行索引并提供内容辅助等功能,但不会被使用或打包,因为它是提供的。

对于Gradle,我认为可以使用compileOnly

编辑:
为了完整起见,在JDK11上,事物被打包在jmod文件中:https://docs.oracle.com/javase/9/tools/jmod.htm#JSWOR-GUID-0A0BDFF6-BE34-461B-86EF-AAC9A555E2AE

也许你可以说服IDE查看它们。我认为它们位于$GRAALVM_HOME/jmods/org.graalvm.sdk.jmod

英文:

One way to make IDEA recognise the graal-sdk.jar classes is to add it to your dependencies via the build tool. The jar is available on Maven Central: https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk/20.2.0

so adding it to the dependencies with Maven scope: provided will make IDEA to index it and provide content assist, etc. but it won't be used or packaged, cause it's provided.

For Gradle I think it's the compileOnly.

Edit:
For completeness, on JDK11 things are packaged in jmod files: https://docs.oracle.com/javase/9/tools/jmod.htm#JSWOR-GUID-0A0BDFF6-BE34-461B-86EF-AAC9A555E2AE

And maybe you can convince IDE to look at them. I think it's the $GRAALVM_HOME/jmods/org.graalvm.sdk.jmod

huangapple
  • 本文由 发表于 2020年10月17日 14:27:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/64399624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定