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
data/lib/java/packaging.rb
DELETED
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
require "core/project"
|
|
2
|
-
require "java/artifact"
|
|
3
|
-
require "java/java"
|
|
4
|
-
require "java/compile"
|
|
5
|
-
require "java/test"
|
|
6
|
-
require "tasks/zip"
|
|
7
|
-
require "tasks/tar"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module Buildr
|
|
11
|
-
module Java
|
|
12
|
-
|
|
13
|
-
# This module includes comming packaging classes. Each one is also reflected by
|
|
14
|
-
# a packaging method. Generally, you would want to use the packaging method from
|
|
15
|
-
# the project definition, since it does all the heavy lifting.
|
|
16
|
-
module Packaging
|
|
17
|
-
|
|
18
|
-
MANIFEST_HEADER = ["Manifest-Version: 1.0", "Created-By: Buildr"]
|
|
19
|
-
|
|
20
|
-
# Adds support for MANIFEST.MF and other META-INF files.
|
|
21
|
-
module WithManifest
|
|
22
|
-
|
|
23
|
-
class << self
|
|
24
|
-
# jruby issue
|
|
25
|
-
#protected
|
|
26
|
-
def included(mod)
|
|
27
|
-
mod.alias_method_chain :initialize, :manifest
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Specifies how to create the manifest file.
|
|
32
|
-
attr_accessor :manifest
|
|
33
|
-
|
|
34
|
-
# Specifies files to include in the META-INF directory.
|
|
35
|
-
attr_accessor :meta_inf
|
|
36
|
-
|
|
37
|
-
def initialize_with_manifest(*args) #:nodoc:
|
|
38
|
-
initialize_without_manifest *args
|
|
39
|
-
@manifest = false
|
|
40
|
-
@meta_inf = []
|
|
41
|
-
|
|
42
|
-
prepare do
|
|
43
|
-
@prerequisites << manifest if String === manifest || Rake::Task === manifest
|
|
44
|
-
[meta_inf].flatten.map { |file| file.to_s }.uniq.each { |file| path("META-INF").include file }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
enhance do
|
|
48
|
-
if manifest
|
|
49
|
-
# Tempfiles gets deleted on garbage collection, so we're going to hold on to it
|
|
50
|
-
# through instance variable not closure variable.
|
|
51
|
-
Tempfile.open "MANIFEST.MF" do |@manifest_tmp|
|
|
52
|
-
lines = String === manifest || Rake::Task === manifest ? manifest_lines_from(File.read(manifest.to_s)) :
|
|
53
|
-
manifest_lines_from(manifest)
|
|
54
|
-
@manifest_tmp.write((MANIFEST_HEADER + lines).join("\n"))
|
|
55
|
-
@manifest_tmp.write "\n"
|
|
56
|
-
path("META-INF").include @manifest_tmp.path, :as=>"MANIFEST.MF"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
private
|
|
63
|
-
|
|
64
|
-
def manifest_lines_from(arg)
|
|
65
|
-
case arg
|
|
66
|
-
when Hash
|
|
67
|
-
arg.map { |name, value| "#{name}: #{value}" }.sort.
|
|
68
|
-
map { |line| manifest_wrap_at_72(line) }.flatten
|
|
69
|
-
when Array
|
|
70
|
-
arg.map { |section|
|
|
71
|
-
name = section.has_key?("Name") ? ["Name: #{section["Name"]}"] : []
|
|
72
|
-
name + section.except("Name").map { |name, value| "#{name}: #{value}" }.sort + [""]
|
|
73
|
-
}.flatten.map { |line| manifest_wrap_at_72(line) }.flatten
|
|
74
|
-
when Proc, Method
|
|
75
|
-
manifest_lines_from(arg.call)
|
|
76
|
-
when String
|
|
77
|
-
arg.split("\n").map { |line| manifest_wrap_at_72(line) }.flatten
|
|
78
|
-
else
|
|
79
|
-
fail "Invalid manifest, expecting Hash, Array, file name/task or proc/method."
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def manifest_wrap_at_72(arg)
|
|
84
|
-
#return arg.map { |line| manifest_wrap_at_72(line) }.flatten.join("\n") if Array === arg
|
|
85
|
-
return arg if arg.size < 72
|
|
86
|
-
[ arg[0..70], manifest_wrap_at_72(" " + arg[71..-1]) ]
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
class ::Buildr::ZipTask
|
|
92
|
-
include WithManifest
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
# Extends the ZipTask to create a JAR file.
|
|
97
|
-
#
|
|
98
|
-
# This task supports two additional attributes: manifest and meta-inf.
|
|
99
|
-
#
|
|
100
|
-
# The manifest attribute specifies how to create the MANIFEST.MF file.
|
|
101
|
-
# * A hash of manifest properties (name/value pairs).
|
|
102
|
-
# * An array of hashes, one for each section of the manifest.
|
|
103
|
-
# * A string providing the name of an existing manifest file.
|
|
104
|
-
# * A file task can be used the same way.
|
|
105
|
-
# * Proc or method called to return the contents of the manifest file.
|
|
106
|
-
# * False to not generate a manifest file.
|
|
107
|
-
#
|
|
108
|
-
# The meta-inf attribute lists one or more files that should be copied into
|
|
109
|
-
# the META-INF directory.
|
|
110
|
-
#
|
|
111
|
-
# For example:
|
|
112
|
-
# package(:jar).with(:manifest=>"src/MANIFEST.MF")
|
|
113
|
-
# package(:jar).meta_inf << file("README")
|
|
114
|
-
class JarTask < ZipTask
|
|
115
|
-
|
|
116
|
-
def initialize(*args) #:nodoc:
|
|
117
|
-
super
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# :call-seq:
|
|
121
|
-
# with(options) => self
|
|
122
|
-
#
|
|
123
|
-
# Additional
|
|
124
|
-
# Pass options to the task. Returns self. ZipTask itself does not support any options,
|
|
125
|
-
# but other tasks (e.g. JarTask, WarTask) do.
|
|
126
|
-
#
|
|
127
|
-
# For example:
|
|
128
|
-
# package(:jar).with(:manifest=>"MANIFEST_MF")
|
|
129
|
-
def with(*args)
|
|
130
|
-
super args.pop if Hash === args.last
|
|
131
|
-
include :from=>args
|
|
132
|
-
self
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Extends the JarTask to create a WAR file.
|
|
138
|
-
#
|
|
139
|
-
# Supports all the same options as JarTask, in additon to these two options:
|
|
140
|
-
# * :libs -- An array of files, tasks, artifact specifications, etc that will be added
|
|
141
|
-
# to the WEB-INF/lib directory.
|
|
142
|
-
# * :classes -- A directory containing class files for inclusion in the WEB-INF/classes
|
|
143
|
-
# directory.
|
|
144
|
-
#
|
|
145
|
-
# For example:
|
|
146
|
-
# package(:war).with(:libs=>"log4j:log4j:jar:1.1")
|
|
147
|
-
class WarTask < JarTask
|
|
148
|
-
|
|
149
|
-
# Directories with class files to include under WEB-INF/classes.
|
|
150
|
-
attr_accessor :classes
|
|
151
|
-
|
|
152
|
-
# Artifacts to include under WEB-INF/libs.
|
|
153
|
-
attr_accessor :libs
|
|
154
|
-
|
|
155
|
-
def initialize(*args) #:nodoc:
|
|
156
|
-
super
|
|
157
|
-
@classes = []
|
|
158
|
-
@libs = []
|
|
159
|
-
prepare do
|
|
160
|
-
@classes.to_a.flatten.each { |classes| path("WEB-INF/classes").include classes, :as=>"." }
|
|
161
|
-
path("WEB-INF/lib").include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def libs=(value) #:nodoc:
|
|
166
|
-
@libs = Buildr.artifacts(value)
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def classes=(value) #:nodoc:
|
|
170
|
-
@classes = [value].flatten.map { |dir| file(dir.to_s) }
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
# Extends the JarTask to create an AAR file (Axis2 service archive).
|
|
176
|
-
#
|
|
177
|
-
# Supports all the same options as JarTask, with the addition of :wsdls, :services_xml and :libs.
|
|
178
|
-
#
|
|
179
|
-
# * :wsdls -- WSDL files to include (under META-INF). By default packaging will include all WSDL
|
|
180
|
-
# files found under src/main/axis2.
|
|
181
|
-
# * :services_xml -- Location of services.xml file (included under META-INF). By default packaging
|
|
182
|
-
# takes this from src/main/axis2/services.xml. Use a different path if you genereate the services.xml
|
|
183
|
-
# file as part of the build.
|
|
184
|
-
# * :libs -- Array of files, tasks, artifact specifications, etc that will be added to the /lib directory.
|
|
185
|
-
#
|
|
186
|
-
# For example:
|
|
187
|
-
# package(:aar).with(:libs=>"log4j:log4j:jar:1.1")
|
|
188
|
-
#
|
|
189
|
-
# filter.from("src/main/axis2").into("target").include("services.xml", "*.wsdl").using("http_port"=>"8080")
|
|
190
|
-
# package(:aar).wsdls.clear
|
|
191
|
-
# package(:aar).with(:services_xml=>_("target/services.xml"), :wsdls=>_("target/*.wsdl"))
|
|
192
|
-
class AarTask < JarTask
|
|
193
|
-
# Artifacts to include under /lib.
|
|
194
|
-
attr_accessor :libs
|
|
195
|
-
# WSDLs to include under META-INF (defaults to all WSDLs under src/main/axis2).
|
|
196
|
-
attr_accessor :wsdls
|
|
197
|
-
# Location of services.xml file (defaults to src/main/axis2/services.xml).
|
|
198
|
-
attr_accessor :services_xml
|
|
199
|
-
|
|
200
|
-
def initialize(*args) #:nodoc:
|
|
201
|
-
super
|
|
202
|
-
@libs = []
|
|
203
|
-
@wsdls = []
|
|
204
|
-
prepare do
|
|
205
|
-
path("META-INF").include @wsdls
|
|
206
|
-
path("META-INF").include @services_xml, :as=>["services.xml"] if @services_xml
|
|
207
|
-
path("lib").include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def libs=(value) #:nodoc:
|
|
212
|
-
@libs = Buildr.artifacts(value)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def wsdls=(value) #:nodoc:
|
|
216
|
-
@wsdls |= Array(value)
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
Project.on_define do |project|
|
|
224
|
-
# Need to run buildr before package, since package is often used as a dependency by tasks that
|
|
225
|
-
# expect build to happen.
|
|
226
|
-
task "package"=>task("build")
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
class Project
|
|
231
|
-
|
|
232
|
-
# Options accepted by #package method for all package types.
|
|
233
|
-
PACKAGE_OPTIONS = [:group, :id, :version, :type, :classifier]
|
|
234
|
-
|
|
235
|
-
# The project's identifier. Same as the project name, with colons replaced by dashes.
|
|
236
|
-
# The ID for project foo:bar is foo-bar.
|
|
237
|
-
attr_reader :id
|
|
238
|
-
def id()
|
|
239
|
-
name.gsub(":", "-")
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
# Group used for packaging. Inherited from parent project. Defaults to the top-level project name.
|
|
243
|
-
attr_accessor :group
|
|
244
|
-
inherited_attr(:group) { |project| project.name }
|
|
245
|
-
|
|
246
|
-
# Version used for packaging. Inherited from parent project.
|
|
247
|
-
attr_accessor :version
|
|
248
|
-
inherited_attr :version
|
|
249
|
-
|
|
250
|
-
# Manifest used for packaging. Inherited from parent project. The default value is a hash that includes
|
|
251
|
-
# the Build-By, Build-Jdk, Implementation-Title and Implementation-Version values.
|
|
252
|
-
# The later are taken from the project's comment (or name) and version number.
|
|
253
|
-
attr_accessor :manifest
|
|
254
|
-
inherited_attr :manifest do |project|
|
|
255
|
-
manifest = { "Build-By"=>ENV['USER'], "Build-Jdk"=>Java.version }
|
|
256
|
-
manifest["Implementation-Title"] = self.comment || self.name
|
|
257
|
-
manifest["Implementation-Version"] = project.version if project.version
|
|
258
|
-
manifest
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
# Files to always include in the package META-INF directory. The default value include
|
|
262
|
-
# the LICENSE file if one exists in the project's base directory.
|
|
263
|
-
attr_accessor :meta_inf
|
|
264
|
-
inherited_attr(:meta_inf) do |project|
|
|
265
|
-
license = project.file("LICENSE")
|
|
266
|
-
File.exist?(license.to_s) ? [license] : []
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
# :call-seq:
|
|
270
|
-
# package(type, spec?) => task
|
|
271
|
-
#
|
|
272
|
-
# Defines and returns a package created by this project.
|
|
273
|
-
#
|
|
274
|
-
# The first argument declares the package type. For example, :jar to create a JAR file.
|
|
275
|
-
# The package is an artifact that takes its artifact specification from the project.
|
|
276
|
-
# You can override the artifact specification by passing various options in the second
|
|
277
|
-
# argument, for example:
|
|
278
|
-
# package(:zip, :classifier=>"sources")
|
|
279
|
-
#
|
|
280
|
-
# Packages that are ZIP files provides various ways to include additional files, directories,
|
|
281
|
-
# and even merge ZIPs together. Have a look at ZipTask for more information. In case you're
|
|
282
|
-
# wondering, JAR and WAR packages are ZIP files.
|
|
283
|
-
#
|
|
284
|
-
# You can also enhance a JAR package using the ZipTask#with method that accepts the following options:
|
|
285
|
-
# * :manifest -- Specifies how to create the MANIFEST.MF. By default, uses the project's
|
|
286
|
-
# #manifest property.
|
|
287
|
-
# * :meta_inf -- Specifies files to be included in the META-INF directory. By default,
|
|
288
|
-
# uses the project's #meta-inf property.
|
|
289
|
-
#
|
|
290
|
-
# The WAR package supports the same options and adds a few more:
|
|
291
|
-
# * :classes -- Directories of class files to include in WEB-INF/classes. Includes the compile
|
|
292
|
-
# target directory by default.
|
|
293
|
-
# * :libs -- Artifacts and files to include in WEB-INF/libs. Includes the compile classpath
|
|
294
|
-
# dependencies by default.
|
|
295
|
-
#
|
|
296
|
-
# For example:
|
|
297
|
-
# define "project" do
|
|
298
|
-
# define "beans" do
|
|
299
|
-
# package :jar
|
|
300
|
-
# end
|
|
301
|
-
# define "webapp" do
|
|
302
|
-
# compile.with project("beans")
|
|
303
|
-
# package(:war).with :libs=>MYSQL_JDBC
|
|
304
|
-
# end
|
|
305
|
-
# package(:zip, :classifier=>"sources").include path_to(".")
|
|
306
|
-
# end
|
|
307
|
-
#
|
|
308
|
-
# Two other packaging types are:
|
|
309
|
-
# * package :sources -- Creates a ZIP file with the source code and classifier "sources", for use by IDEs.
|
|
310
|
-
# * package :javadoc -- Creates a ZIP file with the Javadocs and classifier "javadoc". You can use the
|
|
311
|
-
# javadoc method to further customize it.
|
|
312
|
-
#
|
|
313
|
-
# A package is also an artifact. The following tasks operate on packages created by the project:
|
|
314
|
-
# buildr upload # Upload packages created by the project
|
|
315
|
-
# buildr install # Install packages created by the project
|
|
316
|
-
# buildr package # Create packages
|
|
317
|
-
# buildr uninstall # Remove previously installed packages
|
|
318
|
-
#
|
|
319
|
-
# If you want to add additional packaging types, implement a method with the name package_as_[type]
|
|
320
|
-
# that accepts two arguments, the file name and a hash of options. You can change the options and
|
|
321
|
-
# file name, e.g. to add a classifier or change the file type. Your method may be called multiple times,
|
|
322
|
-
# and must return the same file task on each call.
|
|
323
|
-
def package(type = :jar, options = nil)
|
|
324
|
-
options = options.nil? ? {} : options.dup
|
|
325
|
-
options[:id] ||= self.id
|
|
326
|
-
options[:group] ||= self.group
|
|
327
|
-
options[:version] ||= self.version
|
|
328
|
-
options[:type] = type
|
|
329
|
-
file_name = path_to(:target, Artifact.hash_to_file_name(options))
|
|
330
|
-
|
|
331
|
-
packager = method("package_as_#{type}") rescue
|
|
332
|
-
fail("Don't know how to create a package of type #{type}")
|
|
333
|
-
package = packager.call(file_name, options) { warn_deprecated "Yielding from package_as_ no longer necessary." }
|
|
334
|
-
unless packages.include?(package)
|
|
335
|
-
# Make it an artifact using the specifications, and tell it how to create a POM.
|
|
336
|
-
package.extend ActsAsArtifact
|
|
337
|
-
package.send :apply_spec, Hash[*Artifact::ARTIFACT_ATTRIBUTES.map { |k| [ k,options[k]] }.flatten]
|
|
338
|
-
# Another task to create the POM file.
|
|
339
|
-
pom_spec = package.to_spec_hash.merge(:type=>:pom)
|
|
340
|
-
pom = file(Buildr.repositories.locate(pom_spec))
|
|
341
|
-
pom.extend ActsAsArtifact
|
|
342
|
-
pom.send :apply_spec, pom_spec
|
|
343
|
-
pom.enhance do
|
|
344
|
-
mkpath File.dirname(pom.name), :verbose=>false
|
|
345
|
-
File.open(pom.name, "w") { |file| file.write pom.pom_xml }
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
# We already run build before package, but we also need to do so if the package itself is
|
|
349
|
-
# used as a dependency, before we get to run the package task.
|
|
350
|
-
task "package"=>package
|
|
351
|
-
package.enhance [task("build")]
|
|
352
|
-
|
|
353
|
-
# Install the artifact along with its POM. Since the artifact (package task) is created
|
|
354
|
-
# in the target directory, we need to copy it into the local repository. However, the
|
|
355
|
-
# POM artifact (created by calling artifact on its spec) is already mapped to its right
|
|
356
|
-
# place in the local repository, so we only need to invoke it.
|
|
357
|
-
installed = file(Buildr.repositories.locate(package)=>package) { |task|
|
|
358
|
-
verbose(Rake.application.options.trace || false) do
|
|
359
|
-
mkpath File.dirname(task.name), :verbose=>false
|
|
360
|
-
cp package.name, task.name
|
|
361
|
-
end
|
|
362
|
-
puts "Installed #{task.name}" if verbose
|
|
363
|
-
}
|
|
364
|
-
task "install"=>[installed, pom]
|
|
365
|
-
task "uninstall" do |task|
|
|
366
|
-
verbose(Rake.application.options.trace || false) do
|
|
367
|
-
[ installed, pom ].map(&:to_s).each { |file| rm file if File.exist?(file) }
|
|
368
|
-
end
|
|
369
|
-
end
|
|
370
|
-
task("upload") { package.pom.invoke ; package.pom.upload ; package.upload }
|
|
371
|
-
|
|
372
|
-
# Add the package to the list of packages created by this project, and
|
|
373
|
-
# register it as an artifact. The later is required so if we look up the spec
|
|
374
|
-
# we find the package in the project's target directory, instead of finding it
|
|
375
|
-
# in the local repository and attempting to install it.
|
|
376
|
-
packages << package
|
|
377
|
-
Artifact.register package, pom
|
|
378
|
-
end
|
|
379
|
-
package
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
# :call-seq:
|
|
383
|
-
# packages() => tasks
|
|
384
|
-
#
|
|
385
|
-
# Returns all packages created by this project. A project may create any number of packages.
|
|
386
|
-
#
|
|
387
|
-
# This method is used whenever you pass a project to Buildr#artifact or any other method
|
|
388
|
-
# that accepts artifact specifications and projects. You can use it to list all packages
|
|
389
|
-
# created by the project. If you want to return a specific package, it is often more
|
|
390
|
-
# convenient to call #package with the type.
|
|
391
|
-
def packages()
|
|
392
|
-
@packages ||= []
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
protected
|
|
396
|
-
|
|
397
|
-
def package_as_jar(file_name, options) #:nodoc:
|
|
398
|
-
unless Rake::Task.task_defined?(file_name)
|
|
399
|
-
rake_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :include]
|
|
400
|
-
Java::Packaging::JarTask.define_task(file_name).tap do |jar|
|
|
401
|
-
jar.with :manifest=>manifest, :meta_inf=>meta_inf
|
|
402
|
-
[:manifest, :meta_inf].each do |option|
|
|
403
|
-
if options.has_key?(option)
|
|
404
|
-
warn_deprecated "The :#{option} option in package(:jar) is deprecated, please use package(:jar).with(:#{option}=>) instead."
|
|
405
|
-
jar.with option=>options[option]
|
|
406
|
-
end
|
|
407
|
-
end
|
|
408
|
-
if options[:include]
|
|
409
|
-
warn_deprecated "The :include option in package(:jar) is deprecated, please use package(:jar).include(files) instead."
|
|
410
|
-
jar.include options[:include]
|
|
411
|
-
else
|
|
412
|
-
jar.with compile.target unless compile.sources.empty?
|
|
413
|
-
jar.with resources.target unless resources.sources.empty?
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
else
|
|
417
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
418
|
-
end
|
|
419
|
-
file(file_name)
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
def package_as_war(file_name, options) #:nodoc:
|
|
423
|
-
unless Rake::Task.task_defined?(file_name)
|
|
424
|
-
rake_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :classes, :libs, :include]
|
|
425
|
-
Java::Packaging::WarTask.define_task(file_name).tap do |war|
|
|
426
|
-
war.with :manifest=>manifest, :meta_inf=>meta_inf
|
|
427
|
-
[:manifest, :meta_inf].each do |option|
|
|
428
|
-
if options.has_key?(option)
|
|
429
|
-
warn_deprecated "The :#{option} option in package :war is deprecated, please use package(:war).with(:#{option}=>) instead."
|
|
430
|
-
war.with option=>options[option]
|
|
431
|
-
end
|
|
432
|
-
end
|
|
433
|
-
# Add libraries in WEB-INF lib, and classes in WEB-INF classes
|
|
434
|
-
if options.has_key?(:classes)
|
|
435
|
-
warn_deprecated "The :classes option in package(:war) is deprecated, please use package(:war).with(:classes=>) instead."
|
|
436
|
-
war.with :classes=>options[:classes]
|
|
437
|
-
else
|
|
438
|
-
war.with :classes=>compile.target unless compile.sources.empty?
|
|
439
|
-
war.with :classes=>resources.target unless resources.sources.empty?
|
|
440
|
-
end
|
|
441
|
-
if options.has_key?(:libs)
|
|
442
|
-
warn_deprecated "The :libs option in package(:war) is deprecated, please use package(:war).with(:libs=>) instead."
|
|
443
|
-
war.with :libs=>options[:libs].collect
|
|
444
|
-
else
|
|
445
|
-
war.with :libs=>compile.classpath
|
|
446
|
-
end
|
|
447
|
-
# Add included files, or the webapp directory.
|
|
448
|
-
if options.has_key?(:include)
|
|
449
|
-
warn_deprecated "The :include option in package(:war) is deprecated, please use package(:war).include(files) instead."
|
|
450
|
-
war.include options[:include]
|
|
451
|
-
else
|
|
452
|
-
path_to("src/main/webapp").tap { |path| war.with path if File.exist?(path) }
|
|
453
|
-
end
|
|
454
|
-
end
|
|
455
|
-
else
|
|
456
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
457
|
-
end
|
|
458
|
-
file(file_name)
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
def package_as_aar(file_name, options) #:nodoc:
|
|
462
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
463
|
-
unless Rake::Task.task_defined?(file_name)
|
|
464
|
-
Java::Packaging::AarTask.define_task(file_name).tap do |aar|
|
|
465
|
-
aar.with :manifest=>manifest, :meta_inf=>meta_inf
|
|
466
|
-
aar.with :wsdls=>path_to("src/main/axis2/*.wsdl")
|
|
467
|
-
aar.with :services_xml=>path_to("src/main/axis2/services.xml")
|
|
468
|
-
aar.with compile.target unless compile.sources.empty?
|
|
469
|
-
aar.with resources.target unless resources.sources.empty?
|
|
470
|
-
aar.with :libs=>compile.classpath
|
|
471
|
-
end
|
|
472
|
-
end
|
|
473
|
-
file(file_name)
|
|
474
|
-
end
|
|
475
|
-
|
|
476
|
-
def package_as_zip(file_name, options) #:nodoc:
|
|
477
|
-
unless Rake::Task.task_defined?(file_name)
|
|
478
|
-
rake_check_options options, *PACKAGE_OPTIONS + [:include]
|
|
479
|
-
ZipTask.define_task(file_name).tap do |zip|
|
|
480
|
-
if options[:include]
|
|
481
|
-
warn_deprecated "The :include option in package(:zip) is deprecated, please use package(:zip).include(files) instead."
|
|
482
|
-
zip.include options[:include]
|
|
483
|
-
end
|
|
484
|
-
end
|
|
485
|
-
else
|
|
486
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
487
|
-
end
|
|
488
|
-
file(file_name)
|
|
489
|
-
end
|
|
490
|
-
|
|
491
|
-
def package_as_tar(file_name, options) #:nodoc:
|
|
492
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
493
|
-
unless Rake::Task.task_defined?(file_name)
|
|
494
|
-
TarTask.define_task(file_name)
|
|
495
|
-
end
|
|
496
|
-
file(file_name)
|
|
497
|
-
end
|
|
498
|
-
alias :package_as_tgz :package_as_tar
|
|
499
|
-
|
|
500
|
-
def package_as_sources(file_name, options) #:nodoc:
|
|
501
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
502
|
-
options.merge!(:type=>:zip, :classifier=>"sources")
|
|
503
|
-
file_name = path_to(:target, Artifact.hash_to_file_name(options))
|
|
504
|
-
ZipTask.define_task(file_name).tap { |zip| zip.include :from=>compile.sources } unless Rake::Task.task_defined?(file_name)
|
|
505
|
-
file(file_name)
|
|
506
|
-
end
|
|
507
|
-
|
|
508
|
-
def package_as_javadoc(file_name, options) #:nodoc:
|
|
509
|
-
rake_check_options options, *PACKAGE_OPTIONS
|
|
510
|
-
options.merge!(:type=>:zip, :classifier=>"javadoc")
|
|
511
|
-
file_name = path_to(:target, Artifact.hash_to_file_name(options))
|
|
512
|
-
unless Rake::Task.task_defined?(file_name)
|
|
513
|
-
ZipTask.define_task(file_name).tap { |zip| zip.include :from=>javadoc.target }
|
|
514
|
-
javadoc.options[:windowtitle] ||= project.comment || project.name
|
|
515
|
-
end
|
|
516
|
-
file(file_name)
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
end
|
|
520
|
-
|
|
521
|
-
class Project
|
|
522
|
-
|
|
523
|
-
# :call-seq:
|
|
524
|
-
# package_with_sources(options?)
|
|
525
|
-
#
|
|
526
|
-
# Call this when you want the project (and all its sub-projects) to create a source distribution.
|
|
527
|
-
# You can use the source distribution in an IDE when debugging.
|
|
528
|
-
#
|
|
529
|
-
# A source distribution is a ZIP package with the classifier "sources", which includes all the
|
|
530
|
-
# sources used by the compile task.
|
|
531
|
-
#
|
|
532
|
-
# Packages use the project's manifest and meta_inf properties, which you can override by passing
|
|
533
|
-
# different values (e.g. false to exclude the manifest) in the options.
|
|
534
|
-
#
|
|
535
|
-
# To create source distributions only for specific projects, use the :only and :except options,
|
|
536
|
-
# for example:
|
|
537
|
-
# package_with_sources :only=>["foo:bar", "foo:baz"]
|
|
538
|
-
#
|
|
539
|
-
# (Same as calling package :sources on each project/sub-project that has source directories.)
|
|
540
|
-
def package_with_sources(options = nil)
|
|
541
|
-
options ||= {}
|
|
542
|
-
enhance do
|
|
543
|
-
selected = options[:only] ? projects(options[:only]) :
|
|
544
|
-
options[:except] ? ([self] + projects - projects(options[:except])) :
|
|
545
|
-
[self] + projects
|
|
546
|
-
selected.reject { |project| project.compile.sources.empty? }.
|
|
547
|
-
each { |project| project.package(:sources) }
|
|
548
|
-
end
|
|
549
|
-
end
|
|
550
|
-
|
|
551
|
-
# :call-seq:
|
|
552
|
-
# package_with_javadoc(options?)
|
|
553
|
-
#
|
|
554
|
-
# Call this when you want the project (and all its sub-projects) to create a JavaDoc distribution.
|
|
555
|
-
# You can use the JavaDoc distribution in an IDE when coding against the API.
|
|
556
|
-
#
|
|
557
|
-
# A JavaDoc distribution is a ZIP package with the classifier "javadoc", which includes all the
|
|
558
|
-
# sources used by the compile task.
|
|
559
|
-
#
|
|
560
|
-
# Packages use the project's manifest and meta_inf properties, which you can override by passing
|
|
561
|
-
# different values (e.g. false to exclude the manifest) in the options.
|
|
562
|
-
#
|
|
563
|
-
# To create JavaDoc distributions only for specific projects, use the :only and :except options,
|
|
564
|
-
# for example:
|
|
565
|
-
# package_with_javadoc :only=>["foo:bar", "foo:baz"]
|
|
566
|
-
#
|
|
567
|
-
# (Same as calling package :javadoc on each project/sub-project that has source directories.)
|
|
568
|
-
def package_with_javadoc(options = nil)
|
|
569
|
-
options ||= {}
|
|
570
|
-
enhance do
|
|
571
|
-
selected = options[:only] ? projects(options[:only]) :
|
|
572
|
-
options[:except] ? ([self] + projects - projects(options[:except])) :
|
|
573
|
-
[self] + projects
|
|
574
|
-
selected.reject { |project| project.compile.sources.empty? }.
|
|
575
|
-
each { |project| project.package(:javadoc) }
|
|
576
|
-
end
|
|
577
|
-
end
|
|
578
|
-
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
end
|