2010-01-06 133 views
1

我有一個buildr腳本,首先加載一個java屬性文件,然後創建一個ant任務。我得到一箇中止錯誤:Buildr中止! org/apache/tools/ant/DefaultLogger運行buildr時。Apache Buildr問題與ant任務/ Hash.from_java_properties

這裏是(簡化)生成文件:

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

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

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

end 

我使用Buildr 1.3.5 OS X 10.6和Ruby 1.8.7

堆棧跟蹤:

** 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 

回答

2

如在Buildr郵件列表中回答的,您需要在致電Hash.from_java_properties之前添加Java.load,以便正確初始化RJB *。

這通常在加載buildfile後自動完成,但由於您在加載階段使用Java對象,因此需要明確告訴Buildr。 (*)RJB =紅寶石 - Java橋

+0

太棒了,很有用,謝謝! –

1

聲音就像一個類路徑問題一樣,但我無法確切地告訴你所提供的信息。嘗試運行buildr --trace併發布完整結果。

就在旁邊,但這類問題最容易在Buildr Users郵件列表中提出並回答。

+0

哦,但我只是愛堆棧溢出這麼多....是這樣錯了嗎? –

+0

添加了跟蹤,並在列表中發佈。謝謝你的提示。 –