2011-11-13 4 views
4

J'ai ajouté quelques pots externes à mon CLASSPATH en ajoutant ceci dans config/application.rb:Comment ajouter correctement au CLASSPATH dans un projet JRuby on Rails?

require 'java' 
$CLASSPATH << "#{File.dirname(__FILE__)}/../backend/src/" 
Dir["#{File.dirname(__FILE__)}/../backend/lib/*.jar"].each do |jar| 
    require jar 
end 

Cela fonctionne bien lors de l'exécution Rails en utilisant rails server. Les pots du CLASSPATH sont chargés. Toutefois, lors de l'exécution rake le classpath n'est pas défini. Comment puis-je le définir? En particulier, je dois le mettre avant de charger mes gemmes, car j'utilise la gemme JRClj, qui repose sur le fait d'avoir déjà clojure.jar dans mon CLASSPATH.

(Oh, j'ai aussi essayé de mettre le code dans environment.rb, n'a pas aidé)

Par "fonctionne pas", je veux dire:

$ 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)' 

Répondre

Questions connexes