You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven Bundle Plugin生成的OSGi Bundle Manifest中内部依赖版本范围异常排查求助

Troubleshooting Incorrect Import-Package Version Ranges in Maven Bundle Plugin

Let's break down why your Maven bundle plugin is generating unexpected version ranges for the com.xxxxxx.yyyy.m2m.* packages, even though your project and dependencies are on 9.0.0-SNAPSHOT. Here are the most likely causes and actionable steps to diagnose them:

1. Verify the actual Bundle-Version in your dependency JARs

The Maven Bundle Plugin doesn’t use the Maven dependency version directly to calculate import ranges—it relies entirely on the Bundle-Version field in the dependency’s MANIFEST.MF. This is a common gotcha!

  • Navigate to your local Maven repo: .m2/com/xxxxxx/yyyy/m2m/com.xxxxxx.yyyy.m2m.config/9.0.0-SNAPSHOT
  • Unpack the JAR file and open META-INF/MANIFEST.MF
  • Check the Bundle-Version value. If it’s something like 8.1.0 instead of 9.0.0.SNAPSHOT, that’s exactly why the plugin generates [8.1,9) as the import range.

This usually happens if the com.xxxxxx.yyyy.m2m.config module wasn’t properly rebuilt with the 9.0.0-SNAPSHOT version in its own bundle configuration.

2. Check your Maven Bundle Plugin version and configuration

Your plugin version is 4.2.0, which is quite old (released in 2019). Older versions might have bugs in version range calculation, especially with SNAPSHOT dependencies.

  • Try upgrading the plugin to the latest stable version (e.g., 5.1.9) in your POM:
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>5.1.9</version>
      <extensions>true</extensions>
      <configuration>
        <!-- your existing instructions -->
      </configuration>
    </plugin>
    
  • Also, check if there’s any explicit configuration in your plugin’s <instructions> (or inherited from the parent POM) that’s overriding the import range for m2m packages. Look for any <Import-Package> entries that might hardcode versions for these packages.

3. Rule out parent POM or global Maven configuration issues

Your project inherits from a parent POM (yyyy-features), so it’s possible that parent is applying bundle plugin settings you’re not aware of:

  • Inspect the parent POM’s <build><plugins> section for any maven-bundle-plugin configurations that might be setting default import rules.
  • Check your global settings.xml (usually in ~/.m2/settings.xml) for profiles or mirrors that might be pulling an older cached version of the m2m dependency instead of the latest SNAPSHOT.

4. Ensure your SNAPSHOT dependencies are properly built

Even if mvn dependency:tree shows the correct version, the actual JAR in your repo might be stale:

  • Navigate to the com.xxxxxx.yyyy.m2m.config module’s source code and run mvn clean install to force a full rebuild.
  • After rebuilding, double-check the MANIFEST.MF in the newly built JAR to confirm the Bundle-Version is 9.0.0.SNAPSHOT.
  • Then run mvn clean install on your current command module and check the generated MANIFEST again.

5. Temporary workaround: Force the import range

If you need a quick fix while troubleshooting, you can explicitly define the import range in your bundle plugin configuration to override the automatic calculation:

<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>
      <Import-Package>
        com.xxxxxx.yyyy.m2m.*;version="[9.0,10)",
        * <!-- Keep this to auto-generate other imports -->
      </Import-Package>
    </instructions>
  </configuration>
</plugin>

This will ensure all m2m packages use the expected [9.0,10) range while letting the plugin handle other imports normally.

内容的提问来源于stack exchange,提问作者maxence pecheux

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 20:22:28