This repository has been archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
buildfile
166 lines (141 loc) · 4.96 KB
/
buildfile
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Generated by Buildr 1.4.5, change to your liking
# 1.7 JVM is not compatible with the emma that buildr uses
#require 'buildr/java/emma'
# Version number for this release
VERSION_NUMBER = "1.0.0"
# Group identifier for your projects
GROUP = "thumbslug"
COPYRIGHT = ""
# Specify Maven 2.0 remote repositories here, like this:
repositories.remote << "http://mirrors.ibiblio.org/pub/mirrors/maven2/"
repositories.remote << "https://repository.jboss.org/nexus/content/repositories/releases/"
# for oauth
repositories.remote << "http://oauth.googlecode.com/svn/code/maven/"
require './buildr/checkstyle'
require 'rspec/core/rake_task'
require 'buildr/java/emma'
# dont require findbugs by default
# needs "buildr-findBugs" gem installed
# (and findbugs and it's large set of deps)
findbugs = ENV['findbugs']
if not findbugs.nil?
require 'buildr-findBugs'
end
NETTY = transitive 'org.jboss.netty:netty:jar:3.2.6.Final'
LOG4J = 'log4j:log4j:jar:1.2.14'
DAEMON = transitive 'org.kohsuke:akuma:jar:1.7'
OAUTH = transitive 'net.oauth.core:oauth-consumer:jar:20100527'
COMMONSCODEC = 'commons-codec:commons-codec:jar:1.4'
JUNIT = 'junit:junit:jar:4.5'
MOCKITO = 'org.mockito:mockito-all:jar:1.8.5'
desc "The Thumbslug project"
define "thumbslug" do
project.version = VERSION_NUMBER
project.group = GROUP
manifest["Implementation-Vendor"] = COPYRIGHT
manifest["Main-Class"] = "org.candlepin.thumbslug.Main"
compile.options.target = '1.6'
compile.options.source = '1.6'
compile.with [NETTY, LOG4J, DAEMON, OAUTH, COMMONSCODEC]
test.compile.with [NETTY, LOG4J, DAEMON, OAUTH, COMMONSCODEC]
test.with [JUNIT, MOCKITO]
#
# eclipse settings
# http://buildr.apache.org/more_stuff.html#eclipse
#
eclipse.natures 'org.eclipse.jdt.core.javanature'
eclipse.builders 'org.eclipse.jdt.core.javabuilder'
# include netty (and deps) in the jar, so it can run standalone
# we exclude the manifests of the sub-jars so they don't overwrite
# our own manifest.mf
package(:jar).merge(NETTY).exclude("META-INF/MANIFEST.MF")
package(:jar).merge(LOG4J).exclude("META-INF/MANIFEST.MF")
package(:jar).merge(DAEMON).exclude("META-INF/MANIFEST.MF")
package(:jar).merge(OAUTH).exclude("META-INF/MANIFEST.MF")
package(:jar).merge(COMMONSCODEC).exclude("META-INF/MANIFEST.MF")
package(:jar).with(:manifest => manifest)
end
task :serve do
sh "java -jar target/#{GROUP}-#{VERSION_NUMBER}.jar"
end
task :serve => :package
#==========================================================================
# RSpec functional tests
#==========================================================================
RSpec::Core::RakeTask.new do |task|
# Support optional features env variable, specify the spec files to run
# without the trailing '_spec.rb'. Specify multiple by separating with ':'.
# i.e. build spec features=flex_expiry:authorization
features = ENV['features']
if not features.nil?
feature_files = Array.new
features.split(":").each do |part|
feature_files << "spec/#{part}_spec.rb"
end
task.pattern = feature_files
end
# task.rspec_opts = ["-I#{File.expand_path '../client/ruby/'}"]
task.rspec_opts = ['-c']
skipbundler = ENV['skipbundler']
if not skipbundler.nil?
task.skip_bundler = true
end
# Allow specify only="should do something" to run only a specific
# test. The text must completely match the contents of your "it" string.
only_run = ENV['only']
if not only_run.nil?
task.rspec_opts << "-e '#{only_run}'"
end
dots = ENV['dots']
if not dots.nil?
task.rspec_opts << "-fp"
else
task.rspec_opts << "-fd"
end
end
task :spec => :package
# runs the eclipse task to generate the .classpath and .project
# files, then fixes the output.
task :eclipse do
puts "Fixing eclipse .classpath"
text = File.read(".classpath")
tmp = File.new("tmp", "w")
text = text.gsub(/output="target\/resources"/, "")
tmp.write(text.gsub(/<\/classpath>/, " <classpathentry path=\"#{Java.tools_jar}\" kind=\"lib\"\/>"))
tmp.write("</classpath>")
tmp.close()
FileUtils.copy("tmp", ".classpath")
File.delete("tmp")
# make the gettext output dir to silence eclipse errors
mkdir_p("target/generated-source")
end
# fix the coverage reports generated by emma.
# we're adding to the existing emma:html task here
# This is AWESOME!
namespace :emma do
task :html do
puts "Fixing emma reports"
fixemmareports("reports/emma/coverage.html")
dir = "reports/emma/_files"
Dir.foreach(dir) do |filename|
fixemmareports("#{dir}/#{filename}") unless filename == "." || filename == ".."
end
end
end
# fixes the html produced by emma
def fixemmareports(filetofix)
text = File.read(filetofix)
newstr = ''
text.each_byte do |c|
if c != 160 then
newstr.concat(c)
else
newstr.concat(' ')
end
end
tmp = File.new("tmpreport", "w")
tmp.write(newstr)
tmp.close()
FileUtils.copy("tmpreport", filetofix)
File.delete("tmpreport")
end