Felix Bundle的进口错误很多 [英] Felix Bundle has lots of wrong imports

查看:95
本文介绍了Felix Bundle的进口错误很多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

felix-bundle插件让我很困惑.文档中提到了Import-Package标签

I am very confused by the felix-bundle plugin. The documentation says of the Import-Package tag

很少需要显式指定此标头.但是,在某些情况下,如果有不需要的导入,则可以使用否定包模式将其删除

This header rarely has to be explicitly specified. However, in certain cases when there is an unwanted import, such an import can be removed by using a negation package pattern

但是我正在构建一个插件,它似乎正在导入很多我不想要的东西. javax.servlet,junit.*和org.junit.*,org.testng以及一些Apache日志记录包也将加入.所有这些都使我的软件包在使用中因缺少需求错误而崩溃.

But I am building a plugin and it seems to be importing lots of things that I don't want. javax.servlet is going in, as are junit.* and org.junit.*, and org.testng, and some apache logging packages. All of these are making my package crash in use with a missing requirement error.

问题是,我不知道为什么首先要包含这些内容.很混乱.欢迎帮忙.

The thing is, I have no idea why these are getting included in the first place. Very confused. Help welcome.

为回答AFAIK,我在代码中的任何地方都没有使用javax.servlet.我的POM当前看起来像这样.我不得不排除很多会破坏负载的软件包.

In response to an answer, AFAIK, I am not using javax.servlet anywhere in my code. My POM currently looks like this. I've had to exclude lots of packages which are otherwise breaking the load.

结果真是一场噩梦!

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
      <groupId>org.sonatype.oss</groupId>
      <artifactId>oss-parent</artifactId>
      <version>7</version>
    </parent>



        <groupId>uk.org.russet</groupId>
    <artifactId>uk.org.russet.protege.nrepl-clojure</artifactId>
    <version>0.1.0-SNAPSHOT</version>
    <name>protege-nrepl</name> 
    <description>Provide an NREPL client to use Clojure inside Protege</description>

    <packaging>bundle</packaging>


    <dependencies>
          <dependency>
            <groupId>uk.org.russet</groupId>
            <artifactId>nrepl-clojure</artifactId>
            <version>1.0.0</version>
          </dependency>

      <!--dependency>
        <groupId>edu.stanford.protege</groupId>
        <artifactId>org.protege.common</artifactId>
        <version>5.0.0-beta-05-SNAPSHOT</version>
            <scope>provided</scope>
      </dependency-->

          <dependency>
        <groupId>edu.stanford.protege</groupId>
        <artifactId>org.protege.editor.core.application</artifactId>
        <version>5.0.0-beta-05-SNAPSHOT</version>
            <scope>provided</scope>
          </dependency>

          <dependency>
        <groupId>edu.stanford.protege</groupId>
            <artifactId>org.protege.editor.owl</artifactId>
        <version>5.0.0-beta-05-SNAPSHOT</version>
            <scope>provided</scope>
          </dependency>
    </dependencies>

    <build>
      <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.0</version>
              <configuration>
                <source>1.6</source>
                <target>1.6</target>
              </configuration>
            </plugin>
            <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>2.3.7</version>
          <extensions>true</extensions>
          <configuration>
        <instructions>
          <Bundle-ClassPath>.</Bundle-ClassPath>
          <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
          <Bundle-Vendor>The Protege Development Team</Bundle-Vendor>
          <Import-Package>
                    !javax.servlet*,!junit.*,!org.junit*,!org.apache.*,
                    !org.testng.*,!sun.misc.*,org.protege.editor.*,
                    org.protege.editor.core,org.protege.editor.core.ui.workspace,
                    org.protege.editor.owl.model,org.protege.editor.core.editorkit,
                    org.semanticweb.owlapi.model, *
          </Import-Package>
          <Include-Resource>plugin.xml, {maven-resources}</Include-Resource>
                  <Embed-Transitive>true</Embed-Transitive>
                  <Embed-Dependency>*;scope=compile</Embed-Dependency>
        </instructions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>install</phase>
            <goals>    
              <goal>manifest</goal>
            </goals>   
          </execution>
        </executions>
          </configuration>
            </plugin>
            <plugin>
              <artifactId>maven-eclipse-plugin</artifactId>
              <version>2.9</version>
              <configuration>
                <pde>true</pde>
              </configuration>
            </plugin>
        </plugins>
    </build>
</project>

推荐答案

添加了依赖性,因为捆绑软件中的某些代码使用了这些软件包.例如,如果您的任何代码使用javax.servlet,则该捆绑包将必须导入javax.servlet.因此,这种导入至少看起来是合理的.

The dependencies are added because some code inside your bundle uses those packages. For example if any of your code uses javax.servlet then the bundle will necessarily import javax.servlet. So this import at least seems reasonable.

当然,导入测试库似乎不太合理.这表明您的测试已与真实"类一起包含在包中,这是不应该发生的.您是否将测试与真实类保存在相同的源文件夹中?推荐的做法是在单独的源文件夹中编写测试代码.在Maven中通常是src/test/java.

The imports of testing libraries do not seem so reasonable, of course. It suggests that your tests have been included in your bundle alongside the "real" classes, which should not happen. Do you keep your tests in the same source folder as the real classes? It's normal and recommended practice to write test code in a separate source folder; in Maven this is usually src/test/java.

如果不是这种情况,则应显示已使用的配置.

If that's not the case then you should show the configuration you have used.

这篇关于Felix Bundle的进口错误很多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆