Permalink
Browse files

Rework Rakefile structure for do_jdbc

  • Loading branch information...
1 parent 37cbfa1 commit cf116f34e60405c896a0d0399502eee7cb3dc0bc @dbussink dbussink committed May 16, 2009
Showing with 150 additions and 44 deletions.
  1. +6 −44 do_jdbc/Rakefile
  2. +50 −0 do_jdbc/tasks/gem.rake
  3. +15 −0 do_jdbc/tasks/install.rake
  4. +4 −0 do_jdbc/tasks/native.rake
  5. +75 −0 do_jdbc/tasks/release.rake
View
50 do_jdbc/Rakefile
@@ -1,54 +1,16 @@
-require 'pathname'
require 'rubygems'
require 'rake'
-require 'rake/rdoctask'
-require 'spec/rake/spectask'
-require 'lib/do_jdbc/version.rb'
+require 'rake/clean'
+
+require 'pathname'
+require 'lib/do_jdbc/version'
ROOT = Pathname(__FILE__).dirname.expand_path
JRUBY = RUBY_PLATFORM =~ /java/
WINDOWS = Gem.win_platform?
SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
-AUTHOR = "Alex Coles"
-EMAIL = "alex@alexcolesportfolio.com"
-GEM_NAME = "do_jdbc"
-GEM_VERSION = DataObjects::Jdbc::VERSION
-GEM_DEPENDENCIES = [["data_objects", GEM_VERSION]]
-GEM_CLEAN = ['build/*','dist/*','lib/**/*.jar']
-GEM_EXTRAS = { :platform => 'java', :has_rdoc => false, :extra_rdoc_files => %w[ README.markdown MIT-LICENSE GPL-LICENSE ] }
-
-PROJECT_NAME = "dorb"
-PROJECT_URL = "http://rubyforge.org/projects/dorb"
-PROJECT_DESCRIPTION = PROJECT_SUMMARY = "JDBC support for DataObjects.rb drivers"
-
-
-if (tasks_dir = ROOT.parent + 'tasks').directory?
- require tasks_dir + 'hoe'
- require tasks_dir + 'ext_helper_java'
-
- setup_java_extension "#{GEM_NAME}_internal", HOE.spec,
- :source_dir => 'src/java', :add_buildr_task => false
-end
-
-def sudo_gem(cmd)
- sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
-end
-
-# Installation
-
-task :default => [ :compile ]
-
-task :filelist do
- puts FileList['pkg/**/*'].inspect
-end
+Dir['tasks/*.rake'].each { |f| import f }
-desc "Install #{GEM_NAME} #{GEM_VERSION}"
-task :install => [ :package ] do
- sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
-end
+CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ])
-desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
-task :uninstall => [ :clean ] do
- sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x"
-end
View
50 do_jdbc/tasks/gem.rake
@@ -0,0 +1,50 @@
+require 'rubygems/package_task'
+
+GEM_SPEC = Gem::Specification.new do |s|
+ # basic information
+ s.name = "do_jdbc"
+ s.version = DataObjects::Jdbc::VERSION
+
+ # description and details
+ s.summary = 'DataObjects JDBC support library'
+ s.description = "Provides JDBC support for usage in DO drivers for JRuby"
+
+ # dependencies
+ s.add_dependency "addressable", "~>2.0.0"
+ s.add_dependency "extlib", "~>0.9.12"
+ s.add_dependency "data_objects", DataObjects::Jdbc::VERSION
+ s.platform = "java"
+
+ # development dependencies
+ s.add_development_dependency 'rspec', '~>1.2.0'
+
+ # components, files and paths
+ s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
+ "MIT-LICENSE", "GPL-LICENSE", "Rakefile", "*.{rdoc,txt,yml}", "lib/*.jar"]
+
+ s.require_path = 'lib'
+
+ # documentation
+ s.has_rdoc = false
+
+ # project information
+ s.homepage = 'http://github.com/datamapper/do'
+ s.rubyforge_project = 'dorb'
+
+ # author and contributors
+ s.author = 'Alex Coles'
+ s.email = 'alex@alexcolesportfolio.com'
+end
+
+gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
+ pkg.need_tar = false
+ pkg.need_zip = false
+end
+
+file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
+ puts "Generating #{t.name}"
+ File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
+end
+
+desc "Generate or update the standalone gemspec file for the project"
+task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
View
15 do_jdbc/tasks/install.rake
@@ -0,0 +1,15 @@
+def sudo_gem(cmd)
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
+end
+
+# Installation
+
+desc "Install #{GEM_SPEC.name} #{GEM_SPEC.version}"
+task :install => [ :package ] do
+ sudo_gem "install pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version} --no-update-sources"
+end
+
+desc "Uninstall #{GEM_SPEC.name} #{GEM_SPEC.version}"
+task :uninstall => [ :clean ] do
+ sudo_gem "uninstall #{GEM_SPEC.name} -v#{GEM_SPEC.version} -I -x"
+end
View
4 do_jdbc/tasks/native.rake
@@ -0,0 +1,4 @@
+if (tasks_dir = ROOT.parent + 'tasks').directory?
+ require tasks_dir + 'ext_helper_java'
+ setup_java_extension("#{GEM_SPEC.name}_internal", GEM_SPEC, :source_dir => 'src/java', :add_buildr_task => false)
+end
View
75 do_jdbc/tasks/release.rake
@@ -0,0 +1,75 @@
+begin
+ gem 'rubyforge', '~> 1.0.1'
+ require 'rubyforge'
+rescue Exception
+ nil
+end
+
+if defined?(RubyForge) then
+ if defined?(GEM_SPEC) then
+ desc 'Package and upload to RubyForge'
+ task :release => [:package] do |t|
+ ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
+
+ # compare versions to avoid mistakes
+ unless ver == GEM_SPEC.version.to_s then
+ fail "Version mismatch (supplied and specification versions differ)."
+ end
+
+ # no rubyforge project? no release for you!
+ if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
+ fail "Must define rubyforge_project in your gem specification."
+ end
+
+ # instantiate a RubyForge object
+ rf = RubyForge.new
+
+ # read project info and overview
+ notes = begin
+ r = File.read("README.rdoc")
+ r.split(/^(=+ .*)/)[1..4].join.strip
+ rescue
+ warn "Missing README.rdoc"
+ ''
+ end
+
+ # read changes
+ changes = begin
+ h = File.read("History.txt")
+ h.split(/^(==+ .*)/)[1..2].join.strip
+ rescue
+ warn "Missing History.txt"
+ ''
+ end
+
+ # build the configuration for the release
+ config = Hash.new
+ config["release_notes"] = notes
+ config["release_changes"] = changes
+ config["preformatted"] = true
+
+ # prepare configuration
+ rf.configure config
+
+ files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
+ fail "No files found for the release." if files.empty?
+
+ puts "Logging in RubyForge..."
+ rf.login
+
+ puts "Files to upload:"
+ files.each do |f|
+ puts " * #{f}"
+ end
+
+ puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
+ rf.add_release GEM_SPEC.rubyforge_project, GEM_SPEC.name, GEM_SPEC.version, *files
+ puts "Done."
+ end
+ Rake::Task['release'].prerequisites.unshift('clean', 'cross', 'native')
+ else
+ warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
+ end
+else
+ warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
+end

0 comments on commit cf116f3

Please sign in to comment.