【问题标题】:Maven bundle plugin suddently generates Manifest with wrong versionsMaven bundle插件突然生成错误版本的Manifest
【发布时间】:2022-05-11 02:58:32
【问题描述】:

在将 maven 项目构建为 OSGI 包时,我在 MANIFEST 的导入包中获得了一些依赖错误版本范围。 这发生在内部依赖上,我突然说,因为这是多年来的工作,而问题发生在今天。

该项目的 pom 看起来像:

<?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/xsd/maven-4.0.0.xsd\">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.xxxxxx.yyyy</groupId>
        <artifactId>yyyy-features</artifactId>
        <version>9.0.0-SNAPSHOT</version>
    </parent>

    <groupId>com.xxxxxx.yyyy</groupId>
    <artifactId>com.xxxxxx.yyyy.command</artifactId>
    <packaging>bundle</packaging>

    <name>${project.artifactId}</name>

    <dependencies>

    [...]

        <dependency>
            <groupId>com.xxxxxx.yyyy.m2m</groupId>
            <artifactId>com.xxxxxx.yyyy.m2m.config</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxxx.yyyy.importexport</groupId>
            <artifactId>com.xxxxxx.yyyy.importexport.api</artifactId>
            <version>${project.version}</version>
        </dependency>

    [...]

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.xxxxxx.yyyy.command.*</Export-Package>
                        <Karaf-Commands>*</Karaf-Commands>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

清单看起来像:

Manifest-Version: 1.0
Bnd-LastModified: 1652108014425
Build-Jdk: 11.0.11
Built-By: wwhite
Bundle-Blueprint: OSGI-INF/blueprint/blueprint.xml
Bundle-Description: YYYYYYYYY yyyy
Bundle-DocURL: https://www.xxxxxx.com/
Bundle-ManifestVersion: 2
Bundle-Name: com.xxxxxx.yyyy.command
Bundle-SymbolicName: com.xxxxxx.yyyy.command
Bundle-Vendor: YYYYYY yyyy YYYYYY
Bundle-Version: 9.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.xxxxxx.yyyy.command;uses:=\"com.xxxxxx.yyyy.commo
 n,com.xxxxxx.yyyy.connector.spi,com.xxxxxx.yyyy.model.core
 
 [...]
 
Import-Package: com.xxxxxx.yyyy.importexport.api;version=\"[9.0,10)\",
com.xxxxxx.yyyy.importexport.api.model;version=\"[9.0,10)\",com.xxxxxx.yyyy.m2m
 ;version=\"[8.1,9)\",com.xxxxxx.yyyy.m2m.bean;version=\"[8.1,9)\",com.so
 prahr.edsn.m2m.config;version=\"[8.1,9)\",com.xxxxxx.yyyy.m2m.config.b
 ean;version=\"[8.1,9)\",com.xxxxxx.yyyy.m2m.utils;version=\"[8.1,9)\"
 
 [...]
 
Service-Component: OSGI-INF/com.xxxxxx.yyyy.command.m2m.resync.Resync
 ServiceImpl.xml
Specification-Title: com.xxxxxx.yyyy.command
Specification-Vendor: XXXXXXXXXX
Specification-Version: 9.0.0-SNAPSHOT
Tool: Bnd-4.2.0.201903051501


当前的项目版本是 9.0.0-SNAPSHOT 所以我希望 [9.0, 10) 版本范围适用于项目版本的所有依赖项,但由于一个模糊的原因,我得到 [8.1,9) 包 com.xxxxxx.yyyy.m2m.*

我为项目 com.xxxxxx.yyyy.m2m.config 构建了一个 denpency 树(mvn dependency:tree),但获得了良好的依赖版本 9.0.0-SNAPSHOT。

我尝试了许多其他的东西,无论是否使用 Netbeans 构建,构建前清洁,清洁我所有的 .m2/com/xxxxxx/yyyy

我正在努力寻找错误范围版本的原因,所以如果您对我有任何想法,谢谢!

祝你有美好的一天。

    标签: maven version osgi manifest


    【解决方案1】:

    我通过在本地(即在我的计算机上)在依赖于它们的项目之前构建具有错误版本的 maven 项目解决了这个问题。

    但无法理解其中的逻辑。上述项目是在所需版本 (9.0.0-SNAPSHOT) 的远程 maven repo (Nexus) 上构建的。即使不是为什么选择 [8.1-9.0) 范围版本? (8.1 是遥控器上最后一个版本的版本)。

    【讨论】:

      猜你喜欢
      • 2017-04-27
      • 2017-10-04
      • 1970-01-01
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-20
      • 1970-01-01
      相关资源
      最近更新 更多