buildr 1.3.5-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,195 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'buildr/java/pom'
|
18
|
+
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
module Generate #:nodoc:
|
22
|
+
|
23
|
+
task 'generate' do
|
24
|
+
script = nil
|
25
|
+
choose do |menu|
|
26
|
+
menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
|
27
|
+
|
28
|
+
menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom('pom.xml').join("\n") } if File.exists?("pom.xml")
|
29
|
+
menu.choice("From directory structure") { script = Generate.from_directory(Dir.pwd).join("\n") }
|
30
|
+
menu.choice("Skip") { }
|
31
|
+
end
|
32
|
+
|
33
|
+
if script
|
34
|
+
buildfile = File.expand_path(Buildr::Application::DEFAULT_BUILDFILES.first)
|
35
|
+
File.open(buildfile, "w") { |file| file.write script }
|
36
|
+
puts "Created #{buildfile}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class << self
|
41
|
+
|
42
|
+
HEADER = "# Generated by Buildr #{Buildr::VERSION}, change to your liking\n\n"
|
43
|
+
|
44
|
+
def from_directory(path = Dir.pwd, root = true)
|
45
|
+
Dir.chdir(path) do
|
46
|
+
name = File.basename(path)
|
47
|
+
if root
|
48
|
+
script = HEADER.split("\n")
|
49
|
+
header = <<-EOF
|
50
|
+
# Version number for this release
|
51
|
+
VERSION_NUMBER = "1.0.0"
|
52
|
+
# Group identifier for your projects
|
53
|
+
GROUP = "#{name}"
|
54
|
+
COPYRIGHT = ""
|
55
|
+
|
56
|
+
# Specify Maven 2.0 remote repositories here, like this:
|
57
|
+
repositories.remote << "http://www.ibiblio.org/maven2/"
|
58
|
+
|
59
|
+
desc "The #{name.capitalize} project"
|
60
|
+
define "#{name}" do
|
61
|
+
|
62
|
+
project.version = VERSION_NUMBER
|
63
|
+
project.group = GROUP
|
64
|
+
manifest["Implementation-Vendor"] = COPYRIGHT
|
65
|
+
EOF
|
66
|
+
script += header.split("\n")
|
67
|
+
else
|
68
|
+
script = [ %{define "#{name}" do} ]
|
69
|
+
end
|
70
|
+
script << " compile.with # Add classpath dependencies" if File.exist?("src/main/java")
|
71
|
+
script << " resources" if File.exist?("src/main/resources")
|
72
|
+
script << " test.compile.with # Add classpath dependencies" if File.exist?("src/test/java")
|
73
|
+
script << " test.resources" if File.exist?("src/test/resources")
|
74
|
+
if File.exist?("src/main/webapp")
|
75
|
+
script << " package(:war)"
|
76
|
+
elsif File.exist?("src/main/java")
|
77
|
+
script << " package(:jar)"
|
78
|
+
end
|
79
|
+
dirs = FileList["*"].exclude("src", "target", "report").
|
80
|
+
select { |file| File.directory?(file) && File.exist?(File.join(file, "src")) }
|
81
|
+
unless dirs.empty?
|
82
|
+
script << ""
|
83
|
+
dirs.sort.each do |dir|
|
84
|
+
script << from_directory(dir, false).flatten.map { |line| " " + line } << ""
|
85
|
+
end
|
86
|
+
end
|
87
|
+
script << "end"
|
88
|
+
script.flatten
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def from_maven2_pom(path = 'pom.xml', root = true)
|
93
|
+
pom = Buildr::POM.load(path)
|
94
|
+
project = pom.project
|
95
|
+
|
96
|
+
artifactId = project['artifactId'].first
|
97
|
+
description = project['name'] || "The #{artifactId} project"
|
98
|
+
project_name = File.basename(Dir.pwd)
|
99
|
+
|
100
|
+
if root
|
101
|
+
script = HEADER.split("\n")
|
102
|
+
|
103
|
+
settings_file = ENV["M2_SETTINGS"] || File.join(ENV['HOME'], ".m2/settings.xml")
|
104
|
+
settings = XmlSimple.xml_in(IO.read(settings_file)) if File.exists?(settings_file)
|
105
|
+
|
106
|
+
if settings
|
107
|
+
proxy = settings['proxies'].first['proxy'].find { |proxy|
|
108
|
+
proxy["active"].nil? || proxy["active"].to_s =~ /true/
|
109
|
+
} rescue nil
|
110
|
+
|
111
|
+
if proxy
|
112
|
+
url = %{#{proxy["protocol"].first}://#{proxy["host"].first}:#{proxy["port"].first}}
|
113
|
+
exclude = proxy["nonProxyHosts"].to_s.gsub("|", ",") if proxy["nonProxyHosts"]
|
114
|
+
script << "options.proxy.http = '#{url}'"
|
115
|
+
script << "options.proxy.exclude << '#{exclude}'" if exclude
|
116
|
+
script << ''
|
117
|
+
# In addition, we need to use said proxies to download artifacts.
|
118
|
+
Buildr.options.proxy.http = url
|
119
|
+
Buildr.options.proxy.exclude << exclude if exclude
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
repositories = project["repositories"].first["repository"].select { |repository|
|
124
|
+
legacy = repository["layout"].to_s =~ /legacy/
|
125
|
+
!legacy
|
126
|
+
} rescue nil
|
127
|
+
repositories = [{"name" => "Standard maven2 repository", "url" => "http://www.ibiblio.org/maven2"}] if repositories.nil? || repositories.empty?
|
128
|
+
repositories.each do |repository|
|
129
|
+
name, url = repository["name"], repository["url"]
|
130
|
+
script << "# #{name}"
|
131
|
+
script << "repositories.remote << '#{url}'"
|
132
|
+
# In addition we need to use said repositores to download artifacts.
|
133
|
+
Buildr.repositories.remote << url.to_s
|
134
|
+
end
|
135
|
+
script << ""
|
136
|
+
else
|
137
|
+
script = []
|
138
|
+
end
|
139
|
+
|
140
|
+
script << "desc '#{description}'"
|
141
|
+
script << "define '#{project_name}' do"
|
142
|
+
|
143
|
+
groupId = project['groupId']
|
144
|
+
script << " project.group = '#{groupId}'" if groupId
|
145
|
+
|
146
|
+
version = project['version']
|
147
|
+
script << " project.version = '#{version}'" if version
|
148
|
+
|
149
|
+
#get plugins configurations
|
150
|
+
plugins = project['build'].first['plugins'].first['plugin'] rescue {}
|
151
|
+
if plugins
|
152
|
+
compile_plugin = plugins.find{|pl| (pl['groupId'].nil? or pl['groupId'].first == 'org.apache.maven.plugins') and pl['artifactId'].first == 'maven-compiler-plugin'}
|
153
|
+
if compile_plugin
|
154
|
+
source = compile_plugin.first['configuration'].first['source'] rescue nil
|
155
|
+
target = compile_plugin.first['configuration'].first['target'] rescue nil
|
156
|
+
|
157
|
+
script << " compile.options.source = '#{source}'" if source
|
158
|
+
script << " compile.options.target = '#{target}'" if target
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
compile_dependencies = pom.dependencies
|
163
|
+
dependencies = compile_dependencies.sort.map{|d| "'#{d}'"}.join(', ')
|
164
|
+
script << " compile.with #{dependencies}" unless dependencies.empty?
|
165
|
+
|
166
|
+
test_dependencies = (pom.dependencies(['test']) - compile_dependencies).reject{|d| d =~ /^junit:junit:jar:/ }
|
167
|
+
#check if we have testng
|
168
|
+
use_testng = test_dependencies.find{|d| d =~ /^org.testng:testng:jar:/}
|
169
|
+
if use_testng
|
170
|
+
script << " test.using :testng"
|
171
|
+
test_dependencies = pom.dependencies(['test']).reject{|d| d =~ /^org.testng:testng:jar:/ }
|
172
|
+
end
|
173
|
+
|
174
|
+
test_dependencies = test_dependencies.sort.map{|d| "'#{d}'"}.join(', ')
|
175
|
+
script << " test.with #{test_dependencies}" unless test_dependencies.empty?
|
176
|
+
|
177
|
+
packaging = project['packaging'] ? project['packaging'].first : 'jar'
|
178
|
+
if %w(jar war).include?(packaging)
|
179
|
+
script << " package :#{packaging}, :id => '#{artifactId}'"
|
180
|
+
end
|
181
|
+
|
182
|
+
modules = project['modules'].first['module'] rescue nil
|
183
|
+
if modules
|
184
|
+
script << ""
|
185
|
+
modules.each do |mod|
|
186
|
+
script << from_maven2_pom(File.join(File.dirname(path), mod, 'pom.xml'), false).flatten.map { |line| " " + line } << ""
|
187
|
+
end
|
188
|
+
end
|
189
|
+
script << "end"
|
190
|
+
script.flatten
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'buildr/core/common'
|
18
|
+
require 'buildr/core/project'
|
19
|
+
|
20
|
+
|
21
|
+
module Buildr
|
22
|
+
|
23
|
+
module Help #:nodoc:
|
24
|
+
class << self
|
25
|
+
|
26
|
+
def <<(arg)
|
27
|
+
if arg.respond_to?(:call)
|
28
|
+
texters << arg
|
29
|
+
else
|
30
|
+
texters << lambda { arg }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
texters.map(&:call).join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
def texters
|
40
|
+
@texters ||= []
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class << self
|
47
|
+
def help(&block)
|
48
|
+
Help << block if block_given?
|
49
|
+
Help
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
task 'help' do
|
57
|
+
# Greeater.
|
58
|
+
puts 'Usage:'
|
59
|
+
puts ' buildr [-f rakefile] {options} targets...'
|
60
|
+
puts
|
61
|
+
|
62
|
+
# Show only the top-level projects.
|
63
|
+
projects.reject(&:parent).tap do |top_level|
|
64
|
+
unless top_level.empty?
|
65
|
+
puts 'Top-level projects (buildr help:projects for full list):'
|
66
|
+
width = [top_level.map(&:name).map(&:size), 20].flatten.max
|
67
|
+
top_level.each do |project|
|
68
|
+
puts project.comment.to_s.empty? ? project.name : (" %-#{width}s # %s" % [project.name, project.comment])
|
69
|
+
end
|
70
|
+
puts
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Show all the top-level tasks, excluding projects.
|
75
|
+
puts 'Common tasks:'
|
76
|
+
task('help:tasks').invoke
|
77
|
+
puts
|
78
|
+
puts 'For help on command line options:'
|
79
|
+
puts ' buildr --help'
|
80
|
+
puts Buildr.help.to_s
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
module Buildr
|
85
|
+
|
86
|
+
# :call-seq:
|
87
|
+
# help() { ... }
|
88
|
+
#
|
89
|
+
# Use this to enhance the help task, e.g. to print some important information about your build,
|
90
|
+
# configuration options, build instructions, etc.
|
91
|
+
def help(&block)
|
92
|
+
Buildr.help << block
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
namespace 'help' do
|
99
|
+
|
100
|
+
desc 'List all projects defined by this buildfile'
|
101
|
+
task 'projects' do
|
102
|
+
width = projects.map(&:name).map(&:size).max
|
103
|
+
projects.each do |project|
|
104
|
+
puts project.comment.to_s.empty? ? " #{project.name}" : (" %-#{width}s # %s" % [project.name, project.comment])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
desc 'List all tasks available from this buildfile'
|
109
|
+
task 'tasks' do
|
110
|
+
Buildr.application.tasks.select(&:comment).reject { |task| Project === task }.tap do |tasks|
|
111
|
+
width = [tasks.map(&:name).map(&:size), 20].flatten.max
|
112
|
+
tasks.each do |task|
|
113
|
+
printf " %-#{width}s # %s\n", task.name, task.comment
|
114
|
+
end
|
115
|
+
puts
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
# Let's see if we can use Growl. Must be running from console in verbose mode.
|
18
|
+
if $stdout.isatty && verbose
|
19
|
+
notify = lambda do |type, title, message|
|
20
|
+
begin
|
21
|
+
# Loading Ruby Cocoa can slow the build down (hooks on Object class), so we're
|
22
|
+
# saving the best for last and only requiring it at the very end.
|
23
|
+
require 'osx/cocoa'
|
24
|
+
icon = OSX::NSApplication.sharedApplication.applicationIconImage
|
25
|
+
icon = OSX::NSImage.alloc.initWithContentsOfFile(File.join(File.dirname(__FILE__), '../resources/buildr.icns'))
|
26
|
+
|
27
|
+
# Register with Growl, that way you can turn notifications on/off from system preferences.
|
28
|
+
OSX::NSDistributedNotificationCenter.defaultCenter.
|
29
|
+
postNotificationName_object_userInfo_deliverImmediately(:GrowlApplicationRegistrationNotification, nil,
|
30
|
+
{ :ApplicationName=>'Buildr', :AllNotifications=>['Completed', 'Failed'],
|
31
|
+
:ApplicationIcon=>icon.TIFFRepresentation }, true)
|
32
|
+
|
33
|
+
OSX::NSDistributedNotificationCenter.defaultCenter.
|
34
|
+
postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil,
|
35
|
+
{ :ApplicationName=>'Buildr', :NotificationName=>type,
|
36
|
+
:NotificationTitle=>title, :NotificationDescription=>message }, true)
|
37
|
+
rescue Exception
|
38
|
+
# We get here in two cases: system doesn't have Growl installed so one of the OSX
|
39
|
+
# calls raises an exception; system doesn't have osx/cocoa, e.g. MacPorts Ruby 1.9,
|
40
|
+
# so we also need to rescue LoadError.
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Buildr.application.on_completion { |title, message| notify['Completed', title, message] if verbose }
|
45
|
+
Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] if verbose }
|
46
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
class ProgressBar
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
def start(args, &block)
|
22
|
+
new(args).start &block
|
23
|
+
end
|
24
|
+
|
25
|
+
def width
|
26
|
+
@width ||= $terminal.output_cols || 80
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(args = {})
|
32
|
+
@title = args[:title] || ''
|
33
|
+
@total = args[:total] || 0
|
34
|
+
@mark = args[:mark] || '.'
|
35
|
+
@format = args[:format] || default_format
|
36
|
+
@output = args[:output] || $stderr unless args[:hidden] || !$stdout.isatty
|
37
|
+
clear
|
38
|
+
end
|
39
|
+
|
40
|
+
def start
|
41
|
+
@start = @last_time = Time.now
|
42
|
+
@count = 0
|
43
|
+
@finished = false
|
44
|
+
render
|
45
|
+
if block_given?
|
46
|
+
result = yield(self) if block_given?
|
47
|
+
finish
|
48
|
+
result
|
49
|
+
else
|
50
|
+
self
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def inc(count)
|
55
|
+
set @count + count
|
56
|
+
end
|
57
|
+
|
58
|
+
def <<(bytes)
|
59
|
+
inc bytes.size
|
60
|
+
end
|
61
|
+
|
62
|
+
def set(count)
|
63
|
+
@count = [count, 0].max
|
64
|
+
@count = [count, @total].min unless @total == 0
|
65
|
+
render if changed?
|
66
|
+
end
|
67
|
+
|
68
|
+
def title
|
69
|
+
@title.size > ProgressBar.width / 5 ? (@title[0, ProgressBar.width / 5 - 2] + '..') : @title
|
70
|
+
end
|
71
|
+
|
72
|
+
def count
|
73
|
+
human(@count)
|
74
|
+
end
|
75
|
+
|
76
|
+
def total
|
77
|
+
human(@total)
|
78
|
+
end
|
79
|
+
|
80
|
+
def percentage
|
81
|
+
'%3d%%' % (@total == 0 ? 100 : (@count * 100 / @total))
|
82
|
+
end
|
83
|
+
|
84
|
+
def time
|
85
|
+
@finished ? elapsed : eta
|
86
|
+
end
|
87
|
+
|
88
|
+
def eta
|
89
|
+
return 'ETA: --:--:--' if @count == 0
|
90
|
+
elapsed = Time.now - @start
|
91
|
+
eta = elapsed * @total / @count - elapsed
|
92
|
+
'ETA: %s' % duration(eta.ceil)
|
93
|
+
end
|
94
|
+
|
95
|
+
def elapsed
|
96
|
+
'Time: %s' % duration(Time.now - @start)
|
97
|
+
end
|
98
|
+
|
99
|
+
def rate
|
100
|
+
'%s/s' % human(@count / (Time.now - @start))
|
101
|
+
end
|
102
|
+
|
103
|
+
def progress(width)
|
104
|
+
width -= 2
|
105
|
+
marks = @total == 0 ? width : (@count * width / @total)
|
106
|
+
"|%-#{width}s|" % (@mark * marks)
|
107
|
+
end
|
108
|
+
|
109
|
+
def human(bytes)
|
110
|
+
magnitude = (0..3).find { |i| bytes < (1024 << i * 10) } || 3
|
111
|
+
return '%dB' % bytes if magnitude == 0
|
112
|
+
return '%.1f%s' % [ bytes.to_f / (1 << magnitude * 10), [nil, 'KB', 'MB', 'GB'][magnitude] ]
|
113
|
+
end
|
114
|
+
|
115
|
+
def duration(seconds)
|
116
|
+
'%02d:%02d:%02d' % [seconds / 3600, (seconds / 60) % 60, seconds % 60]
|
117
|
+
end
|
118
|
+
|
119
|
+
def finish
|
120
|
+
unless @finished
|
121
|
+
@finished = true
|
122
|
+
render
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
protected
|
127
|
+
|
128
|
+
def clear
|
129
|
+
return unless @output
|
130
|
+
@output.print "\r", " " * (ProgressBar.width - 1), "\r"
|
131
|
+
@output.flush
|
132
|
+
end
|
133
|
+
|
134
|
+
def render
|
135
|
+
return unless @output
|
136
|
+
format, *args = @format
|
137
|
+
line = format % args.map { |arg| send(arg) }
|
138
|
+
@output.print line.sub('|--|') { progress(ProgressBar.width - line.size + 3) }
|
139
|
+
@output.print @finished ? "\n" : "\r"
|
140
|
+
@output.flush
|
141
|
+
@previous = @count
|
142
|
+
@last_time = Time.now
|
143
|
+
end
|
144
|
+
|
145
|
+
def changed?
|
146
|
+
return false unless @output && Time.now - @last_time > 0.1
|
147
|
+
return human(@count) != human(@previous) if @total == 0
|
148
|
+
return true if (@count - @previous) >= @total / 100
|
149
|
+
return Time.now - @last_time > 1
|
150
|
+
end
|
151
|
+
|
152
|
+
def default_format
|
153
|
+
@total == 0 ? ['%s %8s %s', :title, :count, :elapsed] : ['%s: %s |--| %8s/%s %s', :title, :percentage, :count, :total, :time]
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|