-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rakefile
109 lines (86 loc) · 3.72 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'rubygems'
require 'bundler'
require "fileutils"
require 'rake'
require File.expand_path(File.join(File.dirname(__FILE__), 'src/main/ruby/naether'))
namespace :naether do
task :setup_naether_gem_build do
unless File.exists?( "target" )
raise "Run `mvn package` to build java first"
end
unless File.exists?( "target/gem" )
Dir.mkdir( "target/gem" )
end
unless File.exists?( "target/gem/lib" )
FileUtils.mkdir_p( "target/gem/lib/naether/java" )
end
Dir.glob("src/main/ruby/**/*.rb") do |file|
FileUtils.copy( file, file.gsub("src/main/ruby", "target/gem/lib"))
end
FileUtils.copy( 'jar_dependencies.yml', "target/gem/jar_dependencies.yml" )
FileUtils.copy( 'LICENSE', "target/gem/LICENSE" )
FileUtils.copy( 'README.md', "target/gem/README.md" )
FileUtils.copy( 'pom.xml', "target/gem/pom.xml" )
FileUtils.copy( 'VERSION', "target/gem/VERSION" )
FileUtils.copy( 'PostInstallRakefile', "target/gem/Rakefile" )
FileUtils.copy( 'Gemfile', "target/gem/Gemfile" )
version = IO.read('VERSION').strip
if !File.exists? "target/core-#{version}.jar"
raise "target/core-#{version}.jar does not exist"
end
FileUtils.copy( "target/core-#{version}.jar", "target/gem/core-#{version}.jar" )
# Change dir so relevant files have the correct paths
Dir.chdir( "target/gem" )
end
task :version_return_from_target do
FileUtils.copy( 'VERSION', "../../." )
Dir.chdir( "../../" )
end
# XXX: bit of chicken and the egg, need a valid jar_dependencies to properly
# bootstrap Naether
desc "write jar_dependencies.yml"
task :write_dependencies do
Naether::Configuration[:naether_jar] = "target/core-#{Naether::Configuration[:version]}.jar"
require "#{File.dirname(__FILE__)}/src/main/ruby/naether/java"
Naether::Java.load_paths( "target/classes" )
require "#{File.dirname(__FILE__)}/src/main/ruby/naether/bootstrap"
Naether::Bootstrap.bootstrap_local_repo("target/test-repo", :dep_yaml => File.expand_path( '../jar_dependencies.yml', __FILE__ ) )
Naether::Bootstrap.write_dependencies()
end
end
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "naether"
gem.rubyforge_project = 'naether'
gem.homepage = "http://github.com/mguymon/naether"
gem.license = "Apache"
gem.summary = %Q{Java dependency resolver using Maven's Aether}
gem.description = %Q{Java dependency resolver using Maven's Aether}
gem.email = "[email protected]"
gem.authors = ["Michael Guymon"]
gem.platform = $platform || RUBY_PLATFORM[/java/] || 'ruby'
gem.require_paths = %w[lib]
gem.extensions = ["Rakefile"]
# all files in target/gem should be included, expect for pkg
gem.files = Dir.glob("**/*").select{ |path| !(path =~ /^pkg/) }
end
Jeweler::RubygemsDotOrgTasks.new
Rake::Task["build"].enhance ["naether:setup_naether_gem_build"]
Rake::Task["version_required"].enhance ["naether:setup_naether_gem_build"]
Rake::Task["gemspec:release"].enhance ["naether:setup_naether_gem_build"]
Rake::Task["version:bump:major"].enhance ['naether:version_return_from_target']
Rake::Task["version:bump:minor"].enhance ['naether:version_return_from_target']
Rake::Task["version:bump:patch"].enhance ['naether:version_return_from_target']
Rake::Task["build"]
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'src/test/spec/**/*_spec.rb'
end
task :test => :spec
task :default => :test
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', 'LICENSE', 'pom.xml', 'jar_dependencies.yml']
end
#Rake::Task["build"].enhance ['yard']