forked from OvercastNetwork/SportBukkit
/
Rakefile
97 lines (70 loc) · 1.98 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
require 'rubygems'
require 'git'
require 'maven/ruby/maven'
task :default => [:update, :build, :compile]
task :update, :tag do |t, args|
args.with_defaults(:tag => 'HEAD')
Dir.mkdir("build") if !File.directory?("build")
update("Bukkit", args.tag)
update("CraftBukkit", args.tag)
end
task :build do
abort("Run update first!") if !File.directory?("build")
build("Bukkit")
build("CraftBukkit")
end
task :compile do
abort("Run update first!") if !File.directory?("build")
compile("Bukkit")
compile("CraftBukkit")
end
task :deploy do
abort("Run update first!") if !File.directory?("build")
deploy("Bukkit")
deploy("CraftBukkit")
end
# FIX ME
def run(cmd)
IO.popen(cmd) { |io| while (line = io.gets) do puts line end }
fail if $?.exitstatus != 0
end
def update(project, tag)
Dir.chdir("build")
p "Checking out " + project + " [" + tag + "]"
if File.directory?(project)
g = Git.open(project)
else
uri = "git://github.com/Bukkit/" + project + ".git"
g = Git.clone(uri, project)
end
g.reset_hard(Git::Object::Tag.new(g, tag, tag))
run("git clean -fd") # FIX ME
g.pull(g.remotes.first, "master")
g.remote("origin").merge
Dir.chdir("..")
end
def build(project)
Dir.chdir("build/" + project)
g = Git.open(".")
g.reset_hard
run("git clean -fqd") # FIX ME
p "Applying patches for: " + project
patches = Dir.glob("../../" + project + "/*.patch").sort
patches.each do |patch|
p "Applying " + project + "/" + File.basename(patch)
run("patch -Np1 --ignore-whitespace -F3 --quiet < " + patch) # FIX ME
end
Dir.chdir("../..")
end
def compile(project)
Dir.chdir("build/" + project)
mvn = Maven::Ruby::Maven.new
fail if mvn.exec("clean install") == false
Dir.chdir("../..")
end
def deploy(project)
Dir.chdir("build/" + project)
mvn = Maven::Ruby::Maven.new
fail if mvn.exec("deploy") == false
Dir.chdir("../..")
end