buildr 1.4.25 → 1.5.0.dev2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +50 -0
- data/NOTICE +1 -1
- data/README.rdoc +1 -1
- data/addon/buildr/bnd.rb +0 -6
- data/addon/buildr/custom_pom.rb +6 -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/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/wsgen.rb +27 -27
- data/buildr.buildfile +1 -1
- data/buildr.gemspec +13 -9
- data/doc/_config.yml +3 -1
- data/doc/_layouts/default.html +1 -1
- data/doc/artifacts.textile +42 -0
- data/doc/download.textile +18 -6
- data/doc/languages.textile +15 -1
- data/doc/packaging.textile +1 -1
- data/doc/preface.textile +1 -1
- data/doc/projects.textile +13 -0
- data/doc/releasing.textile +14 -0
- data/doc/settings_profiles.textile +4 -0
- data/lib/buildr.rb +1 -0
- data/lib/buildr/core/application.rb +2 -3
- data/lib/buildr/core/build.rb +21 -34
- data/lib/buildr/core/compile.rb +0 -12
- data/lib/buildr/core/filter.rb +7 -0
- data/lib/buildr/core/generate.rb +1 -0
- data/lib/buildr/core/project.rb +14 -4
- data/lib/buildr/core/test.rb +2 -4
- data/lib/buildr/core/transports.rb +2 -0
- data/lib/buildr/groovy/bdd.rb +0 -7
- data/lib/buildr/ide/eclipse.rb +3 -3
- data/lib/buildr/java/ant.rb +0 -6
- data/lib/buildr/java/bdd.rb +0 -7
- data/lib/buildr/java/commands.rb +1 -1
- data/lib/buildr/java/deprecated.rb +0 -60
- data/lib/buildr/java/ecj.rb +16 -3
- data/lib/buildr/java/jruby.rb +19 -1
- data/lib/buildr/java/packaging.rb +4 -8
- data/lib/buildr/java/pom.rb +17 -12
- data/lib/buildr/java/rjb.rb +21 -3
- data/lib/buildr/java/tests.rb +0 -21
- data/lib/buildr/packaging/archive.rb +1 -1
- data/lib/buildr/packaging/artifact.rb +132 -3
- data/lib/buildr/packaging/zip.rb +32 -29
- data/lib/buildr/packaging/ziptask.rb +7 -5
- data/lib/buildr/scala.rb +0 -1
- data/lib/buildr/scala/bdd.rb +28 -122
- data/lib/buildr/scala/compiler.rb +24 -10
- data/lib/buildr/scala/doc.rb +0 -1
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +4 -3
- data/lib/buildr/scala/org/apache/buildr/ZincRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/ZincRunner.java +37 -0
- data/lib/buildr/scala/tests.rb +18 -26
- data/lib/buildr/version.rb +1 -1
- data/spec/addon/bnd_spec.rb +5 -5
- data/spec/addon/custom_pom_spec.rb +38 -32
- data/spec/addon/jaxb_xjc_spec.rb +0 -4
- data/spec/core/application_spec.rb +4 -5
- data/spec/core/build_spec.rb +10 -51
- data/spec/core/common_spec.rb +7 -0
- data/spec/core/compile_spec.rb +0 -6
- data/spec/core/console_spec.rb +1 -1
- data/spec/core/generate_from_eclipse_spec.rb +22 -8
- data/spec/core/project_spec.rb +34 -70
- data/spec/core/test_spec.rb +6 -9
- data/spec/core/transport_spec.rb +16 -7
- data/spec/groovy/compiler_spec.rb +2 -2
- data/spec/java/ant_spec.rb +0 -5
- data/spec/java/compiler_spec.rb +4 -4
- data/spec/java/ecj_spec.rb +244 -45
- data/spec/java/java_spec.rb +7 -9
- data/spec/java/packaging_spec.rb +23 -23
- data/spec/java/pom_spec.rb +37 -0
- data/spec/java/tests_spec.rb +0 -5
- data/spec/packaging/archive_spec.rb +1 -1
- data/spec/packaging/artifact_spec.rb +129 -7
- data/spec/packaging/packaging_spec.rb +1 -1
- data/spec/sandbox.rb +2 -2
- data/spec/scala/bdd_spec.rb +0 -101
- data/spec/scala/compiler_spec.rb +20 -16
- data/spec/scala/doc_spec.rb +0 -11
- data/spec/scala/tests_spec.rb +6 -15
- data/spec/spec_helpers.rb +1 -1
- data/spec/xpath_matchers.rb +2 -1
- metadata +64 -22
- data/addon/buildr/cobertura.rb +0 -21
- data/addon/buildr/emma.rb +0 -21
data/lib/buildr/java/ecj.rb
CHANGED
@@ -17,6 +17,20 @@ module Buildr #:nodoc:
|
|
17
17
|
module Compiler #:nodoc:
|
18
18
|
|
19
19
|
class Ecj < Javac
|
20
|
+
|
21
|
+
VERSION = "4.5.1"
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# Current version of ECJ being used.
|
25
|
+
def version
|
26
|
+
Buildr.settings.build['ecj'] || VERSION
|
27
|
+
end
|
28
|
+
|
29
|
+
# ECJ classpath dependencies.
|
30
|
+
def dependencies
|
31
|
+
@dependencies ||= ["org.eclipse.jdt.core.compiler:ecj:jar:#{version}"]
|
32
|
+
end
|
33
|
+
end
|
20
34
|
|
21
35
|
OPTIONS = Buildr::Compiler::Javac::OPTIONS
|
22
36
|
|
@@ -64,6 +78,5 @@ module Buildr #:nodoc:
|
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
67
|
-
Java.classpath <<
|
68
|
-
|
69
|
-
Buildr::Compiler.compilers.unshift Buildr::Compiler::Ecj
|
81
|
+
Java.classpath << lambda { Buildr::Compiler::Ecj.dependencies }
|
82
|
+
Buildr::Compiler.compilers << Buildr::Compiler::Ecj
|
data/lib/buildr/java/jruby.rb
CHANGED
@@ -72,7 +72,25 @@ module Java
|
|
72
72
|
# For example, Ant is loaded as follows:
|
73
73
|
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
74
74
|
def classpath
|
75
|
-
@classpath ||=
|
75
|
+
@classpath ||= begin
|
76
|
+
classpath = []
|
77
|
+
class << classpath
|
78
|
+
|
79
|
+
def new_add(*args)
|
80
|
+
warn 'Java is already loaded' if Java.loaded?
|
81
|
+
send(:old_add, *args)
|
82
|
+
end
|
83
|
+
|
84
|
+
alias_method :old_add, :<<
|
85
|
+
alias_method :<<, :new_add
|
86
|
+
end
|
87
|
+
classpath
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns true if the JVM is loaded with all the libraries loaded on the classpath.
|
92
|
+
def loaded?
|
93
|
+
@loaded
|
76
94
|
end
|
77
95
|
|
78
96
|
# Most platforms requires tools.jar to be on the classpath, tools.jar contains the
|
@@ -52,12 +52,8 @@ module Buildr #:nodoc:
|
|
52
52
|
#
|
53
53
|
# Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
|
54
54
|
def from_zip(file)
|
55
|
-
Zip::
|
56
|
-
|
57
|
-
if entry.name == 'META-INF/MANIFEST.MF'
|
58
|
-
return Manifest.parse zip.read
|
59
|
-
end
|
60
|
-
end
|
55
|
+
Zip::File.open(file.to_s) do |zip|
|
56
|
+
return Manifest.parse zip.read('META-INF/MANIFEST.MF') if zip.find_entry('META-INF/MANIFEST.MF')
|
61
57
|
end
|
62
58
|
Manifest.new
|
63
59
|
end
|
@@ -71,7 +67,7 @@ module Buildr #:nodoc:
|
|
71
67
|
def update_manifest(file)
|
72
68
|
manifest = from_zip(file)
|
73
69
|
result = yield manifest
|
74
|
-
Zip::
|
70
|
+
Zip::File.open(file.to_s) do |zip|
|
75
71
|
zip.get_output_stream('META-INF/MANIFEST.MF') do |out|
|
76
72
|
out.write manifest.to_s
|
77
73
|
out.write "\n"
|
@@ -469,7 +465,7 @@ module Buildr #:nodoc:
|
|
469
465
|
Manifest.update_manifest(task) do |manifest|
|
470
466
|
class_path = manifest.main['Class-Path'].to_s.split
|
471
467
|
included_libs = class_path.map { |fn| fn.pathmap('%f') }
|
472
|
-
Zip::
|
468
|
+
Zip::File.foreach(task.to_s) do |entry|
|
473
469
|
included_libs << entry.name.pathmap('%f') if entry.file? && entry.name =~ /^WEB-INF\/lib\/[^\/]+$/
|
474
470
|
end
|
475
471
|
# Include all other libraries in the classpath.
|
data/lib/buildr/java/pom.rb
CHANGED
@@ -17,10 +17,10 @@
|
|
17
17
|
module Buildr
|
18
18
|
class POM
|
19
19
|
|
20
|
-
POM_TO_SPEC_MAP = { :group=>
|
21
|
-
:version=>
|
22
|
-
SCOPES_TRANSITIVE = [nil,
|
23
|
-
SCOPES_WE_USE = SCOPES_TRANSITIVE + [
|
20
|
+
POM_TO_SPEC_MAP = { :group=> 'groupId', :id=> 'artifactId', :type=> 'type',
|
21
|
+
:version=> 'version', :classifier=> 'classifier', :scope=> 'scope'}
|
22
|
+
SCOPES_TRANSITIVE = [nil, 'compile', 'runtime']
|
23
|
+
SCOPES_WE_USE = SCOPES_TRANSITIVE + ['provided']
|
24
24
|
|
25
25
|
# POM project as Hash (using XmlSimple).
|
26
26
|
attr_reader :project
|
@@ -57,7 +57,7 @@ module Buildr
|
|
57
57
|
end
|
58
58
|
pom
|
59
59
|
else
|
60
|
-
raise ArgumentError,
|
60
|
+
raise ArgumentError, 'Expecting Hash spec, Artifact, file name or file task'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -92,9 +92,9 @@ module Buildr
|
|
92
92
|
# try to cache dependencies also
|
93
93
|
@depends_for_scopes ||= {}
|
94
94
|
unless depends = @depends_for_scopes[options]
|
95
|
-
declared = project[
|
95
|
+
declared = project['dependencies'].first['dependency'] rescue nil
|
96
96
|
depends = (declared || [])
|
97
|
-
depends = depends.reject { |dep| value_of(dep[
|
97
|
+
depends = depends.reject { |dep| value_of(dep['optional']) =~ /true/ } unless options[:optional]
|
98
98
|
depends = depends.map { |dep|
|
99
99
|
spec = pom_to_hash(dep, properties)
|
100
100
|
apply = managed(spec)
|
@@ -106,7 +106,7 @@ module Buildr
|
|
106
106
|
if options[:scopes].include?(spec[:scope])
|
107
107
|
spec.delete(:scope)
|
108
108
|
|
109
|
-
exclusions = dep[
|
109
|
+
exclusions = dep['exclusions'].first['exclusion'] rescue nil
|
110
110
|
transitive_deps = POM.load(spec).dependencies(:exclusions => exclusions, :scopes => (options[:scopes_transitive] || SCOPES_TRANSITIVE) ) rescue []
|
111
111
|
|
112
112
|
[Artifact.to_spec(spec)] + transitive_deps
|
@@ -124,12 +124,17 @@ module Buildr
|
|
124
124
|
# properties for groupId, artifactId, version and packaging.
|
125
125
|
def properties()
|
126
126
|
@properties ||= begin
|
127
|
-
pom =
|
127
|
+
pom = %w(groupId artifactId version packaging).inject({}) { |hash, key|
|
128
128
|
value = project[key] || (parent ? parent.project[key] : nil)
|
129
129
|
hash[key] = hash["pom.#{key}"] = hash["project.#{key}"] = value_of(value) if value
|
130
130
|
hash
|
131
131
|
}
|
132
|
-
|
132
|
+
pom = %w(groupId artifactId version).inject(pom) { |hash, key|
|
133
|
+
value = parent.project[key]
|
134
|
+
hash[key] = hash["pom.parent.#{key}"] = hash["project.parent.#{key}"] = value_of(value) if value
|
135
|
+
hash
|
136
|
+
} if parent
|
137
|
+
props = project['properties'].first rescue {}
|
133
138
|
props = props.inject({}) { |mapped, pair| mapped[pair.first] = value_of(pair.last, props) ; mapped }
|
134
139
|
(parent ? parent.properties.merge(props) : props).merge(pom)
|
135
140
|
end
|
@@ -148,7 +153,7 @@ module Buildr
|
|
148
153
|
(parent ? parent.managed(spec) : nil)
|
149
154
|
else
|
150
155
|
@managed ||= begin
|
151
|
-
managed = project[
|
156
|
+
managed = project['dependencyManagement'].first['dependencies'].first['dependency'] rescue nil
|
152
157
|
managed ? managed.map { |dep| pom_to_hash(dep, properties) } : []
|
153
158
|
end
|
154
159
|
end
|
@@ -179,7 +184,7 @@ module Buildr
|
|
179
184
|
spec[pair.first] = value_of(element[pair.last], substitute) if element[pair.last]
|
180
185
|
spec
|
181
186
|
}
|
182
|
-
{:scope =>
|
187
|
+
{:scope => 'compile', :type => 'jar'}.merge(hash)
|
183
188
|
end
|
184
189
|
|
185
190
|
end
|
data/lib/buildr/java/rjb.rb
CHANGED
@@ -65,7 +65,7 @@ ENV_JAVA = {}
|
|
65
65
|
# with a partial classpath, or before all remote repositories are listed.
|
66
66
|
# 4. Check on a clean build with empty local repository.
|
67
67
|
module Java
|
68
|
-
|
68
|
+
|
69
69
|
module Package #:nodoc:
|
70
70
|
|
71
71
|
def method_missing(sym, *args, &block)
|
@@ -78,7 +78,7 @@ module Java
|
|
78
78
|
end
|
79
79
|
|
80
80
|
class << self
|
81
|
-
|
81
|
+
|
82
82
|
# Returns the classpath, an array listing directories, JAR files and
|
83
83
|
# artifacts. Use when loading the extension to add any additional
|
84
84
|
# libraries used by that extension.
|
@@ -86,7 +86,25 @@ module Java
|
|
86
86
|
# For example, Ant is loaded as follows:
|
87
87
|
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
88
88
|
def classpath
|
89
|
-
@classpath ||=
|
89
|
+
@classpath ||= begin
|
90
|
+
classpath = []
|
91
|
+
class << classpath
|
92
|
+
|
93
|
+
def new_add(*args)
|
94
|
+
warn 'Java is already loaded' if Java.loaded?
|
95
|
+
send(:old_add, *args)
|
96
|
+
end
|
97
|
+
|
98
|
+
alias_method :old_add, :<<
|
99
|
+
alias_method :<<, :new_add
|
100
|
+
end
|
101
|
+
classpath
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns true if the JVM is loaded with all the libraries loaded on the classpath.
|
106
|
+
def loaded?
|
107
|
+
@loaded
|
90
108
|
end
|
91
109
|
|
92
110
|
# Most platforms requires tools.jar to be on the classpath, tools.jar contains the
|
data/lib/buildr/java/tests.rb
CHANGED
@@ -108,13 +108,6 @@ module Buildr #:nodoc:
|
|
108
108
|
end
|
109
109
|
@dependencies
|
110
110
|
end
|
111
|
-
|
112
|
-
private
|
113
|
-
def const_missing(const)
|
114
|
-
return super unless const == :REQUIRES # TODO: remove in 1.5
|
115
|
-
Buildr.application.deprecated 'Please use JMock.dependencies/.version instead of JMock::REQUIRES/VERSION'
|
116
|
-
dependencies
|
117
|
-
end
|
118
111
|
end
|
119
112
|
end
|
120
113
|
|
@@ -205,13 +198,6 @@ module Buildr #:nodoc:
|
|
205
198
|
def ant_taskdef #:nodoc:
|
206
199
|
"org.apache.ant:ant-junit:jar:#{Ant.version}"
|
207
200
|
end
|
208
|
-
|
209
|
-
private
|
210
|
-
def const_missing(const)
|
211
|
-
return super unless const == :REQUIRES # TODO: remove in 1.5
|
212
|
-
Buildr.application.deprecated 'Please use JUnit.dependencies/.version instead of JUnit::REQUIRES/VERSION'
|
213
|
-
dependencies
|
214
|
-
end
|
215
201
|
end
|
216
202
|
|
217
203
|
def tests(dependencies) #:nodoc:
|
@@ -308,13 +294,6 @@ module Buildr #:nodoc:
|
|
308
294
|
return ["org.testng:testng:jar:jdk15:#{version}"] + JMock.dependencies if version < "6.0"
|
309
295
|
["org.testng:testng:jar:#{version}",'com.beust:jcommander:jar:1.27'] + JMock.dependencies
|
310
296
|
end
|
311
|
-
|
312
|
-
private
|
313
|
-
def const_missing(const)
|
314
|
-
return super unless const == :REQUIRES # TODO: remove in 1.5
|
315
|
-
Buildr.application.deprecated 'Please use TestNG.dependencies/.version instead of TestNG::REQUIRES/VERSION'
|
316
|
-
dependencies
|
317
|
-
end
|
318
297
|
end
|
319
298
|
|
320
299
|
def tests(dependencies) #:nodoc:
|
@@ -292,7 +292,7 @@ module Buildr #:nodoc:
|
|
292
292
|
|
293
293
|
def expand(file_map, path)
|
294
294
|
@includes = ['*'] if @includes.empty?
|
295
|
-
Zip::
|
295
|
+
Zip::File.open(@zip_file) do |source|
|
296
296
|
source.entries.reject { |entry| entry.directory? }.each do |entry|
|
297
297
|
if @includes.any? { |pattern| File.fnmatch(pattern, entry.name) } &&
|
298
298
|
!@excludes.any? { |pattern| File.fnmatch(pattern, entry.name) }
|
@@ -35,6 +35,7 @@ module Buildr #:nodoc:
|
|
35
35
|
module ActsAsArtifact
|
36
36
|
|
37
37
|
ARTIFACT_ATTRIBUTES = [:group, :id, :type, :classifier, :version]
|
38
|
+
MAVEN_METADATA = "maven_metadata.xml"
|
38
39
|
|
39
40
|
class << self
|
40
41
|
private
|
@@ -75,6 +76,11 @@ module Buildr #:nodoc:
|
|
75
76
|
def snapshot?
|
76
77
|
version =~ /-SNAPSHOT$/
|
77
78
|
end
|
79
|
+
|
80
|
+
def final_version
|
81
|
+
return version unless snapshot?
|
82
|
+
Time.now.strftime("%Y%m%d.%H%M%S")
|
83
|
+
end
|
78
84
|
|
79
85
|
# :call-seq:
|
80
86
|
# to_spec_hash => Hash
|
@@ -151,6 +157,27 @@ module Buildr #:nodoc:
|
|
151
157
|
end
|
152
158
|
end
|
153
159
|
end
|
160
|
+
|
161
|
+
# :call-seq:
|
162
|
+
# maven_metadata_xml => string
|
163
|
+
#
|
164
|
+
# Creates Maven Metadata XML content for this artifact.
|
165
|
+
def maven_metadata_xml
|
166
|
+
xml = Builder::XmlMarkup.new(:indent=>2)
|
167
|
+
xml.instruct!
|
168
|
+
xml.metadata do
|
169
|
+
xml.groupId group
|
170
|
+
xml.artifactId id
|
171
|
+
xml.version version
|
172
|
+
xml.versioning do
|
173
|
+
xml.snapshot do
|
174
|
+
xml.timestamp final_version
|
175
|
+
xml.buildNumber 1
|
176
|
+
end
|
177
|
+
xml.lastupdated Time.now.strftime("%Y%m%d%H%M%S")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
154
181
|
|
155
182
|
def install
|
156
183
|
invoke
|
@@ -201,7 +228,7 @@ module Buildr #:nodoc:
|
|
201
228
|
uri.user = upload_to[:username] if upload_to[:username]
|
202
229
|
uri.password = upload_to[:password] if upload_to[:password]
|
203
230
|
|
204
|
-
path = group.gsub('.', '/') + "/#{id}/#{version}/#{
|
231
|
+
path = group.gsub('.', '/') + "/#{id}/#{version}/#{upload_name}"
|
205
232
|
|
206
233
|
unless task = Buildr.application.lookup(uri+path)
|
207
234
|
deps = [self]
|
@@ -212,6 +239,10 @@ module Buildr #:nodoc:
|
|
212
239
|
options = upload_to[:options] || {:permissions => upload_to[:permissions]}
|
213
240
|
info "Deploying #{to_spec}"
|
214
241
|
URI.upload uri + path, name, options
|
242
|
+
if snapshot? && pom != self
|
243
|
+
maven_metadata = group.gsub('.', '/') + "/#{id}/#{version}/#{MAVEN_METADATA}"
|
244
|
+
URI.write uri + maven_metadata, maven_metadata_xml, :permissions => upload_to[:permissions]
|
245
|
+
end
|
215
246
|
end
|
216
247
|
end
|
217
248
|
task
|
@@ -229,6 +260,16 @@ module Buildr #:nodoc:
|
|
229
260
|
def group_path
|
230
261
|
group.gsub('.', '/')
|
231
262
|
end
|
263
|
+
|
264
|
+
def upload_name
|
265
|
+
return File.basename(name) unless snapshot?
|
266
|
+
return File.basename(name).gsub(/SNAPSHOT/, "#{final_version}-1")
|
267
|
+
end
|
268
|
+
|
269
|
+
def extract_type(type)
|
270
|
+
return :jar if type == :bundle
|
271
|
+
type
|
272
|
+
end
|
232
273
|
|
233
274
|
end
|
234
275
|
|
@@ -335,7 +376,7 @@ module Buildr #:nodoc:
|
|
335
376
|
def hash_to_file_name(hash)
|
336
377
|
version = "-#{hash[:version]}" if hash[:version]
|
337
378
|
classifier = "-#{hash[:classifier]}" if hash[:classifier]
|
338
|
-
"#{hash[:id]}#{version}#{classifier}.#{hash[:type] || DEFAULT_TYPE}"
|
379
|
+
"#{hash[:id]}#{version}#{classifier}.#{extract_type(hash[:type]) || DEFAULT_TYPE}"
|
339
380
|
end
|
340
381
|
|
341
382
|
end
|
@@ -426,7 +467,7 @@ module Buildr #:nodoc:
|
|
426
467
|
# which they are returned from #remote, until successful.
|
427
468
|
def download
|
428
469
|
trace "Downloading #{to_spec}"
|
429
|
-
remote = Buildr.repositories.
|
470
|
+
remote = Buildr.repositories.remote_uri
|
430
471
|
remote = remote.each { |repo_url| repo_url.path += '/' unless repo_url.path[-1] == '/' }
|
431
472
|
fail "Unable to download #{to_spec}. No remote repositories defined." if remote.empty?
|
432
473
|
exact_success = remote.find do |repo_url|
|
@@ -623,6 +664,44 @@ module Buildr #:nodoc:
|
|
623
664
|
spec = Artifact.to_hash(spec)
|
624
665
|
File.join(local, spec[:group].split('.'), spec[:id], spec[:version], Artifact.hash_to_file_name(spec))
|
625
666
|
end
|
667
|
+
|
668
|
+
# :call-seq:
|
669
|
+
# mirrors => Array
|
670
|
+
#
|
671
|
+
# Returns an array of all the mirror repository URLs.
|
672
|
+
#
|
673
|
+
# Mirrors override remote repositories defined in the project.
|
674
|
+
# The best way is to add repositories to the user settings file under '$HOME/.buildr/settings.yaml'.
|
675
|
+
# For example:
|
676
|
+
# repositories:
|
677
|
+
# mirrors:
|
678
|
+
# - http://example.com/repository
|
679
|
+
def mirrors
|
680
|
+
unless @mirrors
|
681
|
+
@mirrors = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
|
682
|
+
repos | Array(hash['repositories'] && hash['repositories']['mirrors'])
|
683
|
+
}
|
684
|
+
end
|
685
|
+
@mirrors
|
686
|
+
end
|
687
|
+
|
688
|
+
# :call-seq:
|
689
|
+
# remote = Array
|
690
|
+
# remote = url
|
691
|
+
# remote = nil
|
692
|
+
#
|
693
|
+
# With a String argument, clears the array and set it to that single URL.
|
694
|
+
#
|
695
|
+
# With an Array argument, clears the array and set it to these specific URLs.
|
696
|
+
#
|
697
|
+
# With nil, clears the array.
|
698
|
+
def mirrors=(urls)
|
699
|
+
case urls
|
700
|
+
when nil then @mirrors = nil
|
701
|
+
when Array then @mirrors = urls.dup
|
702
|
+
else @mirrors = [urls.to_s]
|
703
|
+
end
|
704
|
+
end
|
626
705
|
|
627
706
|
# :call-seq:
|
628
707
|
# remote => Array
|
@@ -643,6 +722,10 @@ module Buildr #:nodoc:
|
|
643
722
|
# - http://example.com/repo
|
644
723
|
# - http://elsewhere.com/repo
|
645
724
|
def remote
|
725
|
+
unless mirrors.empty?
|
726
|
+
info "Remote repositories overridden by mirrors #{mirrors.map(&:to_s).join(", ")}"
|
727
|
+
mirrors
|
728
|
+
end
|
646
729
|
unless @remote
|
647
730
|
@remote = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
|
648
731
|
repos | Array(hash['repositories'] && hash['repositories']['remote'])
|
@@ -650,6 +733,52 @@ module Buildr #:nodoc:
|
|
650
733
|
end
|
651
734
|
@remote
|
652
735
|
end
|
736
|
+
|
737
|
+
# :call-seq:
|
738
|
+
# remote_uri => Array
|
739
|
+
#
|
740
|
+
# Returns an array of all the remote repositories as instances of URI
|
741
|
+
#
|
742
|
+
# Supports
|
743
|
+
# * String urls: "http://example.com/repo"
|
744
|
+
# * URI: URI.parse( "http://example.com/repo" )
|
745
|
+
# * Hash: { :url => "http://example.com/repo", :user => "user", :pass => "pass" }
|
746
|
+
#
|
747
|
+
def remote_uri
|
748
|
+
remote
|
749
|
+
|
750
|
+
uris = []
|
751
|
+
@remote.each do |repo|
|
752
|
+
case repo
|
753
|
+
when nil then
|
754
|
+
# ignore nil
|
755
|
+
when URI then
|
756
|
+
uris << repo
|
757
|
+
when Hash then
|
758
|
+
url = (repo[:url] || repo['url'] )
|
759
|
+
if url
|
760
|
+
uri = URI.parse(url)
|
761
|
+
if ( username = (repo[:username] || repo['username'] || repo[:user] || repo['user']) )
|
762
|
+
uri.user = username
|
763
|
+
end
|
764
|
+
|
765
|
+
if ( password = (repo[:password] || repo['password'] || repo[:pass] || repo['pass']) )
|
766
|
+
uri.password = password
|
767
|
+
end
|
768
|
+
uris << uri
|
769
|
+
else
|
770
|
+
fail( "Repository Hash format missing url: #{repo}" )
|
771
|
+
end
|
772
|
+
|
773
|
+
when String then
|
774
|
+
uris << URI.parse(repo)
|
775
|
+
else
|
776
|
+
fail( "Unsupported Repository format: #{repo}" )
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
uris
|
781
|
+
end
|
653
782
|
|
654
783
|
# :call-seq:
|
655
784
|
# remote = Array
|