buildr 1.2.10 → 1.3.0
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 +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- 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/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
module Buildr
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# See ArtifactNamespace#need
|
|
21
|
+
class VersionRequirement
|
|
22
|
+
|
|
23
|
+
CMP_PROCS = Gem::Requirement::OPS.dup
|
|
24
|
+
CMP_REGEX = Gem::Requirement::OP_RE.dup
|
|
25
|
+
CMP_CHARS = CMP_PROCS.keys.join
|
|
26
|
+
BOOL_CHARS = '\|\&\!'
|
|
27
|
+
VER_CHARS = '\w\.'
|
|
28
|
+
|
|
29
|
+
class << self
|
|
30
|
+
# is +str+ a version string?
|
|
31
|
+
def version?(str)
|
|
32
|
+
/^\s*[#{VER_CHARS}]+\s*$/ === str
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# is +str+ a version requirement?
|
|
36
|
+
def requirement?(str)
|
|
37
|
+
/[#{BOOL_CHARS}#{CMP_CHARS}\(\)]/ === str
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# :call-seq:
|
|
41
|
+
# VersionRequirement.create(" >1 <2 !(1.5) ") -> requirement
|
|
42
|
+
#
|
|
43
|
+
# parse the +str+ requirement
|
|
44
|
+
def create(str)
|
|
45
|
+
instance_eval normalize(str)
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
raise "Failed to parse #{str.inspect} due to: #{e}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
def requirement(req)
|
|
52
|
+
unless req =~ /^\s*(#{CMP_REGEX})?\s*([#{VER_CHARS}]+)\s*$/
|
|
53
|
+
raise "Invalid requirement string: #{req}"
|
|
54
|
+
end
|
|
55
|
+
comparator, version = $1, $2
|
|
56
|
+
version = Gem::Version.new(0).tap { |v| v.version = version }
|
|
57
|
+
VersionRequirement.new(nil, [$1, version])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def negate(vreq)
|
|
61
|
+
vreq.negative = !vreq.negative
|
|
62
|
+
vreq
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def normalize(str)
|
|
66
|
+
str = str.strip
|
|
67
|
+
if str[/[^\s\(\)#{BOOL_CHARS + VER_CHARS + CMP_CHARS}]/]
|
|
68
|
+
raise "version string #{str.inspect} contains invalid characters"
|
|
69
|
+
end
|
|
70
|
+
str.gsub!(/\s+(and|\&\&)\s+/, ' & ')
|
|
71
|
+
str.gsub!(/\s+(or|\|\|)\s+/, ' | ')
|
|
72
|
+
str.gsub!(/(^|\s*)not\s+/, ' ! ')
|
|
73
|
+
pattern = /(#{CMP_REGEX})?\s*[#{VER_CHARS}]+/
|
|
74
|
+
left_pattern = /[#{VER_CHARS}\)]$/
|
|
75
|
+
right_pattern = /^(#{pattern}|\()/
|
|
76
|
+
str = str.split.inject([]) do |ary, i|
|
|
77
|
+
ary << '&' if ary.last =~ left_pattern && i =~ right_pattern
|
|
78
|
+
ary << i
|
|
79
|
+
end
|
|
80
|
+
str = str.join(' ')
|
|
81
|
+
str.gsub!(/!([^=])?/, ' negate \1')
|
|
82
|
+
str.gsub!(pattern) do |expr|
|
|
83
|
+
case expr.strip
|
|
84
|
+
when 'not', 'negate' then 'negate '
|
|
85
|
+
else 'requirement("' + expr + '")'
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
str.gsub!(/negate\s+\(/, 'negate(')
|
|
89
|
+
str
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def initialize(op, *requirements) #:nodoc:
|
|
94
|
+
@op, @requirements = op, requirements
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Is this object a composed requirement?
|
|
98
|
+
# VersionRequirement.create('1').composed? -> false
|
|
99
|
+
# VersionRequirement.create('1 | 2').composed? -> true
|
|
100
|
+
# VersionRequirement.create('1 & 2').composed? -> true
|
|
101
|
+
def composed?
|
|
102
|
+
requirements.size > 1
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Return the last requirement on this object having an = operator.
|
|
106
|
+
def default
|
|
107
|
+
default = nil
|
|
108
|
+
requirements.reverse.find do |r|
|
|
109
|
+
if Array === r
|
|
110
|
+
if !negative && (r.first.nil? || r.first.include?('='))
|
|
111
|
+
default = r.last.to_s
|
|
112
|
+
end
|
|
113
|
+
else
|
|
114
|
+
default = r.default
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
default
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Test if this requirement can be satisfied by +version+
|
|
121
|
+
def satisfied_by?(version)
|
|
122
|
+
return false unless version
|
|
123
|
+
unless version.kind_of?(Gem::Version)
|
|
124
|
+
raise "Invalid version: #{version.inspect}" unless self.class.version?(version)
|
|
125
|
+
version = Gem::Version.new(0).tap { |v| v.version = version.strip }
|
|
126
|
+
end
|
|
127
|
+
message = op == :| ? :any? : :all?
|
|
128
|
+
result = requirements.send message do |req|
|
|
129
|
+
if Array === req
|
|
130
|
+
cmp, rv = *req
|
|
131
|
+
CMP_PROCS[cmp || '='].call(version, rv)
|
|
132
|
+
else
|
|
133
|
+
req.satisfied_by?(version)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
negative ? !result : result
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Either modify the current requirement (if it's already an or operation)
|
|
140
|
+
# or create a new requirement
|
|
141
|
+
def |(other)
|
|
142
|
+
operation(:|, other)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Either modify the current requirement (if it's already an and operation)
|
|
146
|
+
# or create a new requirement
|
|
147
|
+
def &(other)
|
|
148
|
+
operation(:&, other)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# return the parsed expression
|
|
152
|
+
def to_s
|
|
153
|
+
str = requirements.map(&:to_s).join(" " + @op.to_s + " ").to_s
|
|
154
|
+
str = "( " + str + " )" if negative || requirements.size > 1
|
|
155
|
+
str = "!" + str if negative
|
|
156
|
+
str
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
attr_accessor :negative
|
|
160
|
+
protected
|
|
161
|
+
attr_reader :requirements, :op
|
|
162
|
+
def operation(op, other)
|
|
163
|
+
@op ||= op
|
|
164
|
+
if negative == other.negative && @op == op && other.requirements.size == 1
|
|
165
|
+
@requirements << other.requirements.first
|
|
166
|
+
self
|
|
167
|
+
else
|
|
168
|
+
self.class.new(op, self, other)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end # VersionRequirement
|
|
172
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
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/packaging/zip'
|
|
18
|
+
require 'buildr/packaging/tar'
|
|
19
|
+
require 'buildr/packaging/artifact'
|
|
20
|
+
require 'buildr/packaging/package'
|
|
21
|
+
require 'buildr/packaging/gems'
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 'builder'
|
|
18
|
+
require 'buildr/core/project'
|
|
19
|
+
require 'buildr/core/transports'
|
|
20
|
+
require 'buildr/packaging/artifact_namespace'
|
|
21
|
+
|
|
4
22
|
|
|
5
23
|
module Buildr
|
|
6
24
|
|
|
7
|
-
desc
|
|
8
|
-
task
|
|
25
|
+
desc 'Download all artifacts'
|
|
26
|
+
task 'artifacts'
|
|
9
27
|
|
|
10
28
|
# Mixin with a task to make it behave like an artifact. Implemented by the packaging tasks.
|
|
11
29
|
#
|
|
@@ -42,50 +60,50 @@ module Buildr
|
|
|
42
60
|
end
|
|
43
61
|
|
|
44
62
|
# :call-seq:
|
|
45
|
-
# to_spec_hash
|
|
63
|
+
# to_spec_hash => Hash
|
|
46
64
|
#
|
|
47
65
|
# Returns the artifact specification as a hash. For example:
|
|
48
66
|
# com.example:app:jar:1.2
|
|
49
67
|
# becomes:
|
|
50
|
-
# { :group=>
|
|
51
|
-
# :id=>
|
|
68
|
+
# { :group=>'com.example',
|
|
69
|
+
# :id=>'app',
|
|
52
70
|
# :type=>:jar,
|
|
53
|
-
# :version=>
|
|
54
|
-
def to_spec_hash
|
|
71
|
+
# :version=>'1.2' }
|
|
72
|
+
def to_spec_hash
|
|
55
73
|
base = { :group=>group, :id=>id, :type=>type, :version=>version }
|
|
56
|
-
classifier
|
|
74
|
+
classifier ? base.merge(:classifier=>classifier) : base
|
|
57
75
|
end
|
|
58
76
|
alias_method :to_hash, :to_spec_hash
|
|
59
77
|
|
|
60
78
|
# :call-seq:
|
|
61
|
-
# to_spec
|
|
79
|
+
# to_spec => String
|
|
62
80
|
#
|
|
63
81
|
# Returns the artifact specification, in the structure:
|
|
64
82
|
# <group>:<artifact>:<type>:<version>
|
|
65
83
|
# or
|
|
66
84
|
# <group>:<artifact>:<type>:<classifier><:version>
|
|
67
|
-
def to_spec
|
|
68
|
-
classifier
|
|
85
|
+
def to_spec
|
|
86
|
+
classifier ? "#{group}:#{id}:#{type}:#{classifier}:#{version}" : "#{group}:#{id}:#{type}:#{version}"
|
|
69
87
|
end
|
|
70
88
|
|
|
71
89
|
# :call-seq:
|
|
72
|
-
# pom
|
|
90
|
+
# pom => Artifact
|
|
73
91
|
#
|
|
74
92
|
# Convenience method that returns a POM artifact.
|
|
75
|
-
def pom
|
|
93
|
+
def pom
|
|
76
94
|
return self if type == :pom
|
|
77
|
-
Buildr.artifact(:group=>group, :id=>id, :version=>version, :type=>:pom
|
|
95
|
+
Buildr.artifact(:group=>group, :id=>id, :version=>version, :type=>:pom)
|
|
78
96
|
end
|
|
79
97
|
|
|
80
98
|
# :call-seq:
|
|
81
|
-
# pom_xml
|
|
99
|
+
# pom_xml => string
|
|
82
100
|
#
|
|
83
101
|
# Creates POM XML for this artifact.
|
|
84
|
-
def pom_xml
|
|
102
|
+
def pom_xml
|
|
85
103
|
xml = Builder::XmlMarkup.new(:indent=>2)
|
|
86
104
|
xml.instruct!
|
|
87
105
|
xml.project do
|
|
88
|
-
xml.modelVersion
|
|
106
|
+
xml.modelVersion '4.0.0'
|
|
89
107
|
xml.groupId group
|
|
90
108
|
xml.artifactId id
|
|
91
109
|
xml.version version
|
|
@@ -93,8 +111,29 @@ module Buildr
|
|
|
93
111
|
end
|
|
94
112
|
end
|
|
95
113
|
|
|
114
|
+
def install
|
|
115
|
+
pom.install if pom && pom != self
|
|
116
|
+
invoke
|
|
117
|
+
installed = Buildr.repositories.locate(self)
|
|
118
|
+
unless installed == name # If not already in local repository.
|
|
119
|
+
verbose(Buildr.application.options.trace || false) do
|
|
120
|
+
mkpath File.dirname(installed)
|
|
121
|
+
cp name, installed
|
|
122
|
+
end
|
|
123
|
+
puts "Installed #{installed}" if verbose
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def uninstall
|
|
128
|
+
verbose(Buildr.application.options.trace || false) do
|
|
129
|
+
installed = Buildr.repositories.locate(self)
|
|
130
|
+
rm installed if File.exist?(installed)
|
|
131
|
+
pom.uninstall if pom && pom != self
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
96
135
|
# :call-seq:
|
|
97
|
-
# upload
|
|
136
|
+
# upload
|
|
98
137
|
# upload(url)
|
|
99
138
|
# upload(options)
|
|
100
139
|
#
|
|
@@ -108,18 +147,22 @@ module Buildr
|
|
|
108
147
|
# Where do we release to?
|
|
109
148
|
upload_to ||= Buildr.repositories.release_to
|
|
110
149
|
upload_to = { :url=>upload_to } unless Hash === upload_to
|
|
111
|
-
raise ArgumentError,
|
|
150
|
+
raise ArgumentError, 'Don\'t know where to upload, perhaps you forgot to set repositories.release_to' unless upload_to[:url]
|
|
151
|
+
invoke # Make sure we exist.
|
|
152
|
+
|
|
153
|
+
# Upload POM ahead of package, so we don't fail and find POM-less package (the horror!)
|
|
154
|
+
pom.upload(upload_to) if pom && pom != self
|
|
112
155
|
|
|
113
156
|
# Set the upload URI, including mandatory slash (we expect it to be the base directory).
|
|
114
157
|
# Username/password may be part of URI, or separate entities.
|
|
115
158
|
uri = URI.parse(upload_to[:url].clone)
|
|
116
|
-
uri.path = uri.path +
|
|
159
|
+
uri.path = uri.path + '/' unless uri.path[-1] == '/'
|
|
117
160
|
uri.user = upload_to[:username] if upload_to[:username]
|
|
118
161
|
uri.password = upload_to[:password] if upload_to[:password]
|
|
119
162
|
|
|
120
163
|
# Upload artifact relative to base URL, need to create path before uploading.
|
|
121
164
|
puts "Deploying #{to_spec}" if verbose
|
|
122
|
-
path = group.gsub(
|
|
165
|
+
path = group.gsub('.', '/') + "/#{id}/#{version}/#{File.basename(name)}"
|
|
123
166
|
URI.upload uri + path, name, :permissions=>upload_to[:permissions]
|
|
124
167
|
end
|
|
125
168
|
|
|
@@ -133,7 +176,7 @@ module Buildr
|
|
|
133
176
|
end
|
|
134
177
|
|
|
135
178
|
def group_path
|
|
136
|
-
group.gsub(
|
|
179
|
+
group.gsub('.', '/')
|
|
137
180
|
end
|
|
138
181
|
|
|
139
182
|
end
|
|
@@ -166,10 +209,11 @@ module Buildr
|
|
|
166
209
|
end
|
|
167
210
|
|
|
168
211
|
# :call-seq:
|
|
169
|
-
# list
|
|
212
|
+
# list => specs
|
|
170
213
|
#
|
|
171
214
|
# Returns an array of specs for all the registered artifacts. (Anything created from artifact, or package).
|
|
172
|
-
def list
|
|
215
|
+
def list
|
|
216
|
+
@artifacts ||= {}
|
|
173
217
|
@artifacts.keys
|
|
174
218
|
end
|
|
175
219
|
|
|
@@ -179,7 +223,7 @@ module Buildr
|
|
|
179
223
|
# Register an artifact task(s) for later lookup (see #lookup).
|
|
180
224
|
def register(*tasks)
|
|
181
225
|
@artifacts ||= {}
|
|
182
|
-
fail
|
|
226
|
+
fail 'You can only register an artifact task, one of the arguments is not a Task that responds to to_spec' unless
|
|
183
227
|
tasks.all? { |task| task.respond_to?(:to_spec) && task.respond_to?(:invoke) }
|
|
184
228
|
tasks.each { |task| @artifacts[task.to_spec] = task }
|
|
185
229
|
tasks
|
|
@@ -203,21 +247,21 @@ module Buildr
|
|
|
203
247
|
rake_check_options spec, :id, :group, :type, :classifier, :version
|
|
204
248
|
# Sanitize the hash and check it's valid.
|
|
205
249
|
spec = ARTIFACT_ATTRIBUTES.inject({}) { |h, k| h[k] = spec[k].to_s if spec[k] ; h }
|
|
206
|
-
fail "Missing group identifier for #{spec.inspect}"
|
|
207
|
-
fail "Missing artifact identifier for #{spec.inspect}"
|
|
208
|
-
fail "Missing version for #{spec.inspect}"
|
|
209
|
-
spec[:type] = spec[:type]
|
|
250
|
+
fail "Missing group identifier for #{spec.inspect}" unless spec[:group]
|
|
251
|
+
fail "Missing artifact identifier for #{spec.inspect}" unless spec[:id]
|
|
252
|
+
fail "Missing version for #{spec.inspect}" unless spec[:version]
|
|
253
|
+
spec[:type] = (spec[:type] || DEFAULT_TYPE).to_sym
|
|
210
254
|
spec
|
|
211
255
|
elsif String === spec
|
|
212
|
-
group, id, type, version, *rest = spec.split(
|
|
256
|
+
group, id, type, version, *rest = spec.split(':').map { |part| part.empty? ? nil : part }
|
|
213
257
|
unless rest.empty?
|
|
214
258
|
# Optional classifier comes before version.
|
|
215
259
|
classifier, version = version, rest.shift
|
|
216
|
-
fail "Expecting <
|
|
260
|
+
fail "Expecting <group:id:type:version> or <group:id:type:classifier:version>, found <#{spec}>" unless rest.empty?
|
|
217
261
|
end
|
|
218
262
|
to_hash :group=>group, :id=>id, :type=>type, :version=>version, :classifier=>classifier
|
|
219
263
|
else
|
|
220
|
-
fail
|
|
264
|
+
fail 'Expecting a String, Hash or object that responds to to_spec'
|
|
221
265
|
end
|
|
222
266
|
end
|
|
223
267
|
|
|
@@ -228,8 +272,8 @@ module Buildr
|
|
|
228
272
|
# a string, hash or any object that responds to to_spec.
|
|
229
273
|
def to_spec(hash)
|
|
230
274
|
hash = to_hash(hash) unless Hash === hash
|
|
231
|
-
version = ":#{hash[:version]}"
|
|
232
|
-
classifier = ":#{hash[:classifier]}"
|
|
275
|
+
version = ":#{hash[:version]}" if hash[:version]
|
|
276
|
+
classifier = ":#{hash[:classifier]}" if hash[:classifier]
|
|
233
277
|
"#{hash[:group]}:#{hash[:id]}:#{hash[:type] || DEFAULT_TYPE}#{classifier}#{version}"
|
|
234
278
|
end
|
|
235
279
|
|
|
@@ -238,8 +282,8 @@ module Buildr
|
|
|
238
282
|
#
|
|
239
283
|
# Convert a hash spec to a file name.
|
|
240
284
|
def hash_to_file_name(hash)
|
|
241
|
-
version = "-#{hash[:version]}"
|
|
242
|
-
classifier = "-#{hash[:classifier]}"
|
|
285
|
+
version = "-#{hash[:version]}" if hash[:version]
|
|
286
|
+
classifier = "-#{hash[:classifier]}" if hash[:classifier]
|
|
243
287
|
"#{hash[:id]}#{version}#{classifier}.#{hash[:type] || DEFAULT_TYPE}"
|
|
244
288
|
end
|
|
245
289
|
|
|
@@ -293,7 +337,7 @@ module Buildr
|
|
|
293
337
|
protected
|
|
294
338
|
|
|
295
339
|
# :call-seq:
|
|
296
|
-
# download
|
|
340
|
+
# download
|
|
297
341
|
#
|
|
298
342
|
# Downloads an artifact from one of the remote repositories, and stores it in the local
|
|
299
343
|
# repository. Accepts a String or Hash artifact specification, and returns a path to the
|
|
@@ -301,11 +345,11 @@ module Buildr
|
|
|
301
345
|
#
|
|
302
346
|
# This method attempts to download the artifact from each repository in the order in
|
|
303
347
|
# which they are returned from #remote, until successful. It always downloads the POM first.
|
|
304
|
-
def download
|
|
305
|
-
puts "Downloading #{to_spec}" if
|
|
348
|
+
def download
|
|
349
|
+
puts "Downloading #{to_spec}" if Buildr.application.options.trace
|
|
306
350
|
remote = Buildr.repositories.remote.map { |repo_url| URI === repo_url ? repo_url : URI.parse(repo_url) }
|
|
307
|
-
remote = remote.each { |repo_url| repo_url.path +=
|
|
308
|
-
fail
|
|
351
|
+
remote = remote.each { |repo_url| repo_url.path += '/' unless repo_url.path[-1] == '/' }
|
|
352
|
+
fail 'No remote repositories defined!' if remote.empty?
|
|
309
353
|
exact_success = remote.find do |repo_url|
|
|
310
354
|
begin
|
|
311
355
|
path = "#{group_path}/#{id}/#{version}/#{File.basename(name)}"
|
|
@@ -315,7 +359,7 @@ module Buildr
|
|
|
315
359
|
false
|
|
316
360
|
rescue Exception=>error
|
|
317
361
|
puts error if verbose
|
|
318
|
-
puts error.backtrace.join("\n") if
|
|
362
|
+
puts error.backtrace.join("\n") if Buildr.application.options.trace
|
|
319
363
|
false
|
|
320
364
|
end
|
|
321
365
|
end
|
|
@@ -350,8 +394,8 @@ module Buildr
|
|
|
350
394
|
metadata_xml = StringIO.new
|
|
351
395
|
URI.download repo_url + metadata_path, metadata_xml
|
|
352
396
|
metadata = REXML::Document.new(metadata_xml.string).root
|
|
353
|
-
timestamp = REXML::XPath.first(metadata,
|
|
354
|
-
build_number = REXML::XPath.first(metadata,
|
|
397
|
+
timestamp = REXML::XPath.first(metadata, '//timestamp').text
|
|
398
|
+
build_number = REXML::XPath.first(metadata, '//buildNumber').text
|
|
355
399
|
snapshot_of = version[0, version.size - 9]
|
|
356
400
|
repo_url + "#{group_path}/#{id}/#{version}/#{id}-#{snapshot_of}-#{timestamp}-#{build_number}.#{type}"
|
|
357
401
|
rescue URI::NotFoundError
|
|
@@ -369,19 +413,23 @@ module Buildr
|
|
|
369
413
|
#
|
|
370
414
|
# You can access this object from the #repositories method. For example:
|
|
371
415
|
# puts repositories.local
|
|
372
|
-
# repositories.remote <<
|
|
373
|
-
# repositories.release_to =
|
|
416
|
+
# repositories.remote << 'http://example.com/repo'
|
|
417
|
+
# repositories.release_to = 'sftp://example.com/var/www/public/repo'
|
|
374
418
|
class Repositories
|
|
375
419
|
include Singleton
|
|
376
420
|
|
|
377
421
|
# :call-seq:
|
|
378
|
-
# local
|
|
422
|
+
# local => path
|
|
379
423
|
#
|
|
380
424
|
# Returns the path to the local repository.
|
|
381
425
|
#
|
|
382
426
|
# The default path is .m2/repository relative to the home directory.
|
|
383
|
-
|
|
384
|
-
|
|
427
|
+
# You can set this using the M2_REPO environment variable or the repositories/local
|
|
428
|
+
# value in your settings.yaml file.
|
|
429
|
+
def local
|
|
430
|
+
@local ||= File.expand_path(ENV['M2_REPO'] || ENV['local_repo'] ||
|
|
431
|
+
(Buildr.settings.user['repositories'] && Buildr.settings.user['repositories']['local']) ||
|
|
432
|
+
File.join(ENV['HOME'], '.m2/repository'))
|
|
385
433
|
end
|
|
386
434
|
|
|
387
435
|
# :call-seq:
|
|
@@ -403,23 +451,38 @@ module Buildr
|
|
|
403
451
|
# a file path.
|
|
404
452
|
#
|
|
405
453
|
# For example:
|
|
406
|
-
# locate :group=>
|
|
454
|
+
# locate :group=>'log4j', :id=>'log4j', :version=>'1.1'
|
|
407
455
|
# => ~/.m2/repository/log4j/log4j/1.1/log4j-1.1.jar
|
|
408
456
|
def locate(spec)
|
|
409
457
|
spec = Artifact.to_hash(spec)
|
|
410
|
-
File.join(local, spec[:group].split(
|
|
458
|
+
File.join(local, spec[:group].split('.'), spec[:id], spec[:version], Artifact.hash_to_file_name(spec))
|
|
411
459
|
end
|
|
412
460
|
|
|
413
461
|
# :call-seq:
|
|
414
|
-
# remote
|
|
462
|
+
# remote => Array
|
|
415
463
|
#
|
|
416
464
|
# Returns an array of all the remote repository URLs.
|
|
417
465
|
#
|
|
418
466
|
# When downloading artifacts, repositories are accessed in the order in which they appear here.
|
|
419
467
|
# The best way is to add repositories individually, for example:
|
|
420
|
-
# repositories.remote <<
|
|
421
|
-
|
|
422
|
-
|
|
468
|
+
# repositories.remote << 'http://example.com/repo'
|
|
469
|
+
#
|
|
470
|
+
# You can also specify remote repositories in the settings.yaml (per user) and build.yaml (per build)
|
|
471
|
+
# files. Both sets of URLs are loaded by default into this array, URLs from the personal setting
|
|
472
|
+
# showing first.
|
|
473
|
+
#
|
|
474
|
+
# For example:
|
|
475
|
+
# repositories:
|
|
476
|
+
# remote:
|
|
477
|
+
# - http://example.com/repo
|
|
478
|
+
# - http://elsewhere.com/repo
|
|
479
|
+
def remote
|
|
480
|
+
unless @remote
|
|
481
|
+
@remote = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
|
|
482
|
+
repos | Array(hash['repositories'] && hash['repositories']['remote'])
|
|
483
|
+
}
|
|
484
|
+
end
|
|
485
|
+
@remote
|
|
423
486
|
end
|
|
424
487
|
|
|
425
488
|
# :call-seq:
|
|
@@ -434,55 +497,10 @@ module Buildr
|
|
|
434
497
|
# With nil, clears the array.
|
|
435
498
|
def remote=(urls)
|
|
436
499
|
case urls
|
|
437
|
-
when nil
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
@remote = urls.dup
|
|
441
|
-
else
|
|
442
|
-
@remote = [urls.to_s]
|
|
443
|
-
end
|
|
444
|
-
end
|
|
445
|
-
|
|
446
|
-
# *Deprecated* Please use options.proxy.http instead of repositories.proxy.
|
|
447
|
-
def proxy()
|
|
448
|
-
warn_deprecated "Please use options.proxy.http instead of repositories.proxy"
|
|
449
|
-
Buildr.options.proxy.http
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
# *Deprecated* Please use options.proxy.http = <url> instead of repositories.proxy.
|
|
453
|
-
def proxy=(proxy)
|
|
454
|
-
warn_deprecated "Please use options.proxy.http = <url> instead of repositories.proxy"
|
|
455
|
-
Buildr.options.proxy.http = proxy
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
# *Deprecated* Just create an artifact and invoke it.
|
|
459
|
-
def download(spec)
|
|
460
|
-
warn_deprecated "Just create and artifact and invoke it."
|
|
461
|
-
spec = Artifact.to_hash(spec) unless Hash === spec
|
|
462
|
-
filename = locate(spec)
|
|
463
|
-
|
|
464
|
-
puts "Downloading #{Artifact.to_spec(spec)}" if Rake.application.options.trace
|
|
465
|
-
return filename if remote.any? do |repo_url|
|
|
466
|
-
repo_url = URI.parse(repo_url) unless URI === repo_url
|
|
467
|
-
repo_url.path += "/" unless repo_url.path[-1] == "/"
|
|
468
|
-
begin
|
|
469
|
-
path = spec[:group].gsub(".", "/") +
|
|
470
|
-
"/#{spec[:id]}/#{spec[:version]}/#{Artifact.hash_to_file_name(spec)}"
|
|
471
|
-
mkpath File.dirname(filename), :verbose=>false
|
|
472
|
-
# We absolutely need the POM, so make sure we download it before the artifact
|
|
473
|
-
# (unless the artifact is a POM).
|
|
474
|
-
URI.download repo_url + path.ext("pom"), filename.ext("pom") unless type == :pom
|
|
475
|
-
URI.download repo_url + path, filename
|
|
476
|
-
true
|
|
477
|
-
rescue URI::NotFoundError
|
|
478
|
-
false
|
|
479
|
-
rescue Exception=>error
|
|
480
|
-
puts error if verbose
|
|
481
|
-
puts error.backtrace.join("\n") if Rake.application.options.trace
|
|
482
|
-
false
|
|
483
|
-
end
|
|
500
|
+
when nil then @remote = nil
|
|
501
|
+
when Array then @remote = urls.dup
|
|
502
|
+
else @remote = [urls.to_s]
|
|
484
503
|
end
|
|
485
|
-
fail "Failed to download #{Artifact.to_spec(spec)}, tried the following repositories:\n#{remote.join("\n")}"
|
|
486
504
|
end
|
|
487
505
|
|
|
488
506
|
# :call-seq:
|
|
@@ -495,51 +513,53 @@ module Buildr
|
|
|
495
513
|
# Besides the URL, all other settings depend on the transport protocol in use.
|
|
496
514
|
#
|
|
497
515
|
# For example:
|
|
498
|
-
# repositories.release_to =
|
|
499
|
-
#
|
|
500
|
-
#
|
|
516
|
+
# repositories.release_to = 'sftp://john:secret@example.com/var/www/repo/'
|
|
517
|
+
#
|
|
518
|
+
# repositories.release_to = { :url=>'sftp://example.com/var/www/repo/',
|
|
519
|
+
# :username='john', :password=>'secret' }
|
|
520
|
+
# Or in the settings.yaml file:
|
|
521
|
+
# repositories:
|
|
522
|
+
# release_to: sftp://john:secret@example.com/var/www/repo/
|
|
523
|
+
#
|
|
524
|
+
# repositories:
|
|
525
|
+
# release_to:
|
|
526
|
+
# url: sftp://example.com/var/www/repo/
|
|
527
|
+
# username: john
|
|
528
|
+
# password: secret
|
|
501
529
|
def release_to=(options)
|
|
502
530
|
options = { :url=>options } unless Hash === options
|
|
503
531
|
@release_to = options
|
|
504
532
|
end
|
|
505
533
|
|
|
506
534
|
# :call-seq:
|
|
507
|
-
# release_to
|
|
535
|
+
# release_to => hash
|
|
508
536
|
#
|
|
509
537
|
# Returns the current release server setting as a Hash. This is a more convenient way to
|
|
510
538
|
# configure the settings, as it allows you to specify the settings progressively.
|
|
511
539
|
#
|
|
512
540
|
# For example, the Buildfile will contain the repository URL used by all developers:
|
|
513
|
-
# repositories.release_to[:url] ||=
|
|
541
|
+
# repositories.release_to[:url] ||= 'sftp://example.com/var/www/repo'
|
|
514
542
|
# Your private buildr.rb will contain your credentials:
|
|
515
|
-
# repositories.release_to[:username] =
|
|
516
|
-
# repositories.release_to[:password] =
|
|
517
|
-
def release_to
|
|
518
|
-
@release_to
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
warn_deprecated "Please use release_to instead."
|
|
524
|
-
self.release_to = options
|
|
525
|
-
end
|
|
526
|
-
|
|
527
|
-
# *Deprecated* See release_to.
|
|
528
|
-
def deploy_to()
|
|
529
|
-
warn_deprecated "Please use release_to instead."
|
|
530
|
-
self.release_to
|
|
543
|
+
# repositories.release_to[:username] = 'john'
|
|
544
|
+
# repositories.release_to[:password] = 'secret'
|
|
545
|
+
def release_to
|
|
546
|
+
unless @release_to
|
|
547
|
+
value = Buildr.settings.user['repositories'] && Buildr.settings.user['repositories']['release_to']
|
|
548
|
+
@release_to = Hash === value ? value.inject({}) { |hash, (key, value)| hash.update(key.to_sym=>value) } : { :url=>Array(value).first }
|
|
549
|
+
end
|
|
550
|
+
@release_to
|
|
531
551
|
end
|
|
532
552
|
|
|
533
553
|
end
|
|
534
554
|
|
|
535
555
|
# :call-seq:
|
|
536
|
-
# repositories
|
|
556
|
+
# repositories => Repositories
|
|
537
557
|
#
|
|
538
558
|
# Returns an object you can use for setting the local repository path, remote repositories
|
|
539
559
|
# URL and release server settings.
|
|
540
560
|
#
|
|
541
561
|
# See Repositories.
|
|
542
|
-
def repositories
|
|
562
|
+
def repositories
|
|
543
563
|
Repositories.instance
|
|
544
564
|
end
|
|
545
565
|
|
|
@@ -558,20 +578,21 @@ module Buildr
|
|
|
558
578
|
# a different way of creating the artifact in the local repository. See Artifact for more details.
|
|
559
579
|
#
|
|
560
580
|
# For example, to specify an artifact:
|
|
561
|
-
# artifact(
|
|
581
|
+
# artifact('log4j:log4j:jar:1.1')
|
|
562
582
|
#
|
|
563
583
|
# To use the artifact in a task:
|
|
564
|
-
# compile.with artifact(
|
|
584
|
+
# compile.with artifact('log4j:log4j:jar:1.1')
|
|
565
585
|
#
|
|
566
586
|
# To specify an artifact and the means for creating it:
|
|
567
|
-
# download(artifact(
|
|
568
|
-
#
|
|
587
|
+
# download(artifact('dojo:dojo-widget:zip:2.0')=>
|
|
588
|
+
# 'http://download.dojotoolkit.org/release-2.0/dojo-2.0-widget.zip')
|
|
569
589
|
def artifact(spec, &block) #:yields:task
|
|
590
|
+
spec = artifact_ns.fetch(spec) if spec.kind_of?(Symbol)
|
|
570
591
|
spec = Artifact.to_hash(spec)
|
|
571
592
|
unless task = Artifact.lookup(spec)
|
|
572
593
|
task = Artifact.define_task(repositories.locate(spec))
|
|
573
594
|
task.send :apply_spec, spec
|
|
574
|
-
Rake::Task[
|
|
595
|
+
Rake::Task['rake:artifacts'].enhance [task]
|
|
575
596
|
Artifact.register(task)
|
|
576
597
|
end
|
|
577
598
|
task.enhance &block
|
|
@@ -583,12 +604,14 @@ module Buildr
|
|
|
583
604
|
# Handles multiple artifacts at a time. This method is the plural equivalent of
|
|
584
605
|
# #artifacts, but can do more things.
|
|
585
606
|
#
|
|
586
|
-
#
|
|
607
|
+
# Returns an array of artifacts built using the supplied
|
|
608
|
+
# specifications, each of which can be:
|
|
587
609
|
# * An artifact specification (String or Hash). Returns the appropriate Artifact task.
|
|
588
610
|
# * An artifact of any other task. Returns the task as is.
|
|
589
611
|
# * A project. Returns all artifacts created (packaged) by that project.
|
|
590
612
|
# * A string. Returns that string, assumed to be a file name.
|
|
591
613
|
# * An array of artifacts or a Struct.
|
|
614
|
+
# * A symbol. Returns the named artifact from the current ArtifactNamespace
|
|
592
615
|
#
|
|
593
616
|
# For example, handling a collection of artifacts:
|
|
594
617
|
# xml = [ xerces, xalan, jaxp ]
|
|
@@ -597,12 +620,14 @@ module Buildr
|
|
|
597
620
|
# artifacts(xml, ws, db)
|
|
598
621
|
#
|
|
599
622
|
# Using artifacts created by a project:
|
|
600
|
-
#
|
|
601
|
-
#
|
|
602
|
-
def artifacts(*specs)
|
|
623
|
+
# artifacts project('my-app') # All packages
|
|
624
|
+
# artifacts project('my-app').package(:war) # Only the WAR
|
|
625
|
+
def artifacts(*specs, &block)
|
|
603
626
|
specs.flatten.inject([]) do |set, spec|
|
|
604
627
|
case spec
|
|
605
|
-
when
|
|
628
|
+
when ArtifactNamespace
|
|
629
|
+
set |= spec.artifacts
|
|
630
|
+
when Symbol, Hash
|
|
606
631
|
set |= [artifact(spec)]
|
|
607
632
|
when /([^:]+:){2,4}/ # A spec as opposed to a file name.
|
|
608
633
|
set |= [artifact(spec)]
|
|
@@ -615,7 +640,7 @@ module Buildr
|
|
|
615
640
|
when Struct
|
|
616
641
|
set |= artifacts(spec.values)
|
|
617
642
|
else
|
|
618
|
-
fail "Invalid artifact specification in
|
|
643
|
+
fail "Invalid artifact specification in #{specs.inspect}"
|
|
619
644
|
end
|
|
620
645
|
end
|
|
621
646
|
end
|
|
@@ -644,7 +669,7 @@ module Buildr
|
|
|
644
669
|
end
|
|
645
670
|
|
|
646
671
|
# :call-seq:
|
|
647
|
-
#
|
|
672
|
+
# group(ids, :under=>group_name, :version=>number) => artifacts
|
|
648
673
|
#
|
|
649
674
|
# Convenience method for defining multiple artifacts that belong to the same group and version.
|
|
650
675
|
# Accepts multiple artifact identifiers follows by two hash values:
|
|
@@ -652,9 +677,9 @@ module Buildr
|
|
|
652
677
|
# * :version -- The version number
|
|
653
678
|
#
|
|
654
679
|
# For example:
|
|
655
|
-
# group
|
|
680
|
+
# group 'xbean', 'xbean_xpath', 'xmlpublic', :under=>'xmlbeans', :version=>'2.1.0'
|
|
656
681
|
# Or:
|
|
657
|
-
# group %w{xbean xbean_xpath xmlpublic}, :under=>
|
|
682
|
+
# group %w{xbean xbean_xpath xmlpublic}, :under=>'xmlbeans', :version=>'2.1.0'
|
|
658
683
|
def group(*args)
|
|
659
684
|
hash = args.pop
|
|
660
685
|
args.flatten.map { |id| artifact :group=>hash[:under], :version=>hash[:version], :id=>id }
|
|
@@ -693,44 +718,10 @@ module Buildr
|
|
|
693
718
|
def upload(*args, &block)
|
|
694
719
|
artifacts = artifacts(args)
|
|
695
720
|
raise ArgumentError, 'This method can only upload artifacts' unless artifacts.all? { |f| f.respond_to?(:to_spec) }
|
|
696
|
-
all = (artifacts + artifacts.map { |artifact| artifact.pom }).uniq
|
|
697
721
|
task('upload').tap do |task|
|
|
698
722
|
task.enhance &block if block
|
|
699
|
-
task.enhance
|
|
700
|
-
|
|
701
|
-
end
|
|
702
|
-
end
|
|
703
|
-
end
|
|
704
|
-
|
|
705
|
-
# *Deprecated* For artifact, call it's upload method; for anything else, use URI.upload.
|
|
706
|
-
def deploy(*args)
|
|
707
|
-
warn_deprecated "If it's an artifact, call it's upload method directly. Otherwise, use URI.upload."
|
|
708
|
-
# Where do we release to?
|
|
709
|
-
options = Hash === args.last ? args.pop : {}
|
|
710
|
-
deploy_to = options[:url] ? options : repositories.release_to
|
|
711
|
-
fail "Don't know where to deploy, perhaps you forgot to set repositories.deploy_to" if deploy_to[:url].blank?
|
|
712
|
-
|
|
713
|
-
args.flatten.each { |arg| arg.invoke if arg.respond_to?(:invoke) }
|
|
714
|
-
# Set the upload URI, including mandatory slash (we expect it to be the base directory).
|
|
715
|
-
# Username/password may be part of URI, or separate entities.
|
|
716
|
-
uri = URI.parse(deploy_to[:url].clone)
|
|
717
|
-
uri.path = uri.path + "/" unless uri.path[-1] == "/"
|
|
718
|
-
uri.user = deploy_to[:username] if deploy_to[:username]
|
|
719
|
-
uri.password = deploy_to[:password] if deploy_to[:password]
|
|
720
|
-
|
|
721
|
-
args.each do |arg|
|
|
722
|
-
if arg.respond_to?(:to_spec)
|
|
723
|
-
# Upload artifact relative to base URL, need to create path before uploading.
|
|
724
|
-
puts "Deploying #{arg.to_spec}" if verbose
|
|
725
|
-
spec = arg.to_spec_hash
|
|
726
|
-
path = spec[:group].gsub(".", "/") + "/#{spec[:id]}/#{spec[:version]}/" + Artifact.hash_to_file_name(spec)
|
|
727
|
-
URI.upload uri + path, arg.to_s, :permissions=>deploy_to[:permissions]
|
|
728
|
-
else
|
|
729
|
-
# Upload file to URL.
|
|
730
|
-
puts "Deploying #{arg}" if verbose
|
|
731
|
-
path = File.basename(args.to_s)
|
|
732
|
-
path = File.join(options[:path], path) if options[:path]
|
|
733
|
-
URI.upload uri + path, arg.to_s, :permissions=>deploy_to[:permissions]
|
|
723
|
+
task.enhance artifacts do
|
|
724
|
+
artifacts.each { |artifact| artifact.upload }
|
|
734
725
|
end
|
|
735
726
|
end
|
|
736
727
|
end
|