Maven 找不到某些依赖项的组件

Maven can't find some dependencies' components

我正在为 Intellij IDEA 制作一个插件。我尝试使用 Maven 构建和编译我的项目,但在使用 com.intellij 开源时遇到了一些问题。这是我的 pom.xml 依赖项:

     <properties>
        <java.version>1.7</java.version>
        <org.apache.maven.plugins.compiler.version>3.5</org.apache.maven.plugins.compiler.version>
        <intellij.openapi.version>7.0.3</intellij.openapi.version>
        <intellij.annotations.version>12.0</intellij.annotations.version>
        <intellij.forms_rt.version>7.0.3</intellij.forms_rt.version>
        <intellij.openapi.version>7.0.3</intellij.openapi.version>
        <intellij.extensions.version>7.0.3</intellij.extensions.version>
        <intellij.java2c.version>7.0.3</intellij.java2c.version>
    </properties>
    </dependencies>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>openapi</artifactId>
            <version>${intellij.openapi.version}</version>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>annotations</artifactId>
            <version>${intellij.annotations.version}</version>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>forms_rt</artifactId>
            <version>${intellij.forms_rt.version}</version>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>extensions</artifactId>
            <version>${intellij.extensions.version}</version>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>javac2</artifactId>
            <version>${intellij.java2c.version}</version>
        </dependency>
    </dependencies>

这是我在尝试编译或构建项目时得到的结果:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[6,40] package com.intellij.openapi.editor.impl does not exist
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[11,31] cannot find symbol
  symbol:   class ToolWindowFactory
  location: package com.intellij.openapi.wm
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[13,34] cannot find symbol
  symbol:   class JBList
  location: package com.intellij.ui.components
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[34,50] cannot find symbol
  symbol: class ToolWindowFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[42,13] cannot find symbol
  symbol:   class JBList
  location: class com.company.ap.gigaspaces.plugin.PrimaryToolWindowFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[362,13] cannot find symbol
  symbol:   class EditorHeaderComponent
  location: class com.company.ap.gigaspaces.plugin.PrimaryToolWindowFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[79,55] cannot find symbol
  symbol:   variable SERVICE
  location: interface com.intellij.ui.content.ContentFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[58,5] method does not override or implement a method from a supertype
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[263,9] cannot find symbol
  symbol:   class EditorHeaderComponent
  location: class com.company.ap.gigaspaces.plugin.PrimaryToolWindowFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[363,9] cannot find symbol
  symbol:   class EditorHeaderComponent
  location: class com.company.ap.gigaspaces.plugin.PrimaryToolWindowFactory
[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[363,44] cannot find symbol
  symbol:   class EditorHeaderComponent
  location: class com.company.ap.gigaspaces.plugin.PrimaryToolWindowFactory

更新:我又添加了两个依赖项,现在只剩下 1 个错误,我无法解决。

    <dependency>
        <groupId>com.github.adedayo.intellij.sdk</groupId>
        <artifactId>platform-impl</artifactId>
        <version>142.1</version>
    </dependency>
    <dependency>
        <groupId>com.github.adedayo.intellij.sdk</groupId>
        <artifactId>platform-api</artifactId>
        <version>142.1</version>
    </dependency>

出现以下错误:

[ERROR] /home/student/Dev/gs-idea-plugin/main/java/com/company/ap/gigaspaces/plugin/PrimaryToolWindowFactory.java:[79,55] cannot find symbol
[ERROR] symbol:   variable SERVICE
[ERROR] location: interface com.intellij.ui.content.ContentFactory

我打开接口的location,没有这个变量,但是class只用一个静态方法调用了SERVICE。会不会是 maven 生病了并试图找到 class 的变量?

日志表明 Maven 设法解决了您的依赖项(否则,它甚至不会调用编译器)。

您需要修复您的 java 类,因为它们存在编译问题(所有导入都包含在您的 类 中吗?)。

所以我通过在本地创建依赖项解决了这个问题。 Maven Central 所需的 intellij 库版本太旧,所以我找到了脚本,它将 IntelliJ IDEA 的 lib/ 文件夹中的所有文件安装到本地 maven .m2 存储库。我从这里复制:github 然后创建 pom.xml 文件,就像在这个存储库中一样,并从我机器上的 idea 版本导入依赖项。