无法满足从com.lmax.disruptor 3.2.0到sun.misc 0.0.0的依赖性

我正在开发一个需要com.lmax.disruptor的eclipse插件。它导入了sun.misc。 我在我的p2存储库中有这个,但是当我maven构建我的插件时,我收到此错误“无法满足com.lmax.disruptor 3.2.0对sun.misc 0.0.0包的依赖性。”

我已经浏览了网站Resolve对sun.misc包的依赖关系,他们正在创建一个插件片段,但是当我试图创建它并添加导出页面为sun.misc时,它会抛出像“sun sun”这样的错误。 misc不会在插件中存在“。

如何解决这个问题请帮我解决这个问题。 而不是创建新的插件片段,是否有任何可能的方式我可以添加我的插件本身?

谢谢,

正如oberlies在您链接的问题中的回答中所提到的,您需要构建一个系统包片段 ,该片段公开(即导出) sun.misc包。 我不知道其他任何方式。 但是,这比预期的要容易。

您可以通过创建导出sun.misc的OSGi MANIFEST.MF来执行此操作,然后将其捆绑到片段中。 这是通过Maven完成的,如下所示。

  4.0.0 your.group 1.0.0 your.group.fragment.sun.misc jar System Bundle Fragment exporting sun.misc This bundle extends the System Bundle export list with the sun.misc package such that OSGi bundles may refer to Sun's misc implementation without the OSGi framework itself to provide it in a non-portable way.    maven-jar-plugin  true  ${project.build.outputDirectory}/META-INF/MANIFEST.MF  sun.misc      org.apache.felix maven-bundle-plugin 2.5.4   bundle-manifest process-classes  manifest      your.group system.bundle; extension:=framework       

在此POM上运行mvn clean install 。 现在您需要为Tycho制作片段,即需要通过p2软件站点提供。

值得庆幸的是,有一个很棒的Maven插件可以提供帮助: reficio的p2-maven-plugin 。 您可以使用它基本上将任何mavenized JAR包装到OSGi包中,然后通过p2站点提供它。

按如下方式设置相应的POM。

  4.0.0 sun-misc-p2 site 1.0.0 pom    org.reficio p2-maven-plugin 1.1.1   default-cli     com.lmax:disruptor:3.3.2 your.group:your.group.fragment.sun.misc:1.0.0       org.mortbay.jetty jetty-maven-plugin 8.1.5.v20120716  10 ${basedir}/target/repository/  /site        reficio http://repo.reficio.org/maven/    

请注意 ,我使用此插件提供LMAX Disruptor(版本3.3.2,编写本文时的最新版本,谢天谢地,可以从Maven Central获得)。

在POM上运行mvn p2:site 。 这将在{project-folder}/target/repository创建一个包含sun.misc片段的p2站点。

这个p2存储库 – 以及sun.misc片段 – 现在可以添加到您的目标平台,因此可以在您的Tycho构建中使用。

这应该解决它,并且 – 回答你的问题,如果“[你]可以添加[你的]插件本身” – 这是唯一可行的方法(我知道)。

这些来源也可以在https://github.com/newcodeontheblock/eclipse-rcp-with-async-logging获得 。 在我的博客文章中还详细描述了整个过程, 该文章介绍了如何在Eclipse RCP中使用异步Log4j 2记录器 。