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

unable to satisfy dependency from com.lmax.disruptor 3.2.0 to package sun.misc 0.0.0(无法满足从 com.lmax.disruptor 3.2.0 到包 sun.misc 0.0.0 的依赖关系)

本文介绍了无法满足从 com.lmax.disruptor 3.2.0 到包 sun.misc 0.0.0 的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am developing an eclipse plugin which needs an com.lmax.disruptor.It imports sun.misc. I have this in my p2 repository but when I maven build my plugin I am getting this error "unable to satisfy dependency from com.lmax.disruptor 3.2.0 to package sun.misc 0.0.0."

我浏览了网站 解决对包的依赖sun.misc with Tycho 他们说要创建一个插件片段,但是当我尝试创建它并将导出页面添加为 sun.misc 时,它会抛出一个错误,例如插件中不存在 package sun.misc".

I have gone through the sites Resolve a dependency on package sun.misc with Tycho they are saying to create a plugin fragment but when I tried to create it and added export page as sun.misc, It is throwing an error like "package sun.misc doesnot exsist in the plugin".

如何解决这个问题,请帮我解决这个问题.?除了创建新的插件片段,有什么方法可以添加到我的插件本身吗?

How can solve this issue please help me with this.? Instead of creating new plugin fragment,is there is any possible way i can add in my plugin itself ?

谢谢,

推荐答案

如问题中oberlies' answer中所述您链接到,您需要构建一个系统捆绑片段,它公开,即导出,sun.misc 包.我不知道还有什么办法.但是,这比预期的要容易.

As mentioned in oberlies' answer in the question you link to, you need to build a system bundle fragment, which exposes, i.e., exports, the sun.misc package. I don't know of any other way. However, this is easier than could be expected.

您可以通过创建一个导出 sun.misc 的 OSGi MANIFEST.MF 来做到这一点,然后将其捆绑到一个片段中.这是通过 Maven 完成的,如下所示.

You do this by creating an OSGi MANIFEST.MF that exports sun.misc, and then bundle it into a fragment. This is done via Maven as follows.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
      <groupId>your.group</groupId>
      <version>1.0.0</version>

    <artifactId>your.group.fragment.sun.misc</artifactId>
    <packaging>jar</packaging>
    <name>System Bundle Fragment exporting sun.misc</name>

    <description>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.</description>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <forceCreation>true</forceCreation>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <manifestEntries>
                            <Export-Package>sun.misc</Export-Package>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.5.4</version>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <Bundle-Category>your.group</Bundle-Category>
                        <Fragment-Host>system.bundle; extension:=framework</Fragment-Host>
                    </instructions>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

在这个 POM 上运行 mvn clean install.现在您需要为 Tycho 提供可消耗的片段,也就是说,您需要通过 p2 软件站点使其可用.

Run mvn clean install on this POM. Now you need to make the fragment consumable for Tycho, i.e., you need to make it available via a p2 Software Site.

谢天谢地,有一个很棒的 Maven 插件可以帮助解决这个问题:reficio 的 p2-maven-plugin.您可以使用它基本上将任何 mavenized JAR 包装到 OSGi 包中,然后通过 p2 站点提供它.

Thankfully there is a great Maven plugin which can help with that: reficio's p2-maven-plugin. You can use it to basically wrap any mavenized JAR into an OSGi bundle and then provide it via a p2 site.

如下设置各自的POM.

Set up the respective POM as follows.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>sun-misc-p2</groupId>
  <artifactId>site</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>

  <build>
            <plugins>
                <plugin>
                    <groupId>org.reficio</groupId>
                    <artifactId>p2-maven-plugin</artifactId>
                    <version>1.1.1</version>
                    <executions>
                        <execution>
                            <id>default-cli</id>
                            <configuration>
                                <artifacts>
                                    <!-- specify your depencies here -->
                                    <!-- groupId:artifactId:version -->
                                    <artifact><id>com.lmax:disruptor:3.3.2</id></artifact>
                                    <artifact><id>your.group:your.group.fragment.sun.misc:1.0.0</id></artifact>
                                </artifacts>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>8.1.5.v20120716</version>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
                        <webApp>
                            <contextPath>/site</contextPath>
                        </webApp>
                   </configuration>
                </plugin>
            </plugins>
        </build>
        <pluginRepositories>
            <pluginRepository>
                <id>reficio</id>
                <url>http://repo.reficio.org/maven/</url>
            </pluginRepository>
        </pluginRepositories> 
</project>

注意,我使用这个插件来提供 LMAX Disruptor(3.3.2 版,在撰写本文时的最新版本,谢天谢地可以从 Maven Central 获得).

Note that I use this plugin to provide the LMAX Disruptor (version 3.3.2, the latest one at the time of writing, is thankfully available from Maven Central).

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

Run mvn p2:site on the POM. This will create a p2 site containing the sun.misc fragment at {project-folder}/target/repository.

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

This p2 repository - and with it the sun.misc fragment - can now be added to your target platform, and hence used in your Tycho build.

这应该可以解决它,并且-如果[您]可以通过任何可能的方式添加[您的]插件本身"来回答您的问题-这是唯一可行的方法(我知道).

This should fix it, and - to answer your question if "there is any possible way [you] can add in [your] plugin itself" - this is the only possible way to do it (I know of).

源代码也可在 https://github.com/newcodeontheblock/eclipse-rcp-with-async-logging.this - my- 关于在 Eclipse RCP 中使用异步 Log4j 2 记录器的博文.

这篇关于无法满足从 com.lmax.disruptor 3.2.0 到包 sun.misc 0.0.0 的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:无法满足从 com.lmax.disruptor 3.2.0 到包 sun.misc 0.0.0 的依赖关系

基础教程推荐