English 中文(简体)
Package method having no effect in Buildr
原标题:

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?

最佳回答

I can t reproduce this issue after the initial occurrence.

问题回答

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:Java32jdk1.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.

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.

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)





相关问题
Refactor packages in a Jar

I have a requirement that i need to load two versions of a jar at once. To avoid class path collisions I d like to rename the packages of one of the jars. Then in source you could always easily ...

Directory list of JAR file within classpath

The typically method to reference a file contained with a JAR file is to use ClassLoader.getResource. Is there a way to get the contents of a directory within a JAR files (similar to java.io.File....

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Jar file resource not available?

My program has the following lines, works fine when run from Netbeans, JButton Button_1=new JButton(new ImageIcon(Phone_Dialer.class.getResource("Dir_Icons/"+"Key_1"+Botton_Color+".gif"))); But ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

loading from JAR files during deployment vs development

when i am loading some data into my java program, i usually use FileInputStream. however i deploy the program as a jar file and webstart, so i have to use getRessource() or getRessourceAsStream() to ...

热门标签