打包方法在 Buildr 中无效

发布于 2024-08-17 16:46:19 字数 1265 浏览 5 评论 0原文

我正在尝试将 scala 项目打包到 jar 中,并使用 Buildrs package() 方法将属性写入清单。

该包似乎对 Manifest 没有影响。这是构建文件:

VERSION_NUMBER = "1.0.0"
GROUP = "Green"
COPYRIGHT = "Green CopyRight"

require 'buildr/scala'

Buildr::Scala::Scalac::REQUIRES.library = '2.8.0-SNAPSHOT'
Buildr::Scala::Scalac::REQUIRES.compiler = '2.8.0-SNAPSHOT'
Java.classpath.reject! { |c| c.to_s.index('scala') }
Java.classpath << Buildr::Scala::Scalac::REQUIRES

ENV['USE_FSC'] = 'yes'

repositories.remote << "http://www.ibiblio.org/maven2/"

desc "The Green project"
define "Green" do
    project.version = VERSION_NUMBER
    project.group = GROUP
    package(:jar).with :manifest=>manifest.merge(
        'Main-Class'=>'com.acme.Main',
        'Implementation-Vendor'=>COPYRIGHT
    )
end

这是生成的清单:

Build-By: brianheylin
Build-Jdk: 1.6.0_17
Implementation-Title: The Green project
Implementation-Version: 
Implementation-Vendor: 
Main-Class: green.GreenMain
Manifest-Version: 1.0
Created-By: Buildr

请注意,Implementation-VendorMain-Class 属性都没有被覆盖。我按如下方式运行 Buildr:

jruby -S buildr clean package

我使用 jRuby 1.4.0 和 Buildr 1.3.5(作为 gem 安装)。有人对为什么会出现这种情况有任何想法吗?

I'm trying to package a scala project into a jar and write properties to the Manifest using Buildrs package() method.

The package seems to have no affect on the Manifest. Here's the build file:

VERSION_NUMBER = "1.0.0"
GROUP = "Green"
COPYRIGHT = "Green CopyRight"

require 'buildr/scala'

Buildr::Scala::Scalac::REQUIRES.library = '2.8.0-SNAPSHOT'
Buildr::Scala::Scalac::REQUIRES.compiler = '2.8.0-SNAPSHOT'
Java.classpath.reject! { |c| c.to_s.index('scala') }
Java.classpath << Buildr::Scala::Scalac::REQUIRES

ENV['USE_FSC'] = 'yes'

repositories.remote << "http://www.ibiblio.org/maven2/"

desc "The Green project"
define "Green" do
    project.version = VERSION_NUMBER
    project.group = GROUP
    package(:jar).with :manifest=>manifest.merge(
        'Main-Class'=>'com.acme.Main',
        'Implementation-Vendor'=>COPYRIGHT
    )
end

And here's the resulting Manifest:

Build-By: brianheylin
Build-Jdk: 1.6.0_17
Implementation-Title: The Green project
Implementation-Version: 
Implementation-Vendor: 
Main-Class: green.GreenMain
Manifest-Version: 1.0
Created-By: Buildr

Notice that neither the Implementation-Vendor or Main-Class property has been overwritten. I run Buildr as follows:

jruby -S buildr clean package

I'm using jRuby 1.4.0 and Buildr 1.3.5 (installed as a gem). Anyone any ideas on why this is the case?

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

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

发布评论

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

评论(4

风轻花落早 2024-08-24 16:46:19

我使用 buildr 1.3.5 + Ruby 1.8.6 快速测试了这一点并获得了正确的清单。我对构建文件做了一些小更改,这些更改似乎对于您的明显问题来说并不重要。这是我的测试构建文件:

ENV['JAVA_HOME'] = 'C:\Java\32\jdk1.6.0_17'

VERSION_NUMBER = "1.0.0"
GROUP = "Green"
COPYRIGHT = "Green CopyRight"

require 'buildr/scala'

desc "The Green project"
define "Green" do
    project.version = VERSION_NUMBER
    project.group = GROUP
    package(:jar).with :manifest=>manifest.merge(
        'Main-Class'=>'com.acme.Main',
        'Implementation-Vendor'=>COPYRIGHT
    )
end

这是生成的清单:

Implementation-Vendor: Green CopyRight
Manifest-Version: 1.0
Build-By: Travis
Created-By: Buildr
Build-Jdk: 1.6.0_17
Implementation-Title: The Green project
Implementation-Version: 
Main-Class: com.acme.Main

抱歉,我无法告诉你为什么它对我有用,但也许我的帖子会产生一些想法。

I tested this quickly using buildr 1.3.5 + Ruby 1.8.6 and got the correct manifest. I made a few small changes to the buildfile which seem like they shouldn't matter in regards to your manifest problem. Here is my test buildfile:

ENV['JAVA_HOME'] = 'C:\Java\32\jdk1.6.0_17'

VERSION_NUMBER = "1.0.0"
GROUP = "Green"
COPYRIGHT = "Green CopyRight"

require 'buildr/scala'

desc "The Green project"
define "Green" do
    project.version = VERSION_NUMBER
    project.group = GROUP
    package(:jar).with :manifest=>manifest.merge(
        'Main-Class'=>'com.acme.Main',
        'Implementation-Vendor'=>COPYRIGHT
    )
end

And here is the resulting manifest:

Implementation-Vendor: Green CopyRight
Manifest-Version: 1.0
Build-By: Travis
Created-By: Buildr
Build-Jdk: 1.6.0_17
Implementation-Title: The Green project
Implementation-Version: 
Main-Class: com.acme.Main

Sorry I can't tell you why it works for me but maybe my post will spawn some ideas.

你如我软肋 2024-08-24 16:46:19

尝试在 MRI 1.8.6 而不是 JRuby 下测试您的 buildfile。有可能存在一个仅在该运行时出现的错误(尽管不太可能)。由于您使用 Scala 2.8,也可能会出现一些奇怪的情况。在 Scala 2.7 下尝试使用相同 buildfile 的简单应用程序,看看是否有帮助。

很抱歉,目前我只能给你一些疯狂的猜测。您的 buildfile 看起来应该可以工作,所以肯定发生了一些奇怪的事情。

Try testing your buildfile under MRI 1.8.6 rather than JRuby. It's possible there is a bug which only comes out in that runtime (unlikely though). It's also possible that there is some weirdness arising due to your use of Scala 2.8. Try a simple app with the same buildfile under Scala 2.7 and see if that helps.

I'm sorry that I can't give you any more than wild guesses at this point. Your buildfile looks like it should work, so something bizarre is definitely going on.

如梦 2024-08-24 16:46:19

我已经使用 C-Ruby 1.8.7 和 JRuby 1.4.0 进行了测试,但无法使用您提供的 buildfile 重现问题(两种情况下均使用 buildr 1.3.5)

I've tested with both C-Ruby 1.8.7 and JRuby 1.4.0 and I can't reproduce the issue using the buildfile your provided (with buildr 1.3.5 in both cases)

殤城〤 2024-08-24 16:46:19

初次发生后我无法重现此问题。

I can't reproduce this issue after the initial occurrence.

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