私はconfig/application.rb
でこれを追加することによって、私のCLASSPATHに、いくつかの外部のjarファイルを追加しました:JRuby on RailsプロジェクトのCLASSPATHに正しく追加するにはどうすればよいですか?
require 'java'
$CLASSPATH << "#{File.dirname(__FILE__)}/../backend/src/"
Dir["#{File.dirname(__FILE__)}/../backend/lib/*.jar"].each do |jar|
require jar
end
rails server
を使用して、レールを実行するときにこれが正常に動作します。 CLASSPATHのjarファイルがロードされます。ただし、rake
を実行すると、クラスパスは設定されません。どうすれば設定できますか?特に、CLASSPATHにclojure.jarを既に持っているJRCljの宝石を使用するので、私は宝石をロードする前にそれを設定する必要があります。
(ああ、私もenvironment.rbにでコードを入れてみました。助けにはならなかった)
「機能しない」とは、私は意味:
$ rake rspec --trace
rake aborted!
No such file to load -- /MY_CURRENT_WORKING_DIRECTORY/clojure.lang.RT
org/jruby/RubyKernel.java:1063:in `load'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/pbiggar/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/default_loader.rb:6:in `load'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:569:in `load_imports'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:508:in `raw_load_rakefile'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/pbiggar/.rvm/gems/[email protected]/gems/rake-0.9.2.2/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1063:in `load'
/Users/pbiggar/.rvm/gems/[email protected]/bin/rake:19:in `(root)'