【问题标题】:Ant BND task does not produce bundle containing any itemsAnt BND 任务不会生成包含任何项目的捆绑包
【发布时间】: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),以便他查看。谢谢尼尔!

标签: ant osgi


【解决方案1】:

1) 您是否查看过 bndtools 中包含的 ant 支持? Neil 和我竭尽全力让 bndtools 在离线模式下运行。 2) build.xml 看起来不正确的 ant 语法?你能做一个小例子并发布正确的文件吗? 3) bnd 不应该生成没有 MANIFEST.MF 文件的 jar。运行是否有错误?

如果您无法解决问题,请随时向我发送一个包含设置的 zip 文件,我会检查发生了什么(并在此处报告)。

【讨论】:

    【解决方案2】:

    在 Google Groups bndtools 小组(bndtools 和 bnd 的小组)的帮助下,问题显然是 .bnd 文件不包含 Private-Package 标头。这用于指定实现包,使其成为您想要引入的所有类的基础包。

    我添加之后,所有的类都出现了,组件xml又出现了。

    感谢大家的帮助!

    【讨论】:

      猜你喜欢
      • 2011-12-31
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 2011-08-13
      • 2013-01-03
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多