buildr 1.3.5-x86-mswin32
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 +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,349 @@
|
|
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/common'
|
19
|
+
require 'buildr/core/compile'
|
20
|
+
require 'buildr/packaging'
|
21
|
+
|
22
|
+
|
23
|
+
module Buildr
|
24
|
+
module Compiler
|
25
|
+
|
26
|
+
# Javac compiler:
|
27
|
+
# compile.using(:javac)
|
28
|
+
# Used by default if .java files are found in the src/main/java directory (or src/test/java)
|
29
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
30
|
+
#
|
31
|
+
# Accepts the following options:
|
32
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
33
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
34
|
+
# environment variable/global option.
|
35
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
36
|
+
# * :source -- Source code compatibility.
|
37
|
+
# * :target -- Bytecode compatibility.
|
38
|
+
# * :lint -- Lint option is one of true, false (default), name (e.g. 'cast') or array.
|
39
|
+
# * :other -- Array of options passed to the compiler
|
40
|
+
# (e.g. ['-implicit:none', '-encoding', 'iso-8859-1'])
|
41
|
+
class Javac < Base
|
42
|
+
|
43
|
+
OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
|
44
|
+
|
45
|
+
specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
|
46
|
+
|
47
|
+
def initialize(project, options) #:nodoc:
|
48
|
+
super
|
49
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
50
|
+
options[:warnings] = verbose if options[:warnings].nil?
|
51
|
+
options[:deprecation] ||= false
|
52
|
+
options[:lint] ||= false
|
53
|
+
end
|
54
|
+
|
55
|
+
def compile(sources, target, dependencies) #:nodoc:
|
56
|
+
check_options options, OPTIONS
|
57
|
+
cmd_args = []
|
58
|
+
# tools.jar contains the Java compiler.
|
59
|
+
dependencies << Java.tools_jar if Java.tools_jar
|
60
|
+
cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
|
61
|
+
source_paths = sources.select { |source| File.directory?(source) }
|
62
|
+
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
63
|
+
cmd_args << '-d' << File.expand_path(target)
|
64
|
+
cmd_args += javac_args
|
65
|
+
cmd_args += files_from_sources(sources)
|
66
|
+
unless Buildr.application.options.dryrun
|
67
|
+
trace((['javac'] + cmd_args).join(' '))
|
68
|
+
Java.load
|
69
|
+
Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
70
|
+
fail 'Failed to compile, see errors above'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def javac_args #:nodoc:
|
77
|
+
args = []
|
78
|
+
args << '-nowarn' unless options[:warnings]
|
79
|
+
args << '-verbose' if Buildr.application.options.trace
|
80
|
+
args << '-g' if options[:debug]
|
81
|
+
args << '-deprecation' if options[:deprecation]
|
82
|
+
args << '-source' << options[:source].to_s if options[:source]
|
83
|
+
args << '-target' << options[:target].to_s if options[:target]
|
84
|
+
case options[:lint]
|
85
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
86
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
87
|
+
when true then args << '-Xlint'
|
88
|
+
end
|
89
|
+
args + Array(options[:other])
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Methods added to Project for creating JavaDoc documentation.
|
98
|
+
module Javadoc
|
99
|
+
|
100
|
+
# A convenient task for creating Javadocs from the project's compile task. Minimizes all
|
101
|
+
# the hard work to calling #from and #using.
|
102
|
+
#
|
103
|
+
# For example:
|
104
|
+
# javadoc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
|
105
|
+
# Or, short and sweet:
|
106
|
+
# desc 'My App'
|
107
|
+
# define 'myapp' do
|
108
|
+
# . . .
|
109
|
+
# javadoc projects('myapp:foo', 'myapp:bar')
|
110
|
+
# end
|
111
|
+
class JavadocTask < Rake::Task
|
112
|
+
|
113
|
+
def initialize(*args) #:nodoc:
|
114
|
+
super
|
115
|
+
@options = {}
|
116
|
+
@classpath = []
|
117
|
+
@sourcepath = []
|
118
|
+
@files = FileList[]
|
119
|
+
enhance do |task|
|
120
|
+
rm_rf target.to_s
|
121
|
+
generate source_files, File.expand_path(target.to_s), options.merge(:classpath=>classpath, :sourcepath=>sourcepath)
|
122
|
+
touch target.to_s
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# The target directory for the generated Javadoc files.
|
127
|
+
attr_reader :target
|
128
|
+
|
129
|
+
# :call-seq:
|
130
|
+
# into(path) => self
|
131
|
+
#
|
132
|
+
# Sets the target directory and returns self. This will also set the Javadoc task
|
133
|
+
# as a prerequisite to a file task on the target directory.
|
134
|
+
#
|
135
|
+
# For example:
|
136
|
+
# package :zip, :classifier=>'docs', :include=>javadoc.target
|
137
|
+
def into(path)
|
138
|
+
@target = file(path.to_s).enhance([self]) unless @target && @target.to_s == path.to_s
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
# :call-seq:
|
143
|
+
# include(*files) => self
|
144
|
+
#
|
145
|
+
# Includes additional source files and directories when generating the documentation
|
146
|
+
# and returns self. When specifying a directory, includes all .java files in that directory.
|
147
|
+
def include(*files)
|
148
|
+
@files.include *files.flatten.compact
|
149
|
+
self
|
150
|
+
end
|
151
|
+
|
152
|
+
# :call-seq:
|
153
|
+
# exclude(*files) => self
|
154
|
+
#
|
155
|
+
# Excludes source files and directories from generating the documentation.
|
156
|
+
def exclude(*files)
|
157
|
+
@files.exclude *files
|
158
|
+
self
|
159
|
+
end
|
160
|
+
|
161
|
+
# Classpath dependencies.
|
162
|
+
attr_accessor :classpath
|
163
|
+
|
164
|
+
# :call-seq:
|
165
|
+
# with(*artifacts) => self
|
166
|
+
#
|
167
|
+
# Adds files and artifacts as classpath dependencies, and returns self.
|
168
|
+
def with(*specs)
|
169
|
+
@classpath |= Buildr.artifacts(specs.flatten).uniq
|
170
|
+
self
|
171
|
+
end
|
172
|
+
|
173
|
+
# Additional sourcepaths that are not part of the documented files.
|
174
|
+
attr_accessor :sourcepath
|
175
|
+
|
176
|
+
# Returns the Javadoc options.
|
177
|
+
attr_reader :options
|
178
|
+
|
179
|
+
# :call-seq:
|
180
|
+
# using(options) => self
|
181
|
+
#
|
182
|
+
# Sets the Javadoc options from a hash and returns self.
|
183
|
+
#
|
184
|
+
# For example:
|
185
|
+
# javadoc.using :windowtitle=>'My application'
|
186
|
+
def using(*args)
|
187
|
+
args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
|
188
|
+
args.each { |key| @options[key.to_sym] = true }
|
189
|
+
self
|
190
|
+
end
|
191
|
+
|
192
|
+
# :call-seq:
|
193
|
+
# from(*sources) => self
|
194
|
+
#
|
195
|
+
# Includes files, directories and projects in the Javadoc documentation and returns self.
|
196
|
+
#
|
197
|
+
# You can call this method with Java source files and directories containing Java source files
|
198
|
+
# to include these files in the Javadoc documentation, similar to #include. You can also call
|
199
|
+
# this method with projects. When called with a project, it includes all the source files compiled
|
200
|
+
# by that project and classpath dependencies used when compiling.
|
201
|
+
#
|
202
|
+
# For example:
|
203
|
+
# javadoc.from projects('myapp:foo', 'myapp:bar')
|
204
|
+
def from(*sources)
|
205
|
+
sources.flatten.each do |source|
|
206
|
+
case source
|
207
|
+
when Project
|
208
|
+
self.enhance source.prerequisites
|
209
|
+
self.include source.compile.sources
|
210
|
+
self.with source.compile.dependencies
|
211
|
+
when Rake::Task, String
|
212
|
+
self.include source
|
213
|
+
else
|
214
|
+
fail "Don't know how to generate Javadocs from #{source || 'nil'}"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
self
|
218
|
+
end
|
219
|
+
|
220
|
+
def prerequisites() #:nodoc:
|
221
|
+
super + @files + classpath + sourcepath
|
222
|
+
end
|
223
|
+
|
224
|
+
def source_files() #:nodoc:
|
225
|
+
@source_files ||= @files.map(&:to_s).
|
226
|
+
map { |file| File.directory?(file) ? FileList[File.join(file, "**/*.java")] : file }.
|
227
|
+
flatten.reject { |file| @files.exclude?(file) }
|
228
|
+
end
|
229
|
+
|
230
|
+
def needed?() #:nodoc:
|
231
|
+
return false if source_files.empty?
|
232
|
+
return true unless File.exist?(target.to_s)
|
233
|
+
source_files.map { |src| File.stat(src.to_s).mtime }.max > File.stat(target.to_s).mtime
|
234
|
+
end
|
235
|
+
|
236
|
+
private
|
237
|
+
|
238
|
+
def generate(sources, target, options = {})
|
239
|
+
cmd_args = [ '-d', target, Buildr.application.options.trace ? '-verbose' : '-quiet' ]
|
240
|
+
options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
|
241
|
+
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
242
|
+
each do |key, value|
|
243
|
+
case value
|
244
|
+
when true, nil
|
245
|
+
cmd_args << "-#{key}"
|
246
|
+
when false
|
247
|
+
cmd_args << "-no#{key}"
|
248
|
+
when Hash
|
249
|
+
value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
|
250
|
+
else
|
251
|
+
cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
|
252
|
+
end
|
253
|
+
end
|
254
|
+
[:sourcepath, :classpath].each do |option|
|
255
|
+
Array(options[option]).flatten.tap do |paths|
|
256
|
+
cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
257
|
+
end
|
258
|
+
end
|
259
|
+
cmd_args += sources.flatten.uniq
|
260
|
+
unless Buildr.application.options.dryrun
|
261
|
+
info "Generating Javadoc for #{name}"
|
262
|
+
trace (['javadoc'] + cmd_args).join(' ')
|
263
|
+
Java.load
|
264
|
+
Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
265
|
+
fail 'Failed to generate Javadocs, see errors above'
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
|
272
|
+
include Extension
|
273
|
+
|
274
|
+
first_time do
|
275
|
+
desc 'Create the Javadocs for this project'
|
276
|
+
Project.local_task('javadoc')
|
277
|
+
end
|
278
|
+
|
279
|
+
before_define do |project|
|
280
|
+
JavadocTask.define_task('javadoc').tap do |javadoc|
|
281
|
+
javadoc.into project.path_to(:target, :javadoc)
|
282
|
+
javadoc.using :windowtitle=>project.comment || project.name
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
after_define do |project|
|
287
|
+
project.javadoc.from project
|
288
|
+
end
|
289
|
+
|
290
|
+
# :call-seq:
|
291
|
+
# javadoc(*sources) => JavadocTask
|
292
|
+
#
|
293
|
+
# This method returns the project's Javadoc task. It also accepts a list of source files,
|
294
|
+
# directories and projects to include when generating the Javadocs.
|
295
|
+
#
|
296
|
+
# By default the Javadoc task uses all the source directories from compile.sources and generates
|
297
|
+
# Javadocs in the target/javadoc directory. This method accepts sources and adds them by calling
|
298
|
+
# JavadocsTask#from.
|
299
|
+
#
|
300
|
+
# For example, if you want to generate Javadocs for a given project that includes all source files
|
301
|
+
# in two of its sub-projects:
|
302
|
+
# javadoc projects('myapp:foo', 'myapp:bar').using(:windowtitle=>'Docs for foo and bar')
|
303
|
+
def javadoc(*sources, &block)
|
304
|
+
task('javadoc').from(*sources).enhance &block
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
|
310
|
+
# Methods added to Project to support the Java Annotation Processor.
|
311
|
+
module Apt
|
312
|
+
|
313
|
+
# :call-seq:
|
314
|
+
# apt(*sources) => task
|
315
|
+
#
|
316
|
+
# Returns a task that will use Java#apt to generate source files in target/generated/apt,
|
317
|
+
# from all the source directories passed as arguments. Uses the compile.sources list if
|
318
|
+
# on arguments supplied.
|
319
|
+
#
|
320
|
+
# For example:
|
321
|
+
#
|
322
|
+
def apt(*sources)
|
323
|
+
sources = compile.sources if sources.empty?
|
324
|
+
file(path_to(:target, 'generated/apt')=>sources) do |task|
|
325
|
+
cmd_args = [ Buildr.application.options.trace ? '-verbose' : '-nowarn' ]
|
326
|
+
cmd_args << '-nocompile' << '-s' << task.name
|
327
|
+
cmd_args << '-source' << compile.options.source if compile.options.source
|
328
|
+
classpath = Buildr.artifacts(compile.dependencies).map(&:to_s).each { |t| task(t).invoke }
|
329
|
+
cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
330
|
+
cmd_args += (sources.map(&:to_s) - [task.name]).
|
331
|
+
map { |file| File.directory?(file) ? FileList["#{file}/**/*.java"] : file }.flatten
|
332
|
+
unless Buildr.application.options.dryrun
|
333
|
+
info 'Running apt'
|
334
|
+
trace (['apt'] + cmd_args).join(' ')
|
335
|
+
Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
336
|
+
fail 'Failed to process annotations, see errors above'
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
Buildr::Compiler << Buildr::Compiler::Javac
|
346
|
+
class Buildr::Project
|
347
|
+
include Buildr::Javadoc
|
348
|
+
include Buildr::Apt
|
349
|
+
end
|
@@ -0,0 +1,141 @@
|
|
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
|
+
|
19
|
+
|
20
|
+
module Java
|
21
|
+
|
22
|
+
# *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
|
23
|
+
# From this version forward, we apply with JRuby style for importing Java classes:
|
24
|
+
# Java.java.lang.String.new('hai!')
|
25
|
+
# You still need to call Java.load before using any Java code: it resolves, downloads
|
26
|
+
# and installs various dependencies that are required on the classpath before calling
|
27
|
+
# any Java code (e.g. Ant and its tasks).
|
28
|
+
class JavaWrapper
|
29
|
+
|
30
|
+
include Singleton
|
31
|
+
|
32
|
+
# *Deprecated:* Append to Java.classpath directly.
|
33
|
+
def classpath
|
34
|
+
Buildr.application.deprecated 'Append to Java.classpath instead.'
|
35
|
+
::Java.classpath
|
36
|
+
end
|
37
|
+
|
38
|
+
def classpath=(paths)
|
39
|
+
fail 'Deprecated: Append to Java.classpath, you cannot replace the classpath.'
|
40
|
+
end
|
41
|
+
|
42
|
+
# *Deprecated:* No longer necessary.
|
43
|
+
def setup
|
44
|
+
Buildr.application.deprecated 'See documentation for new way to access Java code.'
|
45
|
+
yield self if block_given?
|
46
|
+
end
|
47
|
+
|
48
|
+
# *Deprecated:* Use Java.load instead.
|
49
|
+
def load
|
50
|
+
Buildr.application.deprecated 'Use Java.load instead.'
|
51
|
+
::Java.load
|
52
|
+
end
|
53
|
+
|
54
|
+
alias :onload :setup
|
55
|
+
|
56
|
+
# *Deprecated:* Use Java.pkg.pkg.ClassName to import a Java class.
|
57
|
+
def import(class_name)
|
58
|
+
Buildr.application.deprecated 'Use Java.pkg.pkg.ClassName to import a Java class.'
|
59
|
+
::Java.instance_eval(class_name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
class << self
|
65
|
+
|
66
|
+
# *Deprecated*: Use Java::Commands.java instead.
|
67
|
+
def java(*args, &block)
|
68
|
+
return send(:method_missing, :java) if args.empty?
|
69
|
+
Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
|
70
|
+
Commands.java(*args, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
# *Deprecated*: Use Java::Commands.apt instead.
|
74
|
+
def apt(*args)
|
75
|
+
Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
|
76
|
+
Commands.apt(*args)
|
77
|
+
end
|
78
|
+
|
79
|
+
# *Deprecated*: Use Java::Commands.javac instead.
|
80
|
+
def javac(*args)
|
81
|
+
Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
|
82
|
+
Commands.javac(*args)
|
83
|
+
end
|
84
|
+
|
85
|
+
# *Deprecated*: Use Java::Commands.javadoc instead.
|
86
|
+
def javadoc(*args)
|
87
|
+
Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
|
88
|
+
Commands.javadoc(*args)
|
89
|
+
end
|
90
|
+
|
91
|
+
# *Deprecated:* Use ENV_JAVA['java.version'] instead.
|
92
|
+
def version
|
93
|
+
Buildr.application.deprecated 'Use ENV_JAVA[\'java.version\'] instead.'
|
94
|
+
Java.load
|
95
|
+
ENV_JAVA['java.version']
|
96
|
+
end
|
97
|
+
|
98
|
+
# *Deprecated:* Use ENV['JAVA_HOME'] instead
|
99
|
+
def home
|
100
|
+
Buildr.application.deprecated 'Use ENV[\'JAVA_HOME\'] instead.'
|
101
|
+
ENV['JAVA_HOME']
|
102
|
+
end
|
103
|
+
|
104
|
+
# *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
|
105
|
+
# From this version forward, we apply with JRuby style for importing Java classes:
|
106
|
+
# Java.java.lang.String.new('hai!')
|
107
|
+
# You still need to call Java.load before using any Java code: it resolves, downloads
|
108
|
+
# and installs various dependencies that are required on the classpath before calling
|
109
|
+
# any Java code (e.g. Ant and its tasks).
|
110
|
+
def wrapper
|
111
|
+
Buildr.application.deprecated 'See documentation for new way to access Java code.'
|
112
|
+
if block_given?
|
113
|
+
Java.load
|
114
|
+
yield JavaWrapper.instance
|
115
|
+
else
|
116
|
+
JavaWrapper.instance
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
alias :rjb :wrapper
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
class Options
|
126
|
+
|
127
|
+
# *Deprecated:* Use ENV['JAVA_OPTS'] instead.
|
128
|
+
def java_args
|
129
|
+
Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
|
130
|
+
(ENV["JAVA_OPTS"] || ENV["JAVA_OPTIONS"]).to_s.split
|
131
|
+
end
|
132
|
+
|
133
|
+
# *Deprecated:* Use ENV['JAVA_OPTS'] instead.
|
134
|
+
def java_args=(args)
|
135
|
+
Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
|
136
|
+
ENV['JAVA_OPTS'] = Array(args).join(' ')
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|