buildr 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +48 -0
- data/README +1 -1
- data/Rakefile +204 -0
- data/bin/buildr +7 -0
- data/lib/buildr.rb +155 -16
- data/lib/buildr/cobertura.rb +26 -19
- data/lib/buildr/hibernate.rb +8 -6
- data/lib/buildr/javacc.rb +1 -0
- data/lib/buildr/jdepend.rb +31 -4
- data/lib/buildr/jetty.rb +26 -28
- data/lib/buildr/openjpa.rb +8 -6
- data/lib/buildr/xmlbeans.rb +9 -4
- data/lib/core/build.rb +40 -50
- data/lib/core/checks.rb +358 -0
- data/lib/core/common.rb +161 -62
- data/lib/core/generate.rb +65 -0
- data/lib/core/help.rb +72 -0
- data/lib/core/project.rb +32 -37
- data/lib/core/rake_ext.rb +12 -66
- data/lib/core/transports.rb +388 -363
- data/lib/java/ant.rb +33 -36
- data/lib/java/artifact.rb +172 -160
- data/lib/java/compile.rb +13 -21
- data/lib/java/eclipse.rb +5 -5
- data/lib/java/idea.ipr.template +284 -0
- data/lib/java/idea.rb +107 -72
- data/lib/java/java.rb +42 -18
- data/lib/java/packaging.rb +242 -124
- data/lib/java/test.rb +532 -135
- data/lib/tasks/zip.rb +72 -23
- metadata +24 -10
data/CHANGELOG
CHANGED
@@ -1,3 +1,51 @@
|
|
1
|
+
1.2 (6/6/2007)
|
2
|
+
* Added: Artifact.list returns specs for all registered artifacts (those created with artifact or package).
|
3
|
+
* Added: Buildr.option.java_args are used when creating the RJB JVM, when running a Java process (unless you override directly), and when running JUnit tests (again, unless override).
|
4
|
+
* Added: TestNG support (test.using :testng).
|
5
|
+
* Added: You can run multiple tests from the command line, e.g. rake test:foo,bar.
|
6
|
+
* Added: If you want to distribute source code and JavaDoc alongside your JARs (helpful when using IDE/debugging), you can now do so by calling package_with_sources and package_with_javadoc on the project (or the parent project to affect all its sub-projects).
|
7
|
+
* Added: junit:report task generates XML and HTML reports in the reports/junit directory.
|
8
|
+
* Added: test=all option runs all test cases ignoring failure.
|
9
|
+
* Added: project generation for IntelliJ Idea. Imports dependencies properly from your local repository (the M2_REPO path variable must be defined), supports tests and resources.
|
10
|
+
* Added: A check task for each project that runs after packaging and can be used to check the build itself, using RSpec matchers.
|
11
|
+
* Added: The help task can be used to get basic information about your build. Right now it returns a list of described tasks, but you can extend it using the help method. Try it out: rake help.
|
12
|
+
* Added: Integration tests that run after packaging (unless tests are disabled). There's only one integration tests task (duh) that you can access from anywhere. You can tell a project to run its tests during the integration phase with test.using :integration.
|
13
|
+
* Added: package :sources and package :javadoc, used by package_with_sources and package_with_javadoc.
|
14
|
+
* Added: Unzip paths now return root/target. (Nathan)
|
15
|
+
* Added: buildr command line, replacing rake. Differs from rake in two ways: uses buildfile by default (but Rakefile also works) and offers to create buildfile if you don't already have one.
|
16
|
+
* Added: options.proxy.http now set from the environment variable HTTP_PROXY (Anatol Pomozov).
|
17
|
+
* Added: options.java_args now set from environment variable JAVA_OPTIONS.
|
18
|
+
* Changed: Filter now complains if source directory or target directory not set, or if source directory does not exist.
|
19
|
+
* Changed: Filter.run returns true if filter run, false otherwise, and can be run multiple times.
|
20
|
+
* Changed: repositories.proxy returns a URI or nil; you can still set a proxy using a hash.
|
21
|
+
* Changed: Transports went the way of the Dodo, instead we now use read/write/download/upload methods implemented on URI itself.
|
22
|
+
* Changed: We now have a way to configure multiple proxies through the options.proxy method; use that instead of repositories.proxies.
|
23
|
+
* Changed: Upgraded to Ant 1.7.0, JUnit 4.3, JMock 1.2.
|
24
|
+
* Changed: TestTask now provides list of test classes and failed classes through test_classes and failed_tests attributes.
|
25
|
+
* Changed: The jetty method is now available everywhere, so you can change the URL using jetty.url = at the top of the Rakefile. Also upgraded to 6.1.3.
|
26
|
+
* Changed: Test classes are now identified as either starting with Test* or ending with *Test, before attempting any include/exclude patterns. Anything ending with *TestCase or *Suite ignored for now (but if you explain why, we can add it back).
|
27
|
+
* Changed: What used to be the projects task is now help:projects task, anticipating more help: tasks to come.
|
28
|
+
* Changed: We now have 3(!) JDepend tasks: jdepend:swing (with windows!), jdepend:text (console) and jdepend:xml (enterprisy).
|
29
|
+
* Changed: Good news for packagers: package_as_ yield no longer required, just make sure to create the task once and return it each time.
|
30
|
+
* Changed: JUnit tests now run using Ant, which makes them faster to run, and gives you text/XML reports (check out the reports/junit directory).
|
31
|
+
* Changed: Cobertura now writes reports to reports/cobertura, in fact, if you're looking for a report of any kind, the reports directory is the place to find it.
|
32
|
+
* Changed: Upgraded to AntWrap 0.6. Note that with AntWrap 0.6 we yield to the block instead of doing instance_eval, so any call to the ant project must be prefixed with an AntProject object. Code that relies on the old functionality (and that's pretty much any code with element-containing tasks) will break.
|
33
|
+
* Changed: artifacts now accepts a struct.
|
34
|
+
* Changed: The repositories.download method folded into Artifact, the repositories.deploy method renamed upload and folded into ActsAsArtifact.
|
35
|
+
* Changed: The deploy task is now called upload, and repositories.deploy_to is now repositories.release_to.
|
36
|
+
* Removed: The check task, which previously was a way to find some circular dependencies (multitask) but not others (dynamically defined).
|
37
|
+
* Removed: JUnitTask, test.junit and Java.junit methods all deprecated; anything you need to affect the unit tests is right there in TestTask.
|
38
|
+
* Removed: The package(:jar) and package(:war) options, such as :manifest, :include, :libs are all deprecated. Instead, use the package method to define the package, and the with method to enhance it, e.g. package(:war).with(:libs=>...) instead of package(:war, :libs=>...).
|
39
|
+
* Removed: The []= method on ZipTask and anything derived from it is deprecated in favor of using attribute accessors.
|
40
|
+
* Removed: Ant.executable and Ant.declarative are deprecated. Use Buildr.ant instead of Ant.executable. Use AntWrap directly if you need the Ant.declarative functionality.
|
41
|
+
* Fixed: Filter now properly handles multiple keys on the same line.
|
42
|
+
* Fixed: Tests teardown now properly executing.
|
43
|
+
* Fixed: Cobertura tasks now run tests, even if test=no.
|
44
|
+
* Fixed: XMLBeans compile task not detecting change to XSD file.
|
45
|
+
* Fixed: URI.download and download task do not create directory path for downloaded file (Anders Bengtsson).
|
46
|
+
* Fixed: Gets JVM version number from system property java.version instead of calling java -version.
|
47
|
+
* Fixed: Artifact downloads POM first, such that you can download/create/fake it youself.
|
48
|
+
|
1
49
|
1.1.3 (6/12/2007)
|
2
50
|
* Added: Long awaited idea project files generation. Very early code, the iml seems to be generated okay but needs testing. The ipr is still missing but will come in due time (and it's not always necessary anyway).
|
3
51
|
*Fixed: Doc bug: unzip doesn't have an into(dir) method.
|
data/README
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
Gem::manage_gems
|
3
|
+
require "rake/gempackagetask"
|
4
|
+
require "spec/rake/spectask"
|
5
|
+
|
6
|
+
|
7
|
+
# Gem specification comes first, other tasks rely on it.
|
8
|
+
spec = Gem::Specification.new do |spec|
|
9
|
+
|
10
|
+
spec.name = "buildr"
|
11
|
+
spec.version = File.read(__FILE__.pathmap("%d/lib/buildr.rb")).scan(/VERSION\s*=\s*(['"])(.*)\1/)[0][1]
|
12
|
+
spec.author = "Assaf Arkin"
|
13
|
+
spec.email = "arkin@intalio.com"
|
14
|
+
spec.homepage = "http://#{spec.name}.rubyforge.org"
|
15
|
+
spec.summary = "A build system that doesn't suck"
|
16
|
+
spec.files = FileList["lib/**/*", "CHANGELOG", "README", "LICENSE", "Rakefile"].collect
|
17
|
+
spec.require_path = "lib"
|
18
|
+
spec.autorequire = "buildr.rb"
|
19
|
+
spec.has_rdoc = true
|
20
|
+
spec.extra_rdoc_files = ["README", "CHANGELOG", "LICENSE"]
|
21
|
+
spec.rdoc_options << "--title" << "Buildr -- #{spec.summary}" <<
|
22
|
+
"--main" << "README" << "--line-numbers" << "-inline-source"
|
23
|
+
spec.rubyforge_project = "buildr"
|
24
|
+
|
25
|
+
spec.bindir = "bin" # Use these for applications.
|
26
|
+
spec.executables = ["buildr"]
|
27
|
+
|
28
|
+
# Tested against these dependencies.
|
29
|
+
spec.add_dependency "rake", "= 0.7.3"
|
30
|
+
spec.add_dependency "facets", "= 1.8.54"
|
31
|
+
spec.add_dependency "builder", "= 2.1.2"
|
32
|
+
spec.add_dependency "net-ssh", "= 1.1.2"
|
33
|
+
spec.add_dependency "net-sftp", "= 1.1.0"
|
34
|
+
spec.add_dependency "rubyzip", "= 0.9.1"
|
35
|
+
spec.add_dependency "highline", "= 1.2.9"
|
36
|
+
spec.add_dependency "rjb", "= 1.0.6"
|
37
|
+
spec.add_dependency "Antwrap", "= 0.6.0"
|
38
|
+
spec.add_dependency "rspec", "= 1.0.5"
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Testing is everything.
|
43
|
+
desc "Run test cases"
|
44
|
+
Spec::Rake::SpecTask.new(:test) do |task|
|
45
|
+
task.spec_files = FileList["test/**/*.rb"]
|
46
|
+
task.spec_opts = [ "--format", "specdoc", "--color", "--diff" ]
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Run test cases with rcov"
|
50
|
+
Spec::Rake::SpecTask.new(:rcov) do |task|
|
51
|
+
task.spec_files = FileList["test/**/*.rb"]
|
52
|
+
task.spec_opts = [ "--format", "specdoc", "--color", "--diff" ]
|
53
|
+
task.rcov = true
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# Packaging and local installation.
|
58
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
59
|
+
pkg.need_tar = true
|
60
|
+
pkg.need_zip = true
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Install the package locally"
|
64
|
+
task :install=>:package do |task|
|
65
|
+
system "gem", "install", "pkg/#{spec.name}-#{spec.version}.gem"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Uninstall previously installed packaged"
|
69
|
+
task :uninstall do |task|
|
70
|
+
system "gem", "uninstall", spec.name, "-v", spec.version.to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# Documentation.
|
75
|
+
begin
|
76
|
+
require "rake/rdoctask"
|
77
|
+
require "docter"
|
78
|
+
require "docter/server"
|
79
|
+
require "docter/ultraviolet"
|
80
|
+
|
81
|
+
desc "Generate RDoc documentation"
|
82
|
+
rdoc = Rake::RDocTask.new(:rdoc) do |rdoc|
|
83
|
+
rdoc.rdoc_dir = "html/rdoc"
|
84
|
+
rdoc.title = spec.name
|
85
|
+
rdoc.options = spec.rdoc_options
|
86
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
87
|
+
rdoc.rdoc_files.include spec.extra_rdoc_files
|
88
|
+
end
|
89
|
+
|
90
|
+
web_collection = Docter.collection.using("doc/web.toc.textile").include("doc/pages", "CHANGELOG", "LICENSE")
|
91
|
+
web_template = Docter.template("doc/web.haml").include("doc/css", "doc/images")
|
92
|
+
print_collection = Docter.collection.using("doc/print.toc.textile").include("doc/pages")
|
93
|
+
print_template = Docter.template("doc/print.haml").include("doc/css", "doc/images")
|
94
|
+
|
95
|
+
Docter.filter_for(:footnote) do |html|
|
96
|
+
html.gsub(/<p id="fn(\d+)">(.*?)<\/p>/, %{<p id="fn\\1" class="footnote">\\2</p>})
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "Produce PDF"
|
100
|
+
print = Docter::Rake.generate("print", print_collection, print_template, :one_page)
|
101
|
+
pdf_file = file("html/buildr.pdf"=>print) do |task|
|
102
|
+
mkpath "html"
|
103
|
+
sh *%W{prince #{print}/index.html -o #{task.name}} do |ok, res|
|
104
|
+
fail "Failed to create PDF, see errors above" unless ok
|
105
|
+
end
|
106
|
+
end
|
107
|
+
task("pdf"=>pdf_file) { |task| `kpdf #{File.expand_path(pdf_file.to_s)}` }
|
108
|
+
|
109
|
+
desc "Generate HTML documentation"
|
110
|
+
html = Docter::Rake.generate("html", web_collection, web_template)
|
111
|
+
desc "Run Docter server"
|
112
|
+
Docter::Rake.serve :docter, web_collection, web_template, :port=>3000
|
113
|
+
|
114
|
+
desc "Generate all documentation merged into the html directory"
|
115
|
+
task "docs"=>[html, rdoc.name, pdf_file]
|
116
|
+
task("clobber") { rm_rf [html, print].map(&:to_s) }
|
117
|
+
|
118
|
+
rescue LoadError=>error
|
119
|
+
puts error
|
120
|
+
puts "To create the Buildr documentation you need to:"
|
121
|
+
puts " gem install docter"
|
122
|
+
puts " gem install ultraviolet"
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
# Commit to SVN, upload and do the release cycle.
|
128
|
+
namespace :svn do
|
129
|
+
task :clean? do |task|
|
130
|
+
status = `svn status`.reject { |line| line =~ /\s(pkg|html)$/ }
|
131
|
+
fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty?
|
132
|
+
end
|
133
|
+
|
134
|
+
task :tag do |task|
|
135
|
+
cur_url = `svn info`.scan(/URL: (.*)/)[0][0]
|
136
|
+
new_url = cur_url.sub(/trunk$/, "tags/#{spec.version.to_s}")
|
137
|
+
system "svn", "remove", new_url, "-m", "Removing old copy" rescue nil
|
138
|
+
system "svn", "copy", cur_url, new_url, "-m", "Release #{spec.version.to_s}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
namespace :upload do
|
143
|
+
task :docs=>"rake:docs" do |task|
|
144
|
+
`rsync -r --del --progress html/* rubyforge.org:/var/www/gforge-projects/#{spec.rubyforge_project.downcase}`
|
145
|
+
end
|
146
|
+
|
147
|
+
task :packages=>["rake:docs", "rake:package"] do |task|
|
148
|
+
# Read the changes for this release.
|
149
|
+
pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d+\/\d+\/\d+\)\s*((:?^[^\n]+\n)*))/
|
150
|
+
changelog = File.read(__FILE__.pathmap("%d/CHANGELOG"))
|
151
|
+
changes = changelog.scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
|
152
|
+
current = changes[spec.version.to_s]
|
153
|
+
if !current && spec.version.to_s =~ /\.0$/
|
154
|
+
current = changes[spec.version.to_s.split(".")[0..-2].join(".")]
|
155
|
+
end
|
156
|
+
fail "No changeset found for version #{spec.version}" unless current
|
157
|
+
|
158
|
+
puts "Uploading #{spec.name} #{spec.version}"
|
159
|
+
files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{spec.name}-#{spec.version}.#{ext}" }
|
160
|
+
system "rubyforge", "login"
|
161
|
+
files.each do |file|
|
162
|
+
system "rubyforge", "add_release", spec.rubyforge_project.downcase, spec.name.downcase,
|
163
|
+
spec.version.to_s, file, "-a", current
|
164
|
+
end
|
165
|
+
puts "Release #{spec.version} uploaded"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
desc "Upload release to RubyForge including docs, tag SVN"
|
170
|
+
task :release=>[ "clobber", "svn:clean?", "test", "upload:packages", "upload:docs", "svn:tag" ]
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
# Misc, may not survive so don't rely on these.
|
175
|
+
task :report do |task|
|
176
|
+
puts "#{spec.name} #{spec.version}"
|
177
|
+
puts spec.summary
|
178
|
+
sources = (spec.files + FileList["test/**/*.rb"]).reject { |f| File.directory?(f) }
|
179
|
+
sources.inject({}) do |lists, file|
|
180
|
+
File.readlines(file).each_with_index do |line, i|
|
181
|
+
if line =~ /(TODO|FIXME|NOTE):\s*(.*)/
|
182
|
+
list = lists[$1] ||= []
|
183
|
+
list << sprintf("%s (%d): %s", file, i, $2)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
lists
|
187
|
+
end.each_pair do |type, list|
|
188
|
+
unless list.empty?
|
189
|
+
puts
|
190
|
+
puts "#{type}:"
|
191
|
+
list.each { |line| puts line }
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
namespace :setup do
|
197
|
+
task :jetty do
|
198
|
+
cp = ["jetty-6.1.1.jar", "jetty-util-6.1.1.jar", "servlet-api-2.5-6.1.1"].
|
199
|
+
map { |jar| `locate #{jar}`.split.first }.join(File::PATH_SEPARATOR)
|
200
|
+
Dir.chdir "lib/buildr/jetty" do
|
201
|
+
`javac -cp #{cp} JettyWrapper.java`
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
data/bin/buildr
ADDED
data/lib/buildr.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "highline"
|
2
|
+
require "highline/import"
|
2
3
|
# &:symbol goodness.
|
3
4
|
require "facet/symbol/to_proc"
|
4
5
|
# blank? on string and nil
|
@@ -17,23 +18,159 @@ require "facet/array/head"
|
|
17
18
|
require "facet/string/starts_with"
|
18
19
|
require "facet/openobject"
|
19
20
|
require "facets/core/kernel/tap"
|
20
|
-
require "facets/core/kernel/with"
|
21
21
|
# A different kind of buildr, one we use to create XML.
|
22
|
-
require "builder"
|
23
22
|
|
24
23
|
|
25
|
-
module
|
26
|
-
|
27
|
-
warn_without_color HighLine.new.color(message.to_s, :red)
|
28
|
-
end
|
29
|
-
alias_method_chain :warn, :color
|
24
|
+
module Buildr
|
25
|
+
VERSION = "1.2.0".freeze
|
30
26
|
end
|
31
27
|
|
32
28
|
|
33
|
-
|
34
|
-
|
29
|
+
# When running from +rake+, we already have an Application setup and must plug into it,
|
30
|
+
# since the top-level tasks come from there. When running from +buildr+, we get to load
|
31
|
+
# Rake and set everything up, and we use our own Application full of cool Buildr features.
|
32
|
+
unless defined?(Rake)
|
33
|
+
require "rake"
|
34
|
+
|
35
|
+
class Application < Rake::Application #:nodoc:
|
36
|
+
|
37
|
+
DEFAULT_BUILDFILES = ["buildfile", "Buildfile"] + DEFAULT_RAKEFILES
|
38
|
+
|
39
|
+
OPTIONS = [ # :nodoc:
|
40
|
+
['--help', '-H', GetoptLong::NO_ARGUMENT,
|
41
|
+
"Display this help message."],
|
42
|
+
['--nosearch', '-N', GetoptLong::NO_ARGUMENT,
|
43
|
+
"Do not search parent directories for the buildfile."],
|
44
|
+
['--quiet', '-q', GetoptLong::NO_ARGUMENT,
|
45
|
+
"Do not log messages to standard output."],
|
46
|
+
['--buildfile', '-f', GetoptLong::OPTIONAL_ARGUMENT,
|
47
|
+
"Use FILE as the buildfile."],
|
48
|
+
['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
|
49
|
+
"Require MODULE before executing buildfile."],
|
50
|
+
['--trace', '-t', GetoptLong::NO_ARGUMENT,
|
51
|
+
"Turn on invoke/execute tracing, enable full backtrace."],
|
52
|
+
['--verbose', '-v', GetoptLong::NO_ARGUMENT,
|
53
|
+
"Log message to standard output (default)."],
|
54
|
+
['--version', '-V', GetoptLong::NO_ARGUMENT,
|
55
|
+
"Display the program version."],
|
56
|
+
['--freeze', "-F", GetoptLong::NO_ARGUMENT,
|
57
|
+
"Freezes the Buildfile so it always uses Buildr version #{Buildr::VERSION}"],
|
58
|
+
['--unfreeze', "-U", GetoptLong::NO_ARGUMENT,
|
59
|
+
"Unfreezes the Buildfile to use the latest version of Buildr"]
|
60
|
+
]
|
61
|
+
|
62
|
+
def initialize()
|
63
|
+
super
|
64
|
+
@rakefiles = DEFAULT_BUILDFILES
|
65
|
+
end
|
66
|
+
|
67
|
+
def run()
|
68
|
+
standard_exception_handling do
|
69
|
+
@name = "Buildr"
|
70
|
+
opts = GetoptLong.new(*command_line_options)
|
71
|
+
opts.each { |opt, value| do_option(opt, value) }
|
72
|
+
collect_tasks
|
73
|
+
load_buildfile
|
74
|
+
top_level
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def do_option(opt, value)
|
79
|
+
case opt
|
80
|
+
when '--help'
|
81
|
+
help
|
82
|
+
exit
|
83
|
+
when "--buildfile"
|
84
|
+
@rakefiles.clear
|
85
|
+
@rakefiles << value
|
86
|
+
when '--version'
|
87
|
+
puts "Buildr, version #{Buildr::VERSION}"
|
88
|
+
exit
|
89
|
+
when "--freeze"
|
90
|
+
find_buildfile
|
91
|
+
puts "Freezing the Buildfile so it always uses Buildr version #{Buildr::VERSION}"
|
92
|
+
gem =
|
93
|
+
original = File.read(rakefile)
|
94
|
+
if original =~ /gem\s*(["'])buildr\1/
|
95
|
+
modified = original.sub(/gem\s*(["'])buildr\1\s*,\s*(["']).*\2/, %{gem "buildr", "#{Buildr::VERSION}"})
|
96
|
+
else
|
97
|
+
modified = %{gem "buildr", "#{Buildr::VERSION}"\n} + original
|
98
|
+
end
|
99
|
+
File.open(rakefile, "w") { |file| file.write modified }
|
100
|
+
exit
|
101
|
+
when "--unfreeze"
|
102
|
+
find_buildfile
|
103
|
+
puts "Unfreezing the Buildfile to use the latest version of Buildr from your Gems repository."
|
104
|
+
modified = File.read(rakefile).sub(/^\s*gem\s*(["'])buildr\1.*\n/, "")
|
105
|
+
File.open(rakefile, "w") { |file| file.write modified }
|
106
|
+
exit
|
107
|
+
when '--require', "--nosearch", "--quiet", "--trace", "--verbose"
|
108
|
+
super
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def find_buildfile()
|
113
|
+
here = Dir.pwd
|
114
|
+
while ! have_rakefile
|
115
|
+
Dir.chdir("..")
|
116
|
+
if Dir.pwd == here || options.nosearch
|
117
|
+
error = "No Buildfile found (looking for: #{@rakefiles.join(', ')})"
|
118
|
+
if STDIN.isatty
|
119
|
+
if $terminal.agree("To use Buildr you need a buildfile. Do you want me to create one? (yes/no)")
|
120
|
+
chdir(original_dir) { task("generate").invoke }
|
121
|
+
end
|
122
|
+
exit 1
|
123
|
+
else
|
124
|
+
raise error
|
125
|
+
end
|
126
|
+
end
|
127
|
+
here = Dir.pwd
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def load_buildfile()
|
132
|
+
find_buildfile
|
133
|
+
puts "(in #{Dir.pwd})"
|
134
|
+
load File.expand_path(@rakefile) if @rakefile != ''
|
135
|
+
load_imports
|
136
|
+
end
|
137
|
+
|
138
|
+
def usage()
|
139
|
+
puts "Buildr #{Buildr::VERSION}"
|
140
|
+
puts
|
141
|
+
puts "Usage:"
|
142
|
+
puts " buildr [-f buildfile] {options} targets..."
|
143
|
+
end
|
144
|
+
|
145
|
+
def help()
|
146
|
+
usage
|
147
|
+
puts
|
148
|
+
puts "Options:"
|
149
|
+
OPTIONS.sort.each do |long, short, mode, desc|
|
150
|
+
if mode == GetoptLong::REQUIRED_ARGUMENT
|
151
|
+
if desc =~ /\b([A-Z]{2,})\b/
|
152
|
+
long = long + "=#{$1}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
printf " %-20s (%s)\n", long, short
|
156
|
+
printf " %s\n", desc
|
157
|
+
end
|
158
|
+
puts
|
159
|
+
puts "For help with your buildfile:"
|
160
|
+
puts " buildr help"
|
161
|
+
end
|
162
|
+
|
163
|
+
def command_line_options
|
164
|
+
OPTIONS.collect { |lst| lst[0..-2] }
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
Rake.application = Application.new
|
35
170
|
end
|
36
171
|
|
172
|
+
|
173
|
+
# Now it's safe to load Buildr, after we set up the Rake Application.
|
37
174
|
$LOAD_PATH.unshift __DIR__
|
38
175
|
["core", "tasks", "java"].each do |dir|
|
39
176
|
Dir[File.join(__DIR__, dir, "*.rb")].map { |file| File.basename(file) }.each { |file| require "#{dir}/#{file}" }
|
@@ -43,9 +180,11 @@ end
|
|
43
180
|
# Methods defined in Buildr are both instance methods (e.g. when included in Project)
|
44
181
|
# and class methods when invoked like Buildr.artifacts().
|
45
182
|
module Buildr ; extend self ; end
|
46
|
-
# The
|
183
|
+
# The Buildfile object (self) has access to all the Buildr methods and constants.
|
47
184
|
class << self ; include Buildr ; end
|
48
|
-
class Object
|
185
|
+
class Object #:nodoc:
|
186
|
+
Buildr.constants.each { |c| const_set c, Buildr.const_get(c) unless const_defined?(c) }
|
187
|
+
end
|
49
188
|
# Project has visibility to everything in the Buildr namespace. (See above for constants)
|
50
189
|
class Project ; include Buildr ; end
|
51
190
|
|
@@ -55,15 +194,15 @@ module Buildr
|
|
55
194
|
end
|
56
195
|
|
57
196
|
# Load the settings files.
|
58
|
-
[ File.expand_path("buildr.
|
59
|
-
[ File.expand_path("buildr.
|
197
|
+
[ File.expand_path("buildr.rb", Gem::user_home), "buildr.rb" ].each { |file| load file if File.exist?(file) }
|
198
|
+
[ File.expand_path("buildr.rake", Gem::user_home), File.expand_path("buildr.rake") ].each do |file|
|
60
199
|
if File.exist?(file)
|
61
|
-
warn "Please use #{file.ext('
|
62
|
-
|
200
|
+
warn "Please use '#{file.ext('rb')}' instead of '#{file}'"
|
201
|
+
load file
|
63
202
|
end
|
64
203
|
end
|
65
204
|
|
66
|
-
#Load local tasks that can be used in the
|
205
|
+
#Load local tasks that can be used in the Buildfile.
|
67
206
|
Dir["#{Dir.pwd}/tasks/*.rake"].each do |file|
|
68
207
|
unless $LOADED_FEATURES.include?(file)
|
69
208
|
load file
|