Buildr Manifest 从 EAR 包生成类路径

发布于 2024-12-14 09:49:03 字数 1161 浏览 0 评论 0原文

我正在使用(并学习)Buildr 来构建和打包我的项目。我想在 EJB 项目 MANIFEST 文件中自动生成类路径属性。目前我正在做:

manifest_cp = compile.dependencies.map { |d| 
    "#{File.basename(d.name)}"
}.join(" ")

package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)

我是 Ruby 和 Buildr 的新手,所以可能有更好的方法来做到这一点。然而,我实际上希望能够生成我定义的 jar 并将其打包在 EAR 中,而不是在 JAR 中获取编译依赖项。

我将我的ear项目打包为:

package(:ear).include(ANTLR, AOP_ALLIANCE, ...

在打包jar并修改清单时,是否可以在我的EJB项目构建中创建包含打包在EAR中的所有依赖项的Class-Path属性?除此之外,我还想排除一两个依赖项?

谢谢

更新

我尝试了一种看起来更好的不同方法(但仍然可能有比我所拥有的更好的方法)。我创建了一个常量来保存我想要包含在 EAR 中的所有工件,然后构建类路径字符串:

EARLIBS = [ANTLR, AOP_ALLIANCE, ... ]
manifest_cp = Buildr.artifacts(EARLIBS).each { |artifact| artifact.invoke }.map{ |d| 
        "#{File.basename(d.to_s)}"
}.join(" ")

当我打包 EJB 时,我指定上面创建的 manifest_cp:

package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)

当我打包 EAR 时,我引用用 all 声明的常量工件:

package(:ear).include(EARLIBS)

即使这适用于我想要的东西,如果有人有更好的方法,我将不胜感激

,谢谢,

I am using (and learning) Buildr to build and package my projects. I would like to auto generate the class-path attribute in an EJB projects MANIFEST file. Currently I am doing:

manifest_cp = compile.dependencies.map { |d| 
    "#{File.basename(d.name)}"
}.join(" ")

package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)

I am new to Ruby and Buildr so there probably is a better way to do this. However I was actually hoping to be able to generate the jars I define and package in my EAR as opposed to getting the compile dependencies in my JAR.

I package my ear project like:

package(:ear).include(ANTLR, AOP_ALLIANCE, ...

Is it possible in my EJB project build when packaging the jar and modifying the manifest I create the Class-Path attribute with all the dependencies packaged in the EAR? On top of that I would also like to exclude one or two dependencies?

thanks

UPDATE

I tried a different approach that seems better (but still probably there are much better ways than what I have). I created a constant that held all my artifacts I want to include in my EAR and then built up the classpath string:

EARLIBS = [ANTLR, AOP_ALLIANCE, ... ]
manifest_cp = Buildr.artifacts(EARLIBS).each { |artifact| artifact.invoke }.map{ |d| 
        "#{File.basename(d.to_s)}"
}.join(" ")

When I package the EJB I specify the manifest_cp that was created above:

package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)

When I package the EAR I reference the constant declared with all the artifacts:

package(:ear).include(EARLIBS)

Even though this works for what I want I would appreciate it if anyone has a better way of doing it

thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过潦 2024-12-21 09:49:03

我相信 EarTask 的构建文档包含 解决方案 :

所有指定的库都将添加到 EAR 存档中,并且每个 EAR 组件的类路径清单条目都会进行修改。

The builds doc for the EarTask contains the solution I believe:

All specified libraries are added to the EAR archive and the Class-Path manifiest entry is modified for each EAR component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文