【发布时间】:2011-08-11 19:30:47
【问题描述】:
在将 maven 项目转换为 ant 项目后,我无法生成捆绑包。 bnd ant 任务创建 test.jar 但该文件仅包含 META-INF。 eclipse 项目名为 testproj。我错过了什么?另外,有人知道有更多 bnd ant 任务示例的地方吗? bnd 站点本身在这方面有点欠缺,尤其是在如何构建类路径值方面。
<project name="testproj" basedir="." default="build">
<patternset id="project.deploy.jars">
<include name="slf4j-api-1.6.1.jar" />
<include name="logback-core-0.9.28.jar" />
<include name="logback-classic-0.9.28.jar" />
<include name="org.osgi.compendium-4.2.0.jar" />
<include name="org.apache.felix.http.jetty-2.2.0.jar" />
<include name="jcl-over-slf4j-1.6.1.jar" />
<include name="mail-1.4.4-1.0.0.jar" />
<include name="commons-io-2.0.1.jar" />
<include name="commons-lang-2.6.jar" />
<include name="commons-codec-1.5.jar" />
<include name="commons-httpclient-3.1-osgi-1.0.0.jar" />
<include name="bndlib-1.43.0.jar" />
<include name="ojdbc5-osgi-1.0.0.jar" />
<include name="joda-time-1.6.2.jar" />
<include name="cxf-dosgi-ri-singlebundle-distribution-1.2.jar" />
</patternset>
<path id="bnd.classpath">
<fileset dir="setup/external">
<patternset refid="project.deploy.jars" />
</fileset>
</path>
<target name="build" description="Build the bundle">
<taskdef resource="aQute/bnd/ant/taskdef.properties"
classpath="setup/dev/biz.aQute.bnd.jar"
/>
<pathconvert property="bnd.classpath.string" pathsep=",">
<path refid="bnd.classpath" />
<mapper>
<chainedmapper>
<flattenmapper/>
<regexpmapper from="(.*)" to="setup/external/\1" casesensitive="no"/>
</chainedmapper>
</mapper>
</pathconvert>
<echo>${bnd.classpath.string}</echo>
<bnd
classpath="target/classes,${bnd.classpath.string}"
eclipse="true"
failok="false"
exceptions="true"
output="test.jar"
files="test.bnd"/>
</target>
</project>
test.bnd:
Import-Package:com.test.service, oracle.sql, oracle.jdbc, oracle.jdbc.driver, *
Export-Package:com.test.service
Service-Component:com.test.*
【问题讨论】:
-
BNDtools 在 BND 之上提供了更高级的工具,至少值得一看:bndtools.org
-
是的,我确实喜欢 bndtools,但我的经理只是在推动一个 ant-offline 构建过程。不过还是谢谢。
-
是否有可能在类路径中找不到包
com.test.service,即在target.classes目录中?如果类路径上不存在该包,那么您的包将为空(除了清单)。顺便说一句,您的经理应该知道您可以使用 Bndtools 并进行离线构建过程;-) -
我已经用完整的构建文件更新了该项目,以防万一我错过了一些明显的东西。我一定是做对了一些事情,因为今天我看到了服务接口,但是 impl 类并没有将其放入包中,服务组件 xml 也没有。我将 .zip 发送给 Peter(减去 jars),以便他查看。谢谢尼尔!