如何为SonarLint eclipse

时间:2016-08-02 23:20:51

标签: eclipse eclipse-plugin sonarlint sonarlint-eclipse

我在Eclipse Luna中加载SonarLint 2.2.0时遇到问题。官方网站文档称Eclipse Luna支持2.2.0版本。我也可以毫无问题地从Eclipse Marketplace安装SonarLint。但是在eclipse重启时,SonarLint无法加载。在诊断插件时,我发现有一些丢失的包,如下图所示。 enter image description here

从OSGI控制台检查捆绑包时,我有捆绑包,它处于ACTIVE状态,但版本不同,如下所示。 enter image description here

考虑到这一点,我不认为我应该将equinox降级到版本0.0.0,如果有的话。而且不确定我该如何处理它。任何帮助将不胜感激。

由于

3 个答案:

答案 0 :(得分:3)

SonarLint for Eclipse 2.2.0版已移至Java 8(以及SonarLint Core库)。因此,所有这些bundle的MANIFEST都被更新为需要JavaSE-1.8执行环境。

如果您的Eclipse安装无法提供此要求,则不会加载SonarLint插件。我同意这种无声的失败是一种耻辱,但如果你对如何改进有所了解,请告诉我。

Eclipse没有提供JavaSE-1.8的可能原因:

  • Eclipse是用Java< 8.确保只需打开帮助 - >关于Eclipse - >安装细节 - >配置并查找属性java.version。这里的解决方案很简单:使用JVM 1.8 +运行Eclipse。
  • 您使用的是非常旧的Eclipse版本(< Kepler SR1)。没有Java 1.8配置文件,因此即使您使用JVM 1.8也无法工作(请参阅https://bugs.eclipse.org/bugs/show_bug.cgi?id=387699)。 Luna应该受到支持,但是如果你从旧版本的Eclipse升级则可能会被破坏(参见How do I add execution environment 1.8 to Eclipse Luna?)。尝试全新安装Luna或更新版本。

答案 1 :(得分:1)

我看到了同样的问题并在OSGi控制台中运行了diag。 我发现SonarLint eclipse捆绑包引用了2.3.1版本的核心SonarLint捆绑包,而插件有效负载包括2.4.0版本的核心包。

例如:diag命令显示sonarlint.eclipse.core包引用了sonarlint-client-api_2.3.1,而插件有效负载包含sonarlint-client-api_2.4.0。

注意:我在OP提供的诊断窗口底部看到了相同的版本问题。

我认为需要使用正确的软件包版本重建/重新打包SonarLint 2.2软件包。

这是我的OSGi控制台输出供参考。

osgi> ss
...
1241    INSTALLED   org.sonarlint.eclipse.core_2.2.0.201607291419-RELEASE
1242    INSTALLED   org.sonarlint.eclipse.jdt_2.2.0.201607291419-RELEASE
1243    INSTALLED   org.sonarlint.eclipse.ui_2.2.0.201607291419-RELEASE
1244    INSTALLED   org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0
1245    INSTALLED   org.sonarsource.sonarlint.core.sonarlint-core_2.4.0


osgi> diag 1241
reference:file:plugins/org.sonarlint.eclipse.core_2.2.0.201607291419-RELEASE.jar [1241]
  Direct constraints which are unresolved:
    Missing required bundle org.sonarsource.sonarlint.core.sonarlint-client-api_2.3.1.
    Missing required bundle org.sonarsource.sonarlint.core.sonarlint-core_2.3.1.
    Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
  Leaf constraints in the dependency chain which are unresolved:
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-core_2.4.0.jar [1245]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.jar [1244]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".

osgi> diag 1242
reference:file:plugins/org.sonarlint.eclipse.jdt_2.2.0.201607291419-RELEASE.jar [1242]
  Direct constraints which are unresolved:
    Missing required bundle org.sonarlint.eclipse.core_0.0.0.
    Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
  Leaf constraints in the dependency chain which are unresolved:
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-core_2.4.0.jar [1245]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.jar [1244]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
    reference:file:plugins/org.sonarlint.eclipse.core_2.2.0.201607291419-RELEASE.jar [1241]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".

osgi> diag 1243
reference:file:plugins/org.sonarlint.eclipse.ui_2.2.0.201607291419-RELEASE.jar [1243]
  Direct constraints which are unresolved:
    Missing required bundle org.sonarlint.eclipse.core_0.0.0.
    Missing imported package org.sonarsource.sonarlint.core.client.api.connected_0.0.0.
    Missing imported package org.sonarsource.sonarlint.core.client.api.util_0.0.0.
    Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
  Leaf constraints in the dependency chain which are unresolved:
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-core_2.4.0.jar [1245]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.jar [1244]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
    reference:file:plugins/org.sonarlint.eclipse.core_2.2.0.201607291419-RELEASE.jar [1241]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".

osgi> diag 1244
reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.jar [1244]
  Direct constraints which are unresolved:
    Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".

osgi> diag 1245
reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-core_2.4.0.jar [1245]
  Direct constraints which are unresolved:
    Missing required bundle org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.
    Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
  Leaf constraints in the dependency chain which are unresolved:
    reference:file:plugins/org.sonarsource.sonarlint.core.sonarlint-client-api_2.4.0.jar [1244]
      Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".

答案 2 :(得分:0)

您是否已将这些插件添加为Manifest中的“必需捆绑包”?