Skip to content

Remove ant #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build.xml
catalog.xml
Gemfile.lock
src/test/resources/db/delayed.db
target
16 changes: 9 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
source "https://rubygems.org"

gem 'ruby-maven'
gem 'jruby-rack'

group :test do
group :development do
gem 'rake'
gem 'test-unit', '~> 2.5.3'
gem 'test-unit-context'
gem 'mocha'
end

group :test do
gem 'test-unit'
gem 'mocha', require: 'mocha/test_unit'
end

group :delayed_job do
Expand All @@ -24,16 +27,15 @@ group :delayed_job do
end
end
else
gem 'delayed_job'
gem 'delayed_job_active_record', :require => nil
gem 'delayed_job_active_record'
gem 'delayed_cron_job', :require => nil
end
if ENV['activerecord']
gem 'activerecord', ENV['activerecord'], :require => nil
else
gem 'activerecord', :require => nil # for tests
end
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3.20', :require => nil, :platform => :jruby
gem 'activerecord-jdbcsqlite3-adapter', '~> 61.3'
end

group :resque do
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,26 @@ end

## Build

[JRuby](http://jruby.org) 1.6.8+ is required to build the project.
[JRuby](http://jruby.org) 9.4.8.0+ is required to build the project.

The build is performed by [rake](http://rake.rubyforge.org) which should be part
of your JRuby installation, if you're experiencing conflicts with another Ruby and
it's `rake` executable use `jruby -S rake` instead.
Besides you will need [ant](http://ant.apache.org/) installed for the Java part.
Install gems :

bundle install

Build the *jruby-rack-worker_[VERSION].jar* using :

rake jar
bundle exec rake jar

Build the gem (includes the .jar packaged) :

rake gem
bundle exec rake gem


## Testing

Run tests with:

bundle exec rake


## Copyright
Expand Down
150 changes: 27 additions & 123 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unless defined?(JRUBY_VERSION)
raise "Hey, we're not running within JRuby my dear !"
end

require 'ruby-maven'

PROJECT_NAME = 'jruby-rack-worker'

Expand All @@ -15,10 +20,6 @@ TEST_RESULTS_DIR = File.join(OUT_DIR, 'test-results')

LIB_BASE_DIR = 'lib'

unless defined?(JRUBY_VERSION)
raise "Hey, we're not running within JRuby my dear !"
end

load File.join(RUBY_SRC_DIR, "#{PROJECT_NAME.gsub('-', '/')}", 'version.rb')

def project_version
Expand All @@ -29,86 +30,17 @@ def out_jar_path
"#{OUT_DIR}/#{PROJECT_NAME}_#{project_version}.jar"
end

require 'ant'
ant.property :name => "ivy.lib.dir", :value => LIB_BASE_DIR

namespace :ivy do

ivy_version = '2.2.0'
ivy_jar_dir = File.join(LIB_BASE_DIR, 'build')
ivy_jar_file = File.join(ivy_jar_dir, 'ivy.jar')

task :download do
mkdir_p ivy_jar_dir
ant.get :src => "http://repo1.maven.org/maven2/org/apache/ivy/ivy/#{ivy_version}/ivy-#{ivy_version}.jar",
:dest => ivy_jar_file,
:usetimestamp => true
end

task :install do
Rake::Task["ivy:download"].invoke unless File.exist?(ivy_jar_file)

ant.path :id => 'ivy.lib.path' do
fileset :dir => ivy_jar_dir, :includes => '*.jar'
end
ant.taskdef :resource => "org/apache/ivy/ant/antlib.xml", :classpathref => "ivy.lib.path"
end

task :clean do
rm_rf LIB_BASE_DIR
end

end

task :retrieve => :"ivy:install" do
ant.retrieve :pattern => "${ivy.lib.dir}/[conf]/[artifact].[type]"
end

ant.path :id => "main.class.path" do
fileset :dir => LIB_BASE_DIR do
include :name => 'runtime/*.jar'
end
end
ant.path :id => "test.class.path" do
fileset :dir => LIB_BASE_DIR do
include :name => 'test/*.jar'
end
end
desc "build jar"
task :jar do
RubyMaven.exec('package', '-DskipTests=true')

task :compile => :retrieve do
mkdir_p MAIN_BUILD_DIR
ant.javac :destdir => MAIN_BUILD_DIR, :source => '1.5' do
src :path => MAIN_SRC_DIR
classpath :refid => "main.class.path"
end
end

task :copy_resources do
mkdir_p ruby_dest_dir = File.join(MAIN_BUILD_DIR, '') # 'META-INF/jruby_rack_worker'
ant.copy :todir => ruby_dest_dir do
fileset :dir => RUBY_SRC_DIR do
exclude :name => 'jruby_rack_worker.rb' # exclude :name => 'jruby/**'
end
end
end

desc "build jar"
task :jar => [ :compile, :copy_resources ] do
ant.jar :destfile => out_jar_path, :basedir => MAIN_BUILD_DIR do
manifest do
attribute :name => "Built-By", :value => "${user.name}"
attribute :name => "Implementation-Title", :value => PROJECT_NAME
attribute :name => "Implementation-Version", :value => project_version
attribute :name => "Implementation-Vendor", :value => "Karol Bucek"
attribute :name => "Implementation-Vendor-Id", :value => "org.kares"
end
end
cp Dir["target/*.jar"].first, out_jar_path
end

desc "build gem"
task :gem => [ :jar ] do
warn "building using JRuby: #{JRUBY_VERSION}" if JRUBY_VERSION > '9.0'
raise "building on Java > 7" if ENV_JAVA['java.specification.version'] > '1.7'

mkdir_p gem_out = File.join(OUT_DIR, 'gem')
mkdir_p gem_out_lib = File.join(gem_out, 'lib')
Expand All @@ -120,10 +52,9 @@ task :gem => [ :jar ] do
abort "too many jars! #{jars.map{ |j| File.basename(j) }.inspect}\nrake clean first"
end

ant.copy :todir => gem_out_lib do
fileset :dir => RUBY_SRC_DIR do
include :name => '*.rb'
include :name => 'jruby/**/*.rb'
%w[*.rb jruby/**/*.rb].each do |glob|
Dir[File.join(RUBY_SRC_DIR, glob)].each do |file|
cp file, gem_out_lib
end
end

Expand Down Expand Up @@ -159,16 +90,6 @@ task :gem => [ :jar ] do
end
end

task :'test:compile' => :compile do
mkdir_p TEST_BUILD_DIR
ant.javac :destdir => TEST_BUILD_DIR, :source => '1.5' do
src :path => TEST_SRC_DIR
classpath :refid => "main.class.path"
classpath :refid => "test.class.path"
classpath { pathelement :path => MAIN_BUILD_DIR }
end
end

task :'bundler:setup' do
begin
require 'bundler/setup'
Expand All @@ -179,57 +100,39 @@ end

namespace :test do

desc "run ruby tests"
task :ruby do # => :'bundler:setup'
task 'dependencies' do
Rake::Task['jar'].invoke unless File.exists?(out_jar_path)
RubyMaven.exec('dependency:copy-dependencies', '-DincludeScope=provided', '-P!jruby-dependencies')
end

desc "run ruby tests"
task :ruby do
Rake::Task['test:dependencies'].invoke
_ruby_test('src/test/ruby/**/*_test.rb')
end

desc "run DJ (ruby) tests only"
task 'ruby:delayed' do # => :'bundler:setup'
Rake::Task['jar'].invoke unless File.exists?(out_jar_path)
task 'ruby:delayed' do
Rake::Task['test:dependencies'].invoke
_ruby_test('src/test/ruby/delayed/**/*_test.rb')
end

desc "run Resque (ruby) tests only"
task 'ruby:resque' do # => :'bundler:setup'
Rake::Task['jar'].invoke unless File.exists?(out_jar_path)
task 'ruby:resque' do
Rake::Task['test:dependencies'].invoke
_ruby_test('src/test/ruby/resque/**/*_test.rb')
end

def _ruby_test(test_files)
test_files = ENV['TEST'] || File.join(test_files)
#test_opts = (ENV['TESTOPTS'] || '').split(' ')
test_files = FileList[test_files].map { |path| path.sub('src/test/ruby/', '') }
ruby "-Isrc/main/ruby:src/test/ruby", "-e #{test_files.inspect}.each { |test| require test }"
ruby "-I", "src/main/ruby:src/test/ruby", "-e", "#{test_files.inspect}.each { |test| require test }"
end

desc "run java tests"
task :java => :'test:compile' do
mkdir_p TEST_RESULTS_DIR
ant.junit :fork => true,
:haltonfailure => false,
:haltonerror => true,
:showoutput => true,
:printsummary => true do

classpath :refid => "main.class.path"
classpath :refid => "test.class.path"
classpath do
pathelement :path => MAIN_BUILD_DIR
pathelement :path => TEST_BUILD_DIR
end

formatter :type => "xml"

batchtest :fork => "yes", :todir => TEST_RESULTS_DIR do
fileset :dir => TEST_SRC_DIR do
include :name => "**/*Test.java"
end
end
end
task :java do
RubyMaven.exec('verify', '-Pjruby-dependencies')
end

end

desc "run all tests"
Expand All @@ -240,4 +143,5 @@ task :default => :test
desc "clean up"
task :clean do
rm_rf OUT_DIR
RubyMaven.exec('clean')
end
84 changes: 84 additions & 0 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# frozen_string_literal: true

load File.join(basedir, 'src/main/ruby/jruby/rack/worker/version.rb')

project do
model_version '4.0.0'

group_id 'org.kares.jruby.rack'
artifact_id 'jruby-rack-worker'
version JRuby::Rack::Worker::VERSION
packaging 'jar'

properties(
'project.build.sourceEncoding' => 'UTF-8',
'project.reporting.outputEncoding' => 'UTF-8',
# 'polyglot.dump.pom' => 'pom.xml',
# 'polyglot.dump.readonly' => true
)

profiles do
profile 'jruby-dependencies' do
activation do
active_by_default true
end
dependencies do
dependency do
group_id 'org.jruby'
artifact_id 'jruby'
version '9.4.8.0'
scope 'provided'
end
end
end
end

dependencies do
dependency do
group_id 'javax.servlet'
artifact_id 'servlet-api'
version '2.4'
scope 'provided'
end

dependency do
group_id 'org.jruby.rack'
artifact_id 'jruby-rack'
version '1.1.12'
scope 'provided'
exclusion 'org.jruby', 'jruby-complete'
end

dependency do
group_id 'junit'
artifact_id 'junit'
version '4.11'
scope 'test'
end

dependency do
group_id 'org.mockito'
artifact_id 'mockito-all'
version '1.9.5'
scope 'test'
end
end

build do
plugins do
plugin('org.apache.maven.plugins:maven-jar-plugin') do
configuration(
archive: {
manifest_entries: {
'Built-By' => '${user.name}',
'Implementation-Title' => '${project.name}',
'Implementation-Version' => '${project.version}',
'Implementation-Vendor' => 'Karol Bucek',
'Implementation-Vendor-Id' => 'org.kares'
}
}
)
end
end
end
end
Loading