PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/rakelib/compile.rake

https://github.com/jruby/activerecord-jdbc-adapter
Ruby | 62 lines | 51 code | 10 blank | 1 comment | 3 complexity | 298f9f77793841de5488b0d462af751d MD5 | raw file
  1. jar_file = File.join(*%w(lib arjdbc jdbc adapter_java.jar))
  2. begin
  3. require 'ant'
  4. directory classes = "pkg/classes"
  5. CLEAN << classes
  6. driver_jars = []
  7. # PostgreSQL driver :
  8. driver_jars << Dir.glob("jdbc-postgres/lib/*.jar").sort.last
  9. file jar_file => FileList['src/java/**/*.java', 'pkg/classes'] do
  10. rm_rf FileList["#{classes}/**/*"]
  11. ant.javac :srcdir => "src/java", :destdir => "pkg/classes",
  12. :source => "7", :target => "7", :debug => true, :deprecation => true,
  13. :classpath => "${java.class.path}:${sun.boot.class.path}:#{driver_jars.join(':')}",
  14. :includeantRuntime => false
  15. ant.tstamp do |ts|
  16. ts.format(:property => 'TODAY', :pattern => 'yyyy-MM-dd HH:mm:ss')
  17. end
  18. require 'arjdbc/version'
  19. gem_version = Gem::Version.create(ArJdbc::VERSION)
  20. if gem_version.segments.last == 'DEV'
  21. version = gem_version.segments[0...-1] # 1.3.0.DEV -> 1.3.0
  22. else
  23. version = gem_version.segments.dup
  24. end
  25. version = version.join('.')
  26. ant.manifest :file => 'MANIFEST.MF' do |mf|
  27. mf.attribute :name => 'Built-By', :value => '${user.name}'
  28. mf.attribute :name => 'Built-Time', :value => '${TODAY}'
  29. mf.attribute :name => 'Built-Jdk', :value => '${java.version}'
  30. mf.attribute :name => 'Built-JRuby', :value => JRUBY_VERSION
  31. mf.attribute :name => 'Specification-Title', :value => 'ActiveRecord-JDBC'
  32. mf.attribute :name => 'Specification-Version', :value => '1.3'
  33. mf.attribute :name => 'Specification-Vendor', :value => 'JRuby'
  34. mf.attribute :name => 'Implementation-Version', :value => version
  35. mf.attribute :name => 'Implementation-Vendor', :value => 'The JRuby Team'
  36. end
  37. ant.jar :basedir => "pkg/classes", :includes => "**/*.class",
  38. :destfile => jar_file, :manifest => 'MANIFEST.MF'
  39. end
  40. desc "Compile the native Java code."
  41. task :jar => jar_file
  42. namespace :jar do
  43. task :force do
  44. rm jar_file if File.exist?(jar_file)
  45. Rake::Task['jar'].invoke
  46. end
  47. end
  48. rescue LoadError
  49. task :jar do
  50. puts "Run 'jar' with JRuby to re-compile the agent extension class"
  51. end
  52. end