realityforge-buildr 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.md +3 -0
- data/Rakefile +50 -0
- data/addon/buildr/checkstyle-report.xsl +104 -0
- data/addon/buildr/checkstyle.rb +254 -0
- data/addon/buildr/git_auto_version.rb +36 -0
- data/addon/buildr/gpg.rb +90 -0
- data/addon/buildr/gwt.rb +413 -0
- data/addon/buildr/jacoco.rb +161 -0
- data/addon/buildr/pmd.rb +185 -0
- data/addon/buildr/single_intermediate_layout.rb +71 -0
- data/addon/buildr/spotbugs.rb +265 -0
- data/addon/buildr/top_level_generate_dir.rb +37 -0
- data/addon/buildr/wsgen.rb +192 -0
- data/bin/buildr +20 -0
- data/buildr.gemspec +61 -0
- data/lib/buildr.rb +86 -0
- data/lib/buildr/core/application.rb +705 -0
- data/lib/buildr/core/assets.rb +96 -0
- data/lib/buildr/core/build.rb +587 -0
- data/lib/buildr/core/common.rb +167 -0
- data/lib/buildr/core/compile.rb +599 -0
- data/lib/buildr/core/console.rb +124 -0
- data/lib/buildr/core/doc.rb +275 -0
- data/lib/buildr/core/environment.rb +128 -0
- data/lib/buildr/core/filter.rb +405 -0
- data/lib/buildr/core/help.rb +114 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +994 -0
- data/lib/buildr/core/test.rb +776 -0
- data/lib/buildr/core/transports.rb +456 -0
- data/lib/buildr/core/util.rb +77 -0
- data/lib/buildr/ide/idea.rb +1664 -0
- data/lib/buildr/java/commands.rb +230 -0
- data/lib/buildr/java/compiler.rb +85 -0
- data/lib/buildr/java/custom_pom.rb +300 -0
- data/lib/buildr/java/doc.rb +62 -0
- data/lib/buildr/java/packaging.rb +393 -0
- data/lib/buildr/java/pom.rb +191 -0
- data/lib/buildr/java/test_result.rb +54 -0
- data/lib/buildr/java/tests.rb +111 -0
- data/lib/buildr/packaging/archive.rb +586 -0
- data/lib/buildr/packaging/artifact.rb +1113 -0
- data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
- data/lib/buildr/packaging/artifact_search.rb +138 -0
- data/lib/buildr/packaging/package.rb +237 -0
- data/lib/buildr/packaging/version_requirement.rb +189 -0
- data/lib/buildr/packaging/zip.rb +189 -0
- data/lib/buildr/packaging/ziptask.rb +387 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/release.rake +99 -0
- data/spec/addon/checkstyle_spec.rb +58 -0
- data/spec/core/application_spec.rb +576 -0
- data/spec/core/build_spec.rb +922 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +656 -0
- data/spec/core/console_spec.rb +65 -0
- data/spec/core/doc_spec.rb +194 -0
- data/spec/core/extension_spec.rb +200 -0
- data/spec/core/project_spec.rb +736 -0
- data/spec/core/test_spec.rb +1131 -0
- data/spec/core/transport_spec.rb +452 -0
- data/spec/core/util_spec.rb +154 -0
- data/spec/ide/idea_spec.rb +1952 -0
- data/spec/java/commands_spec.rb +79 -0
- data/spec/java/compiler_spec.rb +274 -0
- data/spec/java/custom_pom_spec.rb +165 -0
- data/spec/java/doc_spec.rb +55 -0
- data/spec/java/packaging_spec.rb +786 -0
- data/spec/java/pom_spec.rb +162 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +224 -0
- data/spec/packaging/archive_spec.rb +686 -0
- data/spec/packaging/artifact_namespace_spec.rb +757 -0
- data/spec/packaging/artifact_spec.rb +1351 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +690 -0
- data/spec/sandbox.rb +166 -0
- data/spec/spec_helpers.rb +420 -0
- data/spec/version_requirement_spec.rb +145 -0
- data/spec/xpath_matchers.rb +123 -0
- metadata +295 -0
@@ -0,0 +1,230 @@
|
|
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
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin/i
|
17
|
+
# On OS X we attempt to guess where JAVA_HOME is, if not set
|
18
|
+
ENV['JAVA_HOME'] ||= '/System/Library/Frameworks/JavaVM.framework/Home'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Base module for all things Java.
|
22
|
+
module Java
|
23
|
+
|
24
|
+
# JDK commands: java, javac, javadoc, etc.
|
25
|
+
module Commands
|
26
|
+
|
27
|
+
class << self
|
28
|
+
|
29
|
+
# :call-seq:
|
30
|
+
# java(class, *args, options?)
|
31
|
+
#
|
32
|
+
# Runs Java with the specified arguments.
|
33
|
+
#
|
34
|
+
# Each argument should be provided as separate array value, e.g.
|
35
|
+
#
|
36
|
+
# java("-jar", "yuicompressor-2.4.2.jar", "--type","css",
|
37
|
+
# "src/main/webapp/styles/styles-all.css",
|
38
|
+
# "-o", "src/main/webapp/styles/styles-all-min.css")
|
39
|
+
#
|
40
|
+
# The last argument may be a Hash with additional options:
|
41
|
+
# * :dir -- The working directory from which to execute task..
|
42
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
43
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
44
|
+
# * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
|
45
|
+
# * :properties -- Hash of system properties (e.g. 'path'=>base_dir).
|
46
|
+
# * :name -- Shows this name, otherwise shows the first argument (the class name).
|
47
|
+
# * :verbose -- If true, prints the command and all its argument.
|
48
|
+
# * :pathing_jar -- If true, forces the use of a "pathing" jar, false disables. Nil
|
49
|
+
# will default to using a "pathing" jar under windows with long classpaths.
|
50
|
+
# See http://stackoverflow.com/questions/201816/how-to-set-a-long-java-classpath-in-msdos-windows
|
51
|
+
def java(*args, &block)
|
52
|
+
options = Hash === args.last ? args.pop : {}
|
53
|
+
options[:verbose] ||= trace?(:java)
|
54
|
+
rake_check_options options, :classpath, :java_args, :properties, :name, :verbose, :dir, :pathing_jar
|
55
|
+
|
56
|
+
name = options[:name]
|
57
|
+
if name.nil?
|
58
|
+
name = "java #{args.first}"
|
59
|
+
end
|
60
|
+
|
61
|
+
cmd_args = []
|
62
|
+
if options[:dir]
|
63
|
+
cmd_args << "cd '#{options[:dir]}' && "
|
64
|
+
end
|
65
|
+
cmd_args << path_to_bin('java')
|
66
|
+
cp = classpath_from(options)
|
67
|
+
|
68
|
+
unless cp.empty?
|
69
|
+
if options[:pathing_jar] == true
|
70
|
+
paths = cp.map do |c|
|
71
|
+
File.directory?(c) && !c.end_with?('/') ? "#{c}/" : c.to_s
|
72
|
+
end
|
73
|
+
manifest = Buildr::Packaging::Java::Manifest.new([{'Class-Path' => paths.map{|p| URI.encode(p)}.join(" ")}])
|
74
|
+
tjar = Tempfile.new(%w[javacmd .jar])
|
75
|
+
Zip::OutputStream.open(tjar.path) do |zos|
|
76
|
+
zos.put_next_entry('META-INF/MANIFEST.MF')
|
77
|
+
zos.write manifest.to_s
|
78
|
+
zos.write "\n"
|
79
|
+
end
|
80
|
+
tjar.close
|
81
|
+
|
82
|
+
cmd_args << '-classpath' << tjar.path
|
83
|
+
else
|
84
|
+
cmd_args << '-classpath' << cp.join(File::PATH_SEPARATOR)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
|
88
|
+
cmd_args += (options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split).flatten
|
89
|
+
cmd_args += args.flatten.compact
|
90
|
+
|
91
|
+
tmp = nil
|
92
|
+
begin
|
93
|
+
unless Buildr.application.options.dryrun
|
94
|
+
info "Running #{name}" if name && options[:verbose]
|
95
|
+
block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
|
96
|
+
sh(*cmd_args) do |ok, ps|
|
97
|
+
block.call ok, ps
|
98
|
+
end
|
99
|
+
end
|
100
|
+
ensure
|
101
|
+
unless tmp.nil?
|
102
|
+
tmp.close
|
103
|
+
tmp.unlink
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# :call-seq:
|
109
|
+
# javac(*files, options)
|
110
|
+
#
|
111
|
+
# Runs Javac with the specified arguments.
|
112
|
+
#
|
113
|
+
# The last argument may be a Hash with additional options:
|
114
|
+
# * :output -- Target directory for all compiled class files.
|
115
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
116
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
117
|
+
# * :sourcepath -- Additional source paths to use.
|
118
|
+
# * :javac_args -- Any additional arguments to pass (e.g. -extdirs, -encoding)
|
119
|
+
# * :name -- Shows this name, otherwise shows the working directory.
|
120
|
+
def javac(*args, &block)
|
121
|
+
options = Hash === args.last ? args.pop : {}
|
122
|
+
rake_check_options options, :classpath, :sourcepath, :output, :javac_args, :name
|
123
|
+
|
124
|
+
files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
|
125
|
+
collect { |arg| File.directory?(arg) ? FileList["#{File.expand_path(arg)}/**/*.java"] : File.expand_path(arg) }.flatten
|
126
|
+
name = options[:name] || Dir.pwd
|
127
|
+
|
128
|
+
cmd_args = []
|
129
|
+
cmd_args << path_to_bin('javac')
|
130
|
+
cp = classpath_from(options)
|
131
|
+
cmd_args << '-classpath' << cp.join(File::PATH_SEPARATOR) unless cp.empty?
|
132
|
+
cmd_args << '-sourcepath' << [options[:sourcepath]].flatten.join(File::PATH_SEPARATOR) if options[:sourcepath]
|
133
|
+
cmd_args << '-d' << File.expand_path(options[:output].to_s) if options[:output]
|
134
|
+
cmd_args += options[:javac_args].flatten if options[:javac_args]
|
135
|
+
Tempfile.open('javac') do |tmp|
|
136
|
+
tmp.write files.join(' ')
|
137
|
+
cmd_args << "@#{tmp.path}"
|
138
|
+
end
|
139
|
+
unless Buildr.application.options.dryrun
|
140
|
+
mkdir_p options[:output] if options[:output]
|
141
|
+
info "Compiling #{files.size} source files in #{name}"
|
142
|
+
block = lambda { |ok, res| fail 'Failed to compile, see errors above' unless ok } unless block
|
143
|
+
sh(*cmd_args) do |ok, ps|
|
144
|
+
block.call ok, ps
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# :call-seq:
|
150
|
+
# javadoc(*files, options, &block)
|
151
|
+
#
|
152
|
+
# Runs Javadocs with the specified files and options.
|
153
|
+
#
|
154
|
+
# This method accepts the following special options:
|
155
|
+
# * :output -- The output directory
|
156
|
+
# * :classpath -- Array of classpath dependencies.
|
157
|
+
# * :sourcepath -- Array of sourcepaths (paths or tasks).
|
158
|
+
# * :name -- Shows this name, otherwise shows the working directory.
|
159
|
+
#
|
160
|
+
# All other options are passed to Javadoc as following:
|
161
|
+
# * true -- As is, for example, :author=>true becomes -author
|
162
|
+
# * false -- Prefixed, for example, :index=>false becomes -noindex
|
163
|
+
# * string -- Option with value, for example, :windowtitle=>'My project' becomes -windowtitle "My project"
|
164
|
+
# * array -- Option with set of values separated by spaces.
|
165
|
+
def javadoc(*args, &block)
|
166
|
+
options = Hash === args.last ? args.pop : {}
|
167
|
+
fail 'No output defined for javadoc' if options[:output].nil?
|
168
|
+
options[:output] = File.expand_path(options[:output].to_s)
|
169
|
+
cmd_args = []
|
170
|
+
cmd_args << path_to_bin('javadoc')
|
171
|
+
cmd_args << '-d' << options[:output]
|
172
|
+
cmd_args << (trace?(:javadoc) ? '-verbose' : '-quiet')
|
173
|
+
|
174
|
+
options.reject { |key, value| [:output, :name, :sourcepath, :classpath].include?(key) }.
|
175
|
+
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
176
|
+
each do |key, value|
|
177
|
+
case value
|
178
|
+
when true, nil
|
179
|
+
cmd_args << "-#{key}"
|
180
|
+
when false
|
181
|
+
cmd_args << "-no#{key}"
|
182
|
+
when Hash
|
183
|
+
value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
|
184
|
+
else
|
185
|
+
cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
|
186
|
+
end
|
187
|
+
end
|
188
|
+
[:sourcepath, :classpath].each do |option|
|
189
|
+
options[option].to_a.flatten.tap do |paths|
|
190
|
+
cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
191
|
+
end
|
192
|
+
end
|
193
|
+
files = args.each {|arg| arg.invoke if arg.respond_to?(:invoke)}.collect {|arg| arg.is_a?(Project) ? arg.compile.sources.collect{|dir| Dir["#{File.expand_path(dir.to_s)}/**/*.java"]} : File.expand_path(arg.to_s) }
|
194
|
+
cmd_args += files.flatten.uniq.map(&:to_s)
|
195
|
+
name = options[:name] || Dir.pwd
|
196
|
+
unless Buildr.application.options.dryrun
|
197
|
+
info "Generating Javadoc for #{name}"
|
198
|
+
trace(cmd_args.join(' '))
|
199
|
+
block = lambda { |ok, res| fail 'Failed to generate Javadocs, see errors above' unless ok } unless block
|
200
|
+
sh(*cmd_args) do |ok, ps|
|
201
|
+
block.call ok, ps
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# :call-seq:
|
207
|
+
# path_to_bin(cmd?) => path
|
208
|
+
#
|
209
|
+
# Returns the path to the specified Java command (with no argument to java itself).
|
210
|
+
def path_to_bin(name = nil)
|
211
|
+
home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
|
212
|
+
bin = File.expand_path(File.join(home, 'bin'))
|
213
|
+
fail 'JAVA_HOME environment variable does not point to a valid JRE/JDK installation.' unless File.exist? bin
|
214
|
+
File.expand_path(File.join(bin, name.to_s))
|
215
|
+
end
|
216
|
+
|
217
|
+
protected
|
218
|
+
|
219
|
+
# :call-seq:
|
220
|
+
# classpath_from(options) => files
|
221
|
+
#
|
222
|
+
# Extracts the classpath from the options, expands it by calling artifacts, invokes
|
223
|
+
# each of the artifacts and returns an array of paths.
|
224
|
+
def classpath_from(options)
|
225
|
+
Buildr.artifacts(options[:classpath] || []).map(&:to_s).
|
226
|
+
map { |t| task(t).invoke; File.expand_path(t) }
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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
|
+
module Buildr #:nodoc:
|
17
|
+
module Compiler #:nodoc:
|
18
|
+
|
19
|
+
# Javac compiler:
|
20
|
+
# compile.using(:javac)
|
21
|
+
# Used by default if .java files are found in the src/main/java directory (or src/test/java)
|
22
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
23
|
+
#
|
24
|
+
# Accepts the following options:
|
25
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
26
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
27
|
+
# environment variable/global option.
|
28
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
29
|
+
# * :source -- Source code compatibility.
|
30
|
+
# * :target -- Bytecode compatibility.
|
31
|
+
# * :lint -- Lint option is one of true, false (default), name (e.g. 'cast') or array.
|
32
|
+
# * :other -- Array of options passed to the compiler
|
33
|
+
# (e.g. ['-implicit:none', '-encoding', 'iso-8859-1'])
|
34
|
+
class Javac < Base
|
35
|
+
|
36
|
+
OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
|
37
|
+
|
38
|
+
specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
|
39
|
+
|
40
|
+
def initialize(project, options) #:nodoc:
|
41
|
+
super
|
42
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
43
|
+
options[:warnings] ||= false
|
44
|
+
options[:deprecation] ||= false
|
45
|
+
options[:lint] ||= false
|
46
|
+
end
|
47
|
+
|
48
|
+
def compile(sources, target, dependencies) #:nodoc:
|
49
|
+
check_options options, OPTIONS
|
50
|
+
Java::Commands.javac(files_from_sources(sources),
|
51
|
+
:classpath => dependencies,
|
52
|
+
:sourcepath => sources.select { |source| File.directory?(source) },
|
53
|
+
:output => target,
|
54
|
+
:javac_args => self.javac_args)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Filter out source files that are known to not produce any corresponding .class output file. If we leave
|
58
|
+
# this type of file in the generated compile map the compiler will always be run due to missing output files.
|
59
|
+
def compile_map(sources, target)
|
60
|
+
map = super
|
61
|
+
map.reject! { |key,_| File.basename(key) == 'package-info.java' } || map
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def javac_args #:nodoc:
|
67
|
+
args = []
|
68
|
+
args << '-nowarn' unless options[:warnings]
|
69
|
+
args << '-verbose' if trace?(:javac)
|
70
|
+
args << '-g' if options[:debug]
|
71
|
+
args << '-deprecation' if options[:deprecation]
|
72
|
+
args << '-source' << options[:source].to_s if options[:source]
|
73
|
+
args << '-target' << options[:target].to_s if options[:target]
|
74
|
+
case options[:lint]
|
75
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
76
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
77
|
+
when true then args << '-Xlint'
|
78
|
+
end
|
79
|
+
args + Array(options[:other])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Buildr::Compiler << Buildr::Compiler::Javac
|
@@ -0,0 +1,300 @@
|
|
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
|
+
module Buildr
|
17
|
+
class CustomPom
|
18
|
+
Developer = Struct.new(:id, :name, :email, :roles)
|
19
|
+
|
20
|
+
# Specify the name of the project
|
21
|
+
attr_writer :name
|
22
|
+
|
23
|
+
# Retrieve the name of the project, defaulting to the project description or the name if not specified
|
24
|
+
def name
|
25
|
+
@name || @buildr_project.comment || @buildr_project.name
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify a project description
|
29
|
+
attr_writer :description
|
30
|
+
|
31
|
+
# Retrieve the project description, defaulting to the name if not specified
|
32
|
+
def description
|
33
|
+
@description || name
|
34
|
+
end
|
35
|
+
|
36
|
+
# Property for the projects url
|
37
|
+
attr_accessor :url
|
38
|
+
|
39
|
+
# Return the map of licenses for project
|
40
|
+
def licenses
|
41
|
+
@licenses ||= {}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add Apache2 to the list of licenses
|
45
|
+
def add_apache_v2_license
|
46
|
+
self.licenses['The Apache Software License, Version 2.0'] = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_bsd_2_license
|
50
|
+
self.licenses['The BSD 2-Clause License'] = 'http://opensource.org/licenses/BSD-2-Clause'
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_bsd_3_license
|
54
|
+
self.licenses['The BSD 3-Clause License'] = 'http://opensource.org/licenses/BSD-3-Clause'
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_cddl_v1_license
|
58
|
+
self.licenses['Common Development and Distribution License (CDDL-1.0)'] = 'http://opensource.org/licenses/CDDL-1.0'
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_epl_v1_license
|
62
|
+
self.licenses['Eclipse Public License - v 1.0'] = 'http://www.eclipse.org/legal/epl-v10.html'
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_gpl_v1_license
|
66
|
+
self.licenses['GNU General Public License (GPL) version 1.0'] = 'http://www.gnu.org/licenses/gpl-1.0.html'
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_gpl_v2_license
|
70
|
+
self.licenses['GNU General Public License (GPL) version 2.0'] = 'http://www.gnu.org/licenses/gpl-2.0.html'
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_gpl_v3_license
|
74
|
+
self.licenses['GNU General Public License (GPL) version 3.0'] = 'http://www.gnu.org/licenses/gpl-3.0.html'
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_lgpl_v2_license
|
78
|
+
self.licenses['GNU General Lesser Public License (LGPL) version 2.1'] = 'http://www.gnu.org/licenses/lgpl-2.1.html'
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_lgpl_v3_license
|
82
|
+
self.licenses['GNU General Lesser Public License (LGPL) version 3.0'] = 'http://www.gnu.org/licenses/lgpl-3.0.html'
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_mit_license
|
86
|
+
self.licenses['The MIT License'] = 'http://opensource.org/licenses/MIT'
|
87
|
+
end
|
88
|
+
|
89
|
+
attr_accessor :scm_url
|
90
|
+
attr_accessor :scm_connection
|
91
|
+
attr_accessor :scm_developer_connection
|
92
|
+
|
93
|
+
attr_accessor :issues_url
|
94
|
+
attr_accessor :issues_system
|
95
|
+
|
96
|
+
# Add a project like add_github_project('realityforge/gwt-appcache')
|
97
|
+
def add_github_project(project_spec)
|
98
|
+
git_url = "git@github.com:#{project_spec}.git"
|
99
|
+
self.scm_connection = self.scm_developer_connection = "scm:git:#{git_url}"
|
100
|
+
self.scm_url = git_url
|
101
|
+
web_url = "https://github.com/#{project_spec}"
|
102
|
+
self.url = web_url
|
103
|
+
self.issues_url = "#{web_url}/issues"
|
104
|
+
self.issues_system = 'GitHub Issues'
|
105
|
+
end
|
106
|
+
|
107
|
+
def developers
|
108
|
+
@developers ||= []
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_developer(id, name = nil, email = nil, roles = nil)
|
112
|
+
self.developers << Developer.new(id, name, email, roles)
|
113
|
+
end
|
114
|
+
|
115
|
+
def provided_dependencies
|
116
|
+
@provided_dependencies ||= []
|
117
|
+
end
|
118
|
+
|
119
|
+
def provided_dependencies=(provided_dependencies)
|
120
|
+
@provided_dependencies = provided_dependencies
|
121
|
+
end
|
122
|
+
|
123
|
+
def runtime_dependencies
|
124
|
+
@runtime_dependencies ||= []
|
125
|
+
end
|
126
|
+
|
127
|
+
def runtime_dependencies=(runtime_dependencies)
|
128
|
+
@runtime_dependencies = runtime_dependencies
|
129
|
+
end
|
130
|
+
|
131
|
+
def additional_dependencies
|
132
|
+
@additional_dependencies ||= []
|
133
|
+
end
|
134
|
+
|
135
|
+
def additional_dependencies=(additional_dependencies)
|
136
|
+
@additional_dependencies = additional_dependencies
|
137
|
+
end
|
138
|
+
|
139
|
+
def include_transitive_dependencies
|
140
|
+
@include_transitive_dependencies ||= []
|
141
|
+
end
|
142
|
+
|
143
|
+
def include_transitive_dependencies=(include_transitive_dependencies)
|
144
|
+
@include_transitive_dependencies = include_transitive_dependencies
|
145
|
+
end
|
146
|
+
|
147
|
+
def optional_dependencies
|
148
|
+
@optional_dependencies ||= []
|
149
|
+
end
|
150
|
+
|
151
|
+
def optional_dependencies=(optional_dependencies)
|
152
|
+
@optional_dependencies = optional_dependencies
|
153
|
+
end
|
154
|
+
|
155
|
+
# Property that accepts a proc that accepts a dependency and returns a boolean to
|
156
|
+
# determine whether dependency is included in pom or not.
|
157
|
+
attr_accessor :dependency_filter
|
158
|
+
|
159
|
+
protected
|
160
|
+
|
161
|
+
def associate_project(buildr_project)
|
162
|
+
@buildr_project = buildr_project
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.pom_xml(project, package)
|
166
|
+
Proc.new do
|
167
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
168
|
+
xml.instruct!
|
169
|
+
xml.project('xmlns' => 'http://maven.apache.org/POM/4.0.0',
|
170
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
171
|
+
'xsi:schemaLocation' => 'http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd') do
|
172
|
+
xml.modelVersion '4.0.0'
|
173
|
+
xml.groupId project.group
|
174
|
+
xml.artifactId project.id
|
175
|
+
xml.version project.version
|
176
|
+
candidates = project.packages.select{|p| p.classifier.nil? }.collect{|p|p.type.to_s}
|
177
|
+
packaging = !candidates.empty? ? candidates[0] : (project.compile.packaging || :zip).to_s
|
178
|
+
xml.packaging packaging
|
179
|
+
|
180
|
+
xml.name project.pom.name if project.pom.name
|
181
|
+
xml.description project.pom.description if project.pom.description
|
182
|
+
xml.url project.pom.url if project.pom.url
|
183
|
+
|
184
|
+
xml.licenses do
|
185
|
+
project.pom.licenses.each_pair do |name, url|
|
186
|
+
xml.license do
|
187
|
+
xml.name name
|
188
|
+
xml.url url
|
189
|
+
xml.distribution 'repo'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end unless project.pom.licenses.empty?
|
193
|
+
|
194
|
+
if project.pom.scm_url || project.pom.scm_connection || project.pom.scm_developer_connection
|
195
|
+
xml.scm do
|
196
|
+
xml.connection project.pom.scm_connection if project.pom.scm_connection
|
197
|
+
xml.developerConnection project.pom.scm_developer_connection if project.pom.scm_developer_connection
|
198
|
+
xml.url project.pom.scm_url if project.pom.scm_url
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
if project.pom.issues_url
|
203
|
+
xml.issueManagement do
|
204
|
+
xml.url project.pom.issues_url
|
205
|
+
xml.system project.pom.issues_system if project.pom.issues_system
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
xml.developers do
|
210
|
+
project.pom.developers.each do |developer|
|
211
|
+
xml.developer do
|
212
|
+
xml.id developer.id
|
213
|
+
xml.name developer.name if developer.name
|
214
|
+
xml.email developer.email if developer.email
|
215
|
+
if developer.roles
|
216
|
+
xml.roles do
|
217
|
+
developer.roles.each do |role|
|
218
|
+
xml.role role
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end unless project.pom.developers.empty?
|
225
|
+
|
226
|
+
provided_deps = Buildr.artifacts(project.pom.provided_dependencies)
|
227
|
+
runtime_deps = Buildr.artifacts(project.pom.runtime_dependencies)
|
228
|
+
additional_deps = Buildr.artifacts(project.pom.additional_dependencies)
|
229
|
+
include_transitive_deps = Buildr.artifacts(project.pom.include_transitive_dependencies).collect {|dep| dep.to_s}
|
230
|
+
optional_deps = Buildr.artifacts(project.pom.optional_dependencies).collect {|dep| dep.to_s}
|
231
|
+
|
232
|
+
done = []
|
233
|
+
|
234
|
+
deps = []
|
235
|
+
deps += provided_deps.
|
236
|
+
select {|d| d.is_a?(ActsAsArtifact)}.
|
237
|
+
select {|d| !done.include?(d.to_s)}.
|
238
|
+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'provided', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
|
239
|
+
deps += runtime_deps.
|
240
|
+
select {|d| d.is_a?(ActsAsArtifact)}.
|
241
|
+
select {|d| !done.include?(d.to_s)}.
|
242
|
+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'runtime', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
|
243
|
+
deps += additional_deps.
|
244
|
+
select {|d| d.is_a?(ActsAsArtifact)}.
|
245
|
+
select {|d| !done.include?(d.to_s)}.
|
246
|
+
collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)}
|
247
|
+
|
248
|
+
deps +=
|
249
|
+
Buildr.artifacts(project.compile.dependencies).
|
250
|
+
select {|d| d.is_a?(ActsAsArtifact)}.
|
251
|
+
select {|d| !done.include?(d.to_s)}.
|
252
|
+
collect {|d| done << d.to_s; d.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(d.to_s), :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)}
|
253
|
+
|
254
|
+
deps += Buildr.artifacts(project.test.compile.dependencies).
|
255
|
+
select {|d| d.is_a?(ActsAsArtifact)}.
|
256
|
+
select {|d| !done.include?(d.to_s)}.
|
257
|
+
collect {|d| d.to_hash.merge(:scope => 'test', :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)}
|
258
|
+
|
259
|
+
xml.dependencies do
|
260
|
+
deps.select {|dependency| project.pom.dependency_filter.nil? ? true : project.pom.dependency_filter.call(dependency)}.each do |dependency|
|
261
|
+
xml.dependency do
|
262
|
+
xml.groupId dependency[:group]
|
263
|
+
xml.artifactId dependency[:id]
|
264
|
+
xml.version dependency[:version]
|
265
|
+
xml.classifier dependency[:classifier] if dependency[:classifier] && dependency[:classifier].to_s != 'jar'
|
266
|
+
xml.scope dependency[:scope] unless dependency[:scope] == 'compile'
|
267
|
+
xml.optional true if dependency[:optional]
|
268
|
+
unless dependency[:include_transitive]
|
269
|
+
xml.exclusions do
|
270
|
+
xml.exclusion do
|
271
|
+
xml.groupId '*'
|
272
|
+
xml.artifactId '*'
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end unless deps.empty?
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
module CPom
|
284
|
+
module ProjectExtension
|
285
|
+
include Extension
|
286
|
+
|
287
|
+
def pom
|
288
|
+
unless @pom
|
289
|
+
@pom = parent ? parent.pom.dup : Buildr::CustomPom.new
|
290
|
+
@pom.send :associate_project, self
|
291
|
+
end
|
292
|
+
@pom
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
class Buildr::Project
|
299
|
+
include Buildr::CPom::ProjectExtension
|
300
|
+
end
|