buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,140 @@
|
|
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 'hpricot'
|
18
|
+
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
|
22
|
+
# Search best artifact version from remote repositories
|
23
|
+
module ArtifactSearch
|
24
|
+
extend self
|
25
|
+
|
26
|
+
def include(method = nil)
|
27
|
+
(@includes ||= []).tap { push method if method }
|
28
|
+
end
|
29
|
+
|
30
|
+
def exclude(method = nil)
|
31
|
+
(@excludes ||= []).tap { push method if method }
|
32
|
+
end
|
33
|
+
|
34
|
+
# TODO: return the url for best matching repo
|
35
|
+
def best_version(spec, *methods)
|
36
|
+
spec = Artifact.to_hash(spec)
|
37
|
+
spec[:version] = requirement = VersionRequirement.create(spec[:version])
|
38
|
+
select = lambda do |candidates|
|
39
|
+
candidates.find { |candidate| requirement.satisfied_by?(candidate) }
|
40
|
+
end
|
41
|
+
result = nil
|
42
|
+
methods = search_methods if methods.empty?
|
43
|
+
if requirement.composed?
|
44
|
+
until result || methods.empty?
|
45
|
+
method = methods.shift
|
46
|
+
type = method.keys.first
|
47
|
+
from = method[type]
|
48
|
+
if (include.empty? || !(include & [:all, type, from]).empty?) &&
|
49
|
+
(exclude & [:all, type, from]).empty?
|
50
|
+
if from.respond_to?(:call)
|
51
|
+
versions = from.call(spec.dup)
|
52
|
+
else
|
53
|
+
versions = send("#{type}_versions", spec.dup, *from)
|
54
|
+
end
|
55
|
+
result = select[versions]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
result ||= requirement.default
|
60
|
+
raise "Could not find #{Artifact.to_spec(spec)}" +
|
61
|
+
"\n You may need to use an specific version instead of a requirement" unless result
|
62
|
+
spec.merge :version => result
|
63
|
+
end
|
64
|
+
|
65
|
+
def requirement?(spec)
|
66
|
+
VersionRequirement.requirement?(spec[:version])
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def search_methods
|
71
|
+
[].tap do
|
72
|
+
push :runtime => [Artifact.list]
|
73
|
+
push :local => Buildr.repositories.local
|
74
|
+
Buildr.repositories.remote.each { |remote| push :remote => remote }
|
75
|
+
push :mvnrepository => []
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def depend_version(spec)
|
80
|
+
spec[:version][/[\w\.]+/]
|
81
|
+
end
|
82
|
+
|
83
|
+
def runtime_versions(spec, artifacts)
|
84
|
+
spec_classif = spec.values_at(:group, :id, :type)
|
85
|
+
artifacts.inject([]) do |in_memory, str|
|
86
|
+
candidate = Artifact.to_hash(str)
|
87
|
+
if spec_classif == candidate.values_at(:group, :id, :type)
|
88
|
+
in_memory << candidate[:version]
|
89
|
+
end
|
90
|
+
in_memory
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def local_versions(spec, repo)
|
95
|
+
path = (spec[:group].split(/\./) + [spec[:id]]).flatten.join('/')
|
96
|
+
Dir[File.expand_path(path + "/*", repo)].map { |d| d.pathmap("%f") }.sort.reverse
|
97
|
+
end
|
98
|
+
|
99
|
+
def remote_versions(art, base, from = :metadata, fallback = true)
|
100
|
+
path = (art[:group].split(/\./) + [art[:id]]).flatten.join('/')
|
101
|
+
base ||= "http://mirrors.ibiblio.org/pub/mirrors/maven2"
|
102
|
+
uris = {:metadata => "#{base}/#{path}/maven-metadata.xml"}
|
103
|
+
uris[:listing] = "#{base}/#{path}/" if base =~ /^https?:/
|
104
|
+
xml = nil
|
105
|
+
until xml || uris.empty?
|
106
|
+
begin
|
107
|
+
xml = URI.read(uris.delete(from))
|
108
|
+
rescue URI::NotFoundError => e
|
109
|
+
from = fallback ? uris.keys.first : nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
return [] unless xml
|
113
|
+
doc = Hpricot(xml)
|
114
|
+
case from
|
115
|
+
when :metadata then
|
116
|
+
doc.search("versions/version").map(&:innerHTML).reverse
|
117
|
+
when :listing then
|
118
|
+
doc.search("a[@href]").inject([]) { |vers, a|
|
119
|
+
vers << a.innerHTML.chop if a.innerHTML[-1..-1] == '/'
|
120
|
+
vers
|
121
|
+
}.sort.reverse
|
122
|
+
else
|
123
|
+
fail "Don't know how to parse #{from}: \n#{xml.inspect}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def mvnrepository_versions(art)
|
128
|
+
uri = "http://www.mvnrepository.com/artifact/#{art[:group]}/#{art[:id]}"
|
129
|
+
xml = begin
|
130
|
+
URI.read(uri)
|
131
|
+
rescue URI::NotFoundError => e
|
132
|
+
puts e.class, e
|
133
|
+
return []
|
134
|
+
end
|
135
|
+
doc = Hpricot(xml)
|
136
|
+
doc.search("table.grid/tr/td[1]/a").map(&:innerHTML)
|
137
|
+
end
|
138
|
+
|
139
|
+
end # ArtifactSearch
|
140
|
+
end
|
@@ -0,0 +1,102 @@
|
|
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/package'
|
18
|
+
require 'buildr/packaging/archive'
|
19
|
+
gem 'rubyforge' ; autoload :RubyForge, 'rubyforge'
|
20
|
+
Gem.autoload :Package, 'rubygems/package'
|
21
|
+
|
22
|
+
|
23
|
+
module Buildr
|
24
|
+
|
25
|
+
class PackageGemTask < ArchiveTask
|
26
|
+
|
27
|
+
def initialize(*args)
|
28
|
+
super
|
29
|
+
@spec = Gem::Specification.new
|
30
|
+
prepare do
|
31
|
+
include(changelog) if changelog
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_accessor :changelog
|
36
|
+
|
37
|
+
def spec
|
38
|
+
yield @spec if block_given?
|
39
|
+
@spec
|
40
|
+
end
|
41
|
+
|
42
|
+
def install
|
43
|
+
Util::Gems.command 'install', name
|
44
|
+
end
|
45
|
+
|
46
|
+
def uninstall
|
47
|
+
Util::Gems.command 'uninstall', spec.name, '-v', spec.version.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
def upload
|
51
|
+
rubyforge = RubyForge.new
|
52
|
+
rubyforge.login
|
53
|
+
rubyforge.userconfig.merge!('release_changes'=>changelog.to_s, 'preformatted'=>true) if changelog
|
54
|
+
rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, package(:gem).to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def create_from(file_map)
|
60
|
+
spec.mark_version
|
61
|
+
spec.validate
|
62
|
+
Gem::Package.open(name, 'w', nil) do |pkg|
|
63
|
+
pkg.metadata = spec.to_yaml
|
64
|
+
file_map.each do |path, content|
|
65
|
+
next if content.nil? || File.directory?(content.to_s)
|
66
|
+
pkg.add_file_simple(path, File.stat(name).mode & 0777, File.size(content.to_s)) do |os|
|
67
|
+
File.open(content.to_s, "rb") do |file|
|
68
|
+
os.write file.read(4096) until file.eof?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
module PackageAsGem #:nodoc:
|
79
|
+
|
80
|
+
def package_as_gem(file_name) #:nodoc:
|
81
|
+
PackageGemTask.define_task(file_name).tap do |gem|
|
82
|
+
%w{ lib test doc }.each do |dir|
|
83
|
+
gem.include :from=>_(dir), :path=>dir if File.directory?(_(dir))
|
84
|
+
end
|
85
|
+
gem.spec do |spec|
|
86
|
+
spec.name = id
|
87
|
+
spec.version = version
|
88
|
+
spec.summary = full_comment
|
89
|
+
spec.has_rdoc = true
|
90
|
+
spec.rdoc_options << '--title' << comment
|
91
|
+
spec.require_path = 'lib'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
class Project
|
99
|
+
include PackageAsGem
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'buildr/core/project'
|
18
|
+
require 'buildr/core/compile'
|
19
|
+
require 'buildr/packaging/artifact'
|
20
|
+
|
21
|
+
|
22
|
+
module Buildr
|
23
|
+
# Methods added to Project to support packaging and tasks for packaging,
|
24
|
+
# installing and uploading packages.
|
25
|
+
module Package
|
26
|
+
|
27
|
+
include Extension
|
28
|
+
|
29
|
+
first_time do
|
30
|
+
desc 'Create packages'
|
31
|
+
Project.local_task('package'=>'build') { |name| "Packaging #{name}" }
|
32
|
+
desc 'Install packages created by the project'
|
33
|
+
Project.local_task('install'=>'package') { |name| "Installing packages from #{name}" }
|
34
|
+
desc 'Remove previously installed packages'
|
35
|
+
Project.local_task('uninstall') { |name| "Uninstalling packages from #{name}" }
|
36
|
+
desc 'Upload packages created by the project'
|
37
|
+
Project.local_task('upload'=>'package') { |name| "Deploying packages from #{name}" }
|
38
|
+
# Anything that comes after local packaging (install, upload) executes the integration tests,
|
39
|
+
# which do not conflict with integration invoking the project's own packaging (package=>
|
40
|
+
# integration=>foo:package is not circular, just confusing to debug.)
|
41
|
+
task 'package' do
|
42
|
+
task('integration').invoke if Buildr.options.test && Buildr.application.original_dir == Dir.pwd
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
before_define do |project|
|
47
|
+
[ :package, :install, :uninstall, :upload ].each { |name| project.recursive_task name }
|
48
|
+
# Need to run build before package, since package is often used as a dependency by tasks that
|
49
|
+
# expect build to happen.
|
50
|
+
project.task('package'=>project.task('build'))
|
51
|
+
project.group ||= project.parent && project.parent.group || project.name
|
52
|
+
project.version ||= project.parent && project.parent.version
|
53
|
+
end
|
54
|
+
|
55
|
+
# The project's identifier. Same as the project name, with colons replaced by dashes.
|
56
|
+
# The ID for project foo:bar is foo-bar.
|
57
|
+
def id
|
58
|
+
name.gsub(':', '-')
|
59
|
+
end
|
60
|
+
|
61
|
+
# Group used for packaging. Inherited from parent project. Defaults to the top-level project name.
|
62
|
+
attr_accessor :group
|
63
|
+
|
64
|
+
# Version used for packaging. Inherited from parent project.
|
65
|
+
attr_accessor :version
|
66
|
+
|
67
|
+
# :call-seq:
|
68
|
+
# package(type, spec?) => task
|
69
|
+
#
|
70
|
+
# Defines and returns a package created by this project.
|
71
|
+
#
|
72
|
+
# The first argument declares the package type. For example, :jar to create a JAR file.
|
73
|
+
# The package is an artifact that takes its artifact specification from the project.
|
74
|
+
# You can override the artifact specification by passing various options in the second
|
75
|
+
# argument, for example:
|
76
|
+
# package(:zip, :classifier=>'sources')
|
77
|
+
#
|
78
|
+
# Packages that are ZIP files provides various ways to include additional files, directories,
|
79
|
+
# and even merge ZIPs together. Have a look at ZipTask for more information. In case you're
|
80
|
+
# wondering, JAR and WAR packages are ZIP files.
|
81
|
+
#
|
82
|
+
# You can also enhance a JAR package using the ZipTask#with method that accepts the following options:
|
83
|
+
# * :manifest -- Specifies how to create the MANIFEST.MF. By default, uses the project's
|
84
|
+
# #manifest property.
|
85
|
+
# * :meta_inf -- Specifies files to be included in the META-INF directory. By default,
|
86
|
+
# uses the project's #meta-inf property.
|
87
|
+
#
|
88
|
+
# The WAR package supports the same options and adds a few more:
|
89
|
+
# * :classes -- Directories of class files to include in WEB-INF/classes. Includes the compile
|
90
|
+
# target directory by default.
|
91
|
+
# * :libs -- Artifacts and files to include in WEB-INF/libs. Includes the compile classpath
|
92
|
+
# dependencies by default.
|
93
|
+
#
|
94
|
+
# For example:
|
95
|
+
# define 'project' do
|
96
|
+
# define 'beans' do
|
97
|
+
# package :jar
|
98
|
+
# end
|
99
|
+
# define 'webapp' do
|
100
|
+
# compile.with project('beans')
|
101
|
+
# package(:war).with :libs=>MYSQL_JDBC
|
102
|
+
# end
|
103
|
+
# package(:zip, :classifier=>'sources').include path_to('.')
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# Two other packaging types are:
|
107
|
+
# * package :sources -- Creates a ZIP file with the source code and classifier 'sources', for use by IDEs.
|
108
|
+
# * package :javadoc -- Creates a ZIP file with the Javadocs and classifier 'javadoc'. You can use the
|
109
|
+
# javadoc method to further customize it.
|
110
|
+
#
|
111
|
+
# A package is also an artifact. The following tasks operate on packages created by the project:
|
112
|
+
# buildr upload # Upload packages created by the project
|
113
|
+
# buildr install # Install packages created by the project
|
114
|
+
# buildr package # Create packages
|
115
|
+
# buildr uninstall # Remove previously installed packages
|
116
|
+
#
|
117
|
+
# If you want to add additional packaging types, implement a method with the name package_as_[type]
|
118
|
+
# that accepts a file name and returns an appropriate Rake task. For example:
|
119
|
+
# def package_as_zip(file_name) #:nodoc:
|
120
|
+
# ZipTask.define_task(file_name)
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# The file name is determined from the specification passed to the package method, however, some
|
124
|
+
# packagers need to override this. For example, package(:sources) produces a file with the extension
|
125
|
+
# 'zip' and the classifier 'sources'. If you need to overwrite the default implementation, you should
|
126
|
+
# also include a method named package_as_[type]_respec. For example:
|
127
|
+
# def package_as_sources_spec(spec) #:nodoc:
|
128
|
+
# { :type=>:zip, :classifier=>'sources' }.merge(spec)
|
129
|
+
# end
|
130
|
+
def package(*args)
|
131
|
+
spec = Hash === args.last ? args.pop.dup : {}
|
132
|
+
no_options = spec.empty? # since spec is mutated
|
133
|
+
if spec[:file]
|
134
|
+
rake_check_options spec, :file, :type
|
135
|
+
spec[:type] = args.shift || spec[:type] || spec[:file].split('.').last
|
136
|
+
file_name = spec[:file]
|
137
|
+
else
|
138
|
+
rake_check_options spec, *ActsAsArtifact::ARTIFACT_ATTRIBUTES
|
139
|
+
spec[:id] ||= self.id
|
140
|
+
spec[:group] ||= self.group
|
141
|
+
spec[:version] ||= self.version
|
142
|
+
spec[:type] = args.shift || spec[:type] || compile.packaging || :zip
|
143
|
+
end
|
144
|
+
|
145
|
+
packager = method("package_as_#{spec[:type]}") rescue fail("Don't know how to create a package of type #{spec[:type]}")
|
146
|
+
if packager.arity == 1
|
147
|
+
unless file_name
|
148
|
+
spec = send("package_as_#{spec[:type]}_spec", spec) if respond_to?("package_as_#{spec[:type]}_spec")
|
149
|
+
file_name = path_to(:target, Artifact.hash_to_file_name(spec))
|
150
|
+
end
|
151
|
+
package = (no_options && packages.detect { |pkg| pkg.type == spec[:type] &&
|
152
|
+
(spec[:classifier].nil? || pkg.classifier == spec[:classifier])}) ||
|
153
|
+
packages.find { |pkg| pkg.name == file_name } ||
|
154
|
+
packager.call(file_name)
|
155
|
+
else
|
156
|
+
Buildr.application.deprecated "We changed the way package_as methods are implemented. See the package method documentation for more details."
|
157
|
+
file_name ||= path_to(:target, Artifact.hash_to_file_name(spec))
|
158
|
+
package = packager.call(file_name, spec)
|
159
|
+
end
|
160
|
+
|
161
|
+
# First time: prepare package for install, uninstall and upload tasks.
|
162
|
+
unless packages.include?(package)
|
163
|
+
# We already run build before package, but we also need to do so if the package itself is
|
164
|
+
# used as a dependency, before we get to run the package task.
|
165
|
+
task 'package'=>package
|
166
|
+
package.enhance [task('build')]
|
167
|
+
package.enhance { info "Packaging #{File.basename(file_name)}" }
|
168
|
+
|
169
|
+
if spec[:file]
|
170
|
+
class << package ; self ; end.send(:define_method, :type) { spec[:type] }
|
171
|
+
else
|
172
|
+
# Make it an artifact using the specifications, and tell it how to create a POM.
|
173
|
+
package.extend ActsAsArtifact
|
174
|
+
package.send :apply_spec, spec.only(*Artifact::ARTIFACT_ATTRIBUTES)
|
175
|
+
# Another task to create the POM file.
|
176
|
+
pom = package.pom
|
177
|
+
pom.enhance do
|
178
|
+
mkpath File.dirname(pom.name)
|
179
|
+
File.open(pom.name, 'w') { |file| file.write pom.pom_xml }
|
180
|
+
end
|
181
|
+
file(Buildr.repositories.locate(package)=>package) { package.install }
|
182
|
+
|
183
|
+
# Add the package to the list of packages created by this project, and
|
184
|
+
# register it as an artifact. The later is required so if we look up the spec
|
185
|
+
# we find the package in the project's target directory, instead of finding it
|
186
|
+
# in the local repository and attempting to install it.
|
187
|
+
Artifact.register package, pom
|
188
|
+
end
|
189
|
+
|
190
|
+
task('install') { package.install if package.respond_to?(:install) }
|
191
|
+
task('uninstall') { package.uninstall if package.respond_to?(:uninstall) }
|
192
|
+
task('upload') { package.upload if package.respond_to?(:upload) }
|
193
|
+
|
194
|
+
packages << package
|
195
|
+
end
|
196
|
+
package
|
197
|
+
end
|
198
|
+
|
199
|
+
# :call-seq:
|
200
|
+
# packages => tasks
|
201
|
+
#
|
202
|
+
# Returns all packages created by this project. A project may create any number of packages.
|
203
|
+
#
|
204
|
+
# This method is used whenever you pass a project to Buildr#artifact or any other method
|
205
|
+
# that accepts artifact specifications and projects. You can use it to list all packages
|
206
|
+
# created by the project. If you want to return a specific package, it is often more
|
207
|
+
# convenient to call #package with the type.
|
208
|
+
def packages
|
209
|
+
@packages ||= []
|
210
|
+
end
|
211
|
+
|
212
|
+
protected
|
213
|
+
|
214
|
+
def package_as_zip(file_name) #:nodoc:
|
215
|
+
ZipTask.define_task(file_name)
|
216
|
+
end
|
217
|
+
|
218
|
+
def package_as_tar(file_name) #:nodoc:
|
219
|
+
TarTask.define_task(file_name)
|
220
|
+
end
|
221
|
+
alias :package_as_tgz :package_as_tar
|
222
|
+
|
223
|
+
def package_as_sources_spec(spec) #:nodoc:
|
224
|
+
spec.merge(:type=>:zip, :classifier=>'sources')
|
225
|
+
end
|
226
|
+
|
227
|
+
def package_as_sources(file_name) #:nodoc:
|
228
|
+
ZipTask.define_task(file_name).tap do |zip|
|
229
|
+
zip.include :from=>compile.sources
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class Buildr::Project
|
237
|
+
include Buildr::Package
|
238
|
+
end
|