English 中文(简体)
Apache Buildr issue with ant task / Hash.from_java_properties
原标题:

I have a buildr script that first loads a java properties file, then creates an ant task. I m getting an abort error: Buildr aborted! org/apache/tools/ant/DefaultLogger when running buildr.

Here s the (simplified) buildfile:

CONFIG = Hash.from_java_properties("a=1")

define "my_project", :version => "1.0" do

  ant("ant_test") do |ant_project|
    # do something
  end

end

I m using Buildr 1.3.5 on OS X 10.6 with Ruby 1.8.7

stack trace:

** Invoke my_project (first_time)
** Execute my_project
Defining task my_project:shell:jirb
Defining task my_project:shell:clj
Defining task my_project:shell:bsh
** Invoke /Users/jsbowers/.m2/repository/org/apache/ant/ant/1.7.1/ant-1.7.1.jar (first_time, not_needed)
** Invoke /Users/jsbowers/.m2/repository/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar (first_time, not_needed)
** Invoke /Users/jsbowers/.m2/repository/org/apache/ant/ant-trax/1.7.1/ant-trax-1.7.1.jar (first_time, not_needed)
** Invoke /Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/java (first_time, not_needed)
Buildr aborted!
org/apache/tools/ant/DefaultLogger
/Library/Ruby/Gems/1.8/gems/Antwrap-0.7.0/lib/rjb_modules.rb:16:in `import 
/Library/Ruby/Gems/1.8/gems/Antwrap-0.7.0/lib/rjb_modules.rb:16
/Library/Ruby/Gems/1.8/gems/Antwrap-0.7.0/lib/ant_project.rb:86:in `initialize 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/java/ant.rb:74:in `new 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/java/ant.rb:74:in `ant 
/Users/jsbowers/tmp/buildr_test/buildfile:9
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:225:in `instance_exec 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:225:in `define 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:625:in `execute 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:146:in `switch_to_namespace 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:624:in `execute 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:630:in `invoke_with_call_chain 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:616:in `invoke_with_call_chain 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:611:in `invoke 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/util.rb:204:in `__send__ 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/util.rb:204:in `to_proc 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:281:in `each 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:281:in `projects 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/project.rb:863:in `projects 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:400:in `raw_load_buildfile 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:218:in `load_buildfile 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:496:in `standard_exception_handling 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:213:in `load_buildfile 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:137:in `run 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:496:in `standard_exception_handling 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:135:in `run 
/Library/Ruby/Gems/1.8/gems/buildr-1.3.5/bin/buildr:19
/usr/bin/buildr:19:in `load 
/usr/bin/buildr:19
最佳回答

As answered on the Buildr mailing list, you need to add Java.load before your call to Hash.from_java_properties so RJB* is correctly initialized.

This is normally done automatically after the buildfile is loaded but since you re using Java objects during the loading phase, you need to tell Buildr explicitly.

(*) RJB = Ruby-Java Bridge

问题回答

Sounds like a classpath problem, but I can t really say for sure with the information you have given. Try running buildr --trace and posting the full results.

Just an aside, but questions of this sort are most easily asked and answered on the Buildr Users mailing-list.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签