【发布时间】:2017-08-24 07:07:30
【问题描述】:
调试时,为什么我的包中的服务没有被其他包导入,我注意到,我声明了错误的 commons-io 版本(1.4 而不是 2.4)。但是,在调用 mvn clean 然后 mnv install 我注意到,旧版本仍然被引用!另外,没有声明org.apache.httpcomponents的版本!
我的有效 POM 如下所示:
....
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>compile</scope>
</dependency>
...
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<_noee>true</_noee>
<_removeheaders>Import-Service,Export-Service</_removeheaders>
</instructions>
</configuration>
</execution>
</executions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<_noee>true</_noee>
<_removeheaders>Import-Service,Export-Service</_removeheaders>
</instructions>
</configuration>
</plugin>
我在 MANIFEST.MF 中看到的是:
进口包装: .....................,org.apache.com mons.io;version="[1.4,2)",org.apache.http,org.apache.http.client,org.ap ache.http.client.methods,org.apache.http.entity,org.apache.http.impl.cl ient,org.osgi.service.blueprint;version="[1.0.0,2.0.0)",........
现在 maven-bundle-plugin 的行为对我来说似乎是随机的。有时版本被放置在清单中,有时没有,有时来自同一个包的包被放置在 Import-Package 部分,有时没有......现在旧的包版本被放置,好像它被缓存在某个地方......
是否有任何方法可以强制 maven-bundle-plugin 从 maven 依赖项中正确解析包版本?我不想手动编写版本,因为这是我们使用 Maven 的目的......
一个可能很重要的注意事项:使用这些导入的类在蓝图描述符中声明,这是 maven-bundle-plugin 在第一行找到包的方式,看起来插件在蓝图支持方面存在一些问题...
【问题讨论】:
标签: java maven osgi versioning blueprint