forked from mongodb/mongo-ruby-kerberos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
110 lines (95 loc) · 2.81 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
110
# Copyright (C) 2009-2013 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require "bundler"
Bundler.setup
$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
require "rake"
require "rake/extensiontask"
require "rspec/core/rake_task"
def jruby?
defined?(JRUBY_VERSION)
end
if jruby?
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new do |ext|
ext.name = "native"
ext.ext_dir = "src"
ext.lib_dir = "lib/mongo/auth/kerberos"
end
else
require "rake/extensiontask"
Rake::ExtensionTask.new do |ext|
ext.name = "mongo_kerberos_native"
ext.ext_dir = "ext/mongo_kerberos"
ext.lib_dir = "lib"
end
end
require "mongo/gssapi_native/version"
def extension
RUBY_PLATFORM =~ /darwin/ ? "bundle" : "so"
end
RSpec::Core::RakeTask.new(:rspec)
if jruby?
task :build => [ :clean_all, :compile ] do
system "gem build mongo_kerberos.gemspec"
end
else
task :build => :clean_all do
system "gem build mongo_kerberos.gemspec"
end
end
task :clean_all => :clean do
begin
Dir.chdir(Pathname(__FILE__).dirname + "lib") do
["o", extension, "jar"].each do |e|
Dir.glob(File.join("**", "*.#{e}")).each do |f|
`rm #{f}`
end
end
end
rescue Exception => e
puts e.message
end
end
task :spec => :compile do
Rake::Task["rspec"].invoke
end
# Run bundle exec rake release with mri and jruby. Ex:
#
# rvm use 2.1.0@mongo_kerberos
# bundle exec rake release
# rvm use jruby@mongo_kerberos
# bundle exec rake release
task :release => :build do
system "git tag -a #{Mongo::Auth::Kerberos::VERSION} -m 'Tagging release: #{Mongo::Auth::Kerberos::VERSION}'"
system "git push --tags"
if jruby?
system "gem push mongo_kerberos-#{Mongo::Auth::Kerberos::VERSION}-java.gem"
system "rm mongo_kerberos-#{Mongo::Auth::Kerberos::VERSION}-java.gem"
else
system "gem push mongo_kerberos-#{Mongo::Auth::Kerberos::VERSION}.gem"
system "rm mongo_kerberos-#{Mongo::Auth::Kerberos::VERSION}.gem"
end
end
task :default => [ :clean_all, :spec ]
desc "Generate all documentation"
task :docs => 'docs:yard'
namespace :docs do
desc "Generate yard documention"
task :yard do
out = File.join('yard-docs', Mongo::Auth::Kerberos::VERSION)
FileUtils.rm_rf(out)
system "yardoc -o #{out} --title mongo-ruby-kerberos-#{Mongo::Auth::Kerberos::VERSION}"
end
end