【问题标题】:How to make maven bundlor to use my MANIFEST.MF instead of using a template and types detection?如何让 maven bundlor 使用我的 MANIFEST.MF 而不是使用模板和类型检测?
【发布时间】:2012-12-28 06:34:24
【问题描述】:

我正在使用 Virgo 开发一个 OSGi 应用程序,并使用 maven bundlor 构建捆绑包。我想使用 Virgo 使用的 MANIFEST.MF,其中包括包导入和一些包导入,但 bundlor 自动检测我的包使用的类并为它们生成包导入,包括来自 Import-Bundle 标头中的包的包。

有没有办法告诉 bundlor 只使用我已经构建的 MANIFEST.MF 或禁用 java 类型自动检测?

【问题讨论】:

    标签: maven osgi bundlor


    【解决方案1】:

    那么,就不要使用 bundlor 了吗?正如文档中所说,“Bundlor 的主要功能是扫描现有的 JAR 文件并确定其运行时依赖关系。”,

    例如,使用 maven-bundle-plugin(在本例中,我有一个 .war 文件,但这不重要)

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <archive>
              <!-- add the generated manifest to the war -->
              <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
            </archive>
            <failOnMissingWebXml>true</failOnMissingWebXml>
            <packagingExcludes>WEB-INF/web.xml</packagingExcludes>  
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
            <supportedProjectTypes>
              <supportedProjectType>jar</supportedProjectType>
              <supportedProjectType>bundle</supportedProjectType>
              <supportedProjectType>war</supportedProjectType>
            </supportedProjectTypes>
            <instructions>
                <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>
                <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
                <Embed-Directory>WEB-INF/lib</Embed-Directory>
                <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                <Embed-Transitive>true</Embed-Transitive>
                <Import-Package>
                  javax.annotation,
                  javax.servlet;version="[2.5,3.0]",
                  javax.servlet.http;version="[2.5,3.0]",
                  org.osgi.service.http,
                  org.osgi.service.packageadmin,
                  org.osgi.framework;version="[1.5,2.0)",
                  org.jboss.logging;version="[3.0,4.0)"
                </Import-Package>
                <Private-Package>fi.eis.applications</Private-Package>
                <Web-ContextPath>/spring-app</Web-ContextPath>  
            </instructions>
        </configuration>
    </plugin>
    

    我也可以不定义 maven-bundle-plugin,只在 WEB-INF 中放置一个清单文件。

    【讨论】:

    • 是的,你是对的,我实际上不需要 bundlor,很困惑,忘记了我只需要用我的 MENIFEST.MF 构建一个 jar 的事实,所以只需要 maven jar 插件就足够了。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 2016-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多