Buildr Manifest 从 EAR 包生成类路径
我正在使用(并学习)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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 EarTask 的构建文档包含 解决方案 :
The builds doc for the EarTask contains the solution I believe: