<commit_before>#
# setup_java_extension create relevant tasks for building Java extensions
#
def setup_java_extension(extension_name, gem_spec = nil, opts = {})
  ext_name = "#{extension_name}.jar"
  directory 'lib'
  opts = {
    :source_dir => 'ext-java/src/main/java',
    :add_buildr_task => true
    }.merge!(opts)

  desc 'Compile Extension for current Ruby (= compile:jruby)'
  task :compile => [ 'compile:jruby' ] if JRUBY

  namespace :compile do

    desc "Compile Java Extension for JRuby"
    task :jruby => [ :clean ] do
      pkg_classes = File.join(*%w(pkg classes))
      mkdir_p pkg_classes

      if extension_name == 'do_jdbc_internal'
        classpath_arg = java_classpath_arg
      else
        unless File.exists?('../do_jdbc/lib/do_jdbc_internal.jar')
          # Check for the presence of do_jdbc_internal.jar in the do_jdbc project
          # which we need to compile against.
          print "\n"; 80.times { print '-' }; print "\n"
          puts "To compile the Java extension, #{extension_name}, you will first need to compile"
          puts "common JDBC support for DataObjects, do_jdbc:"
          puts "cd ../do_jdbc; jruby -S rake compile"
          80.times { print '-' }; print "\n\n"

          raise "Required file for compilation (do_jdbc_internal.jar) not found."
        end

        classpath_arg = java_classpath_arg '../do_jdbc/lib/do_jdbc_internal.jar'
      end

      # Check if DO_JAVA_DEBUG env var was set to TRUE
      # TRUE means compile java classes with debug info
      if ENV['DO_JAVA_DEBUG'] && ENV['DO_JAVA_DEBUG'].upcase.eql?("TRUE")
        sh "javac -target 1.5 -source 1.5 -Xlint:unchecked -g -d pkg/classes #{classpath_arg} #{FileList["#{opts[:source_dir]}/**/*.java"].join(' ')}"
      else
        sh "javac -target 1.5 -source 1.5 -Xlint:unchecked -d pkg/classes #{classpath_arg} #{FileList["#{opts[:source_dir]}/**/*.java"].join(' ')}"
      end

      sh "jar cf lib/#{ext_name} -C #{pkg_classes} ."
    end

    if opts[:add_buildr_task]
      desc "Compile Java Extension for JRuby (with buildr)"
      task :jruby_buildr do
        begin
          # gem 'buildr', '~>1.3'
          # FIXME: this is throwing RSpec activation errors, as buildr relies on
          # an older version of Rake.

          sh %{#{RUBY} -S buildr package}
<commit_msg>[java rake tasks] if you set the java.ext.dirs system on the jruby call then the javac will use the extdirs. i.e. you can put the oracle jdbc driver in such a directory<commit_after>#
# setup_java_extension create relevant tasks for building Java extensions
#
def setup_java_extension(extension_name, gem_spec = nil, opts = {})
  ext_name = "#{extension_name}.jar"
  directory 'lib'
  opts = {
    :source_dir => 'ext-java/src/main/java',
    :add_buildr_task => true
    }.merge!(opts)

  desc 'Compile Extension for current Ruby (= compile:jruby)'
  task :compile => [ 'compile:jruby' ] if JRUBY

  namespace :compile do

    desc "Compile Java Extension for JRuby"
    task :jruby => [ :clean ] do
      pkg_classes = File.join(*%w(pkg classes))
      mkdir_p pkg_classes

      if extension_name == 'do_jdbc_internal'
        classpath_arg = java_classpath_arg
      else
        unless File.exists?('../do_jdbc/lib/do_jdbc_internal.jar')
          # Check for the presence of do_jdbc_internal.jar in the do_jdbc project
          # which we need to compile against.
          print "\n"; 80.times { print '-' }; print "\n"
          puts "To compile the Java extension, #{extension_name}, you will first need to compile"
          puts "common JDBC support for DataObjects, do_jdbc:"
          puts "cd ../do_jdbc; jruby -S rake compile"
          80.times { print '-' }; print "\n\n"

          raise "Required file for compilation (do_jdbc_internal.jar) not found."
        end

        classpath_arg = java_classpath_arg '../do_jdbc/lib/do_jdbc_internal.jar'
      end

      # just use the extension directory from the executing java
      # for compilation as well
      extdir = java.lang.System.getProperty('java.ext.dirs')
      extdir_arg = extdir.nil? ? "" : "-extdirs #{extdir}"

      # Check if DO_JAVA_DEBUG env var was set to TRUE
      # TRUE means compile java classes with debug info
      if ENV['DO_JAVA_DEBUG'] && ENV['DO_JAVA_DEBUG'].upcase.eql?("TRUE")
        sh "javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -g -d pkg/classes #{classpath_arg} #{FileList["#{opts[:source_dir]}/**/*.java"].join(' ')}"
      else
        sh "javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -d pkg/classes #{classpath_arg} #{FileList["#{opts[:source_dir]}/**/*.java"].join(' ')}"
      end

      sh "jar cf lib/#{ext_name} -C #{pkg_classes} ."
    end

    if opts[:add_buildr_task]
      desc "Compile Java Extension for JRuby (with buildr)"
      task :jruby_buildr do
        begin
          # gem 'buildr', '~>1.3'
          # FIXME: this is throwing RSpec activation errors, as buildr relies on
          # an older version of Rake.

          sh %{#{RUBY} -S buildr package}

{'fraction_non_alphanumeric': 0.12140448323745288, 'fraction_numerical': 0.005554453481452093, 'mean_word_length': 2.7320503330866024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '739415', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1578, 'n_words': 488}