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.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,432 @@
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 (e.g. '-implicit:none')
40
+ class Javac < Base
41
+
42
+ OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
43
+
44
+ specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
45
+
46
+ def initialize(project, options) #:nodoc:
47
+ super
48
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
49
+ options[:warnings] = verbose if options[:warnings].nil?
50
+ options[:deprecation] ||= false
51
+ options[:lint] ||= false
52
+ end
53
+
54
+ def compile(sources, target, dependencies) #:nodoc:
55
+ check_options options, OPTIONS
56
+ cmd_args = []
57
+ tools = File.expand_path('lib/tools.jar', ENV['JAVA_HOME']) if ENV['JAVA_HOME']
58
+ dependencies << tools if tools && File.exist?(tools)
59
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
60
+ source_paths = sources.select { |source| File.directory?(source) }
61
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
62
+ cmd_args << '-d' << File.expand_path(target)
63
+ cmd_args += javac_args
64
+ cmd_args += files_from_sources(sources)
65
+ unless Buildr.application.options.dryrun
66
+ puts (['javac'] + cmd_args).join(' ') if Buildr.application.options.trace
67
+ Java.load
68
+ Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
69
+ fail 'Failed to compile, see errors above'
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def javac_args #:nodoc:
76
+ args = []
77
+ args << '-nowarn' unless options[:warnings]
78
+ args << '-verbose' if Buildr.application.options.trace
79
+ args << '-g' if options[:debug]
80
+ args << '-deprecation' if options[:deprecation]
81
+ args << '-source' << options[:source].to_s if options[:source]
82
+ args << '-target' << options[:target].to_s if options[:target]
83
+ case options[:lint]
84
+ when Array then args << "-Xlint:#{options[:lint].join(',')}"
85
+ when String then args << "-Xlint:#{options[:lint]}"
86
+ when true then args << '-Xlint'
87
+ end
88
+ args + Array(options[:other])
89
+ end
90
+
91
+ end
92
+
93
+
94
+ # Scalac compiler:
95
+ # compile.using(:scalac)
96
+ # Used by default if .scala files are found in the src/main/scala directory (or src/test/scala)
97
+ # and sets the target directory to target/classes (or target/test/classes).
98
+ #
99
+ # Accepts the following options:
100
+ # * :warnings -- Generate warnings if true (opposite of -nowarn).
101
+ # * :deprecation -- Output source locations where deprecated APIs are used.
102
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
103
+ # * :source -- Source compatibility with specified release.
104
+ # * :target -- Class file compatibility with specified release.
105
+ # * :debug -- Generate debugging info.
106
+ # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
107
+ class Scalac < Base
108
+ class << self
109
+ def scala_home
110
+ @home ||= ENV['SCALA_HOME']
111
+ end
112
+
113
+ def dependencies
114
+ [ 'scala-library.jar', 'scala-compiler.jar'].map { |jar| File.expand_path("lib/#{jar}", scala_home) }
115
+ end
116
+
117
+ def use_fsc
118
+ ENV["USE_FSC"] =~ /^(yes|on|true)$/i
119
+ end
120
+ end
121
+
122
+ OPTIONS = [:warnings, :deprecation, :optimise, :source, :target, :debug, :other]
123
+ Java.classpath << dependencies unless Scalac.use_fsc
124
+
125
+ specify :language=>:scala, :target=>'classes', :target_ext=>'class', :packaging=>:jar
126
+
127
+ def initialize(project, options) #:nodoc:
128
+ super
129
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
130
+ options[:warnings] = verbose if options[:warnings].nil?
131
+ options[:deprecation] ||= false
132
+ options[:optimise] ||= false
133
+ end
134
+
135
+ def compile(sources, target, dependencies) #:nodoc:
136
+ check_options options, OPTIONS
137
+
138
+ cmd_args = []
139
+ cmd_args << '-classpath' << (dependencies + Scalac.dependencies).join(File::PATH_SEPARATOR)
140
+ source_paths = sources.select { |source| File.directory?(source) }
141
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
142
+ cmd_args << '-d' << File.expand_path(target)
143
+ cmd_args += scalac_args
144
+ cmd_args += files_from_sources(sources)
145
+
146
+ unless Buildr.application.options.dryrun
147
+ Scalac.scala_home or fail 'Are we forgetting something? SCALA_HOME not set.'
148
+ puts (['scalac'] + cmd_args).join(' ') if Buildr.application.options.trace
149
+ if Scalac.use_fsc
150
+ system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
151
+ fail 'Failed to compile, see errors above'
152
+ else
153
+ Java.load
154
+ Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
155
+ fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
156
+ end
157
+ end
158
+ end
159
+
160
+ private
161
+
162
+ # Returns Scalac command line arguments from the set of options.
163
+ def scalac_args #:nodoc:
164
+ args = []
165
+ args << "-nowarn" unless options[:warnings]
166
+ args << "-verbose" if Buildr.application.options.trace
167
+ args << "-g" if options[:debug]
168
+ args << "-deprecation" if options[:deprecation]
169
+ args << "-optimise" if options[:optimise]
170
+ args << "-source" << options[:source].to_s if options[:source]
171
+ args << "-target:jvm-" + options[:target].to_s if options[:target]
172
+ args + Array(options[:other])
173
+ end
174
+
175
+ end
176
+ end
177
+
178
+
179
+ # Methods added to Project for creating JavaDoc documentation.
180
+ module Javadoc
181
+
182
+ # A convenient task for creating Javadocs from the project's compile task. Minimizes all
183
+ # the hard work to calling #from and #using.
184
+ #
185
+ # For example:
186
+ # javadoc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
187
+ # Or, short and sweet:
188
+ # desc 'My App'
189
+ # define 'myapp' do
190
+ # . . .
191
+ # javadoc projects('myapp:foo', 'myapp:bar')
192
+ # end
193
+ class JavadocTask < Rake::Task
194
+
195
+ def initialize(*args) #:nodoc:
196
+ super
197
+ @options = {}
198
+ @classpath = []
199
+ @sourcepath = []
200
+ @files = FileList[]
201
+ enhance do |task|
202
+ rm_rf target.to_s, :verbose=>false
203
+ generate source_files, File.expand_path(target.to_s), options.merge(:classpath=>classpath, :sourcepath=>sourcepath)
204
+ touch target.to_s, :verbose=>false
205
+ end
206
+ end
207
+
208
+ # The target directory for the generated Javadoc files.
209
+ attr_reader :target
210
+
211
+ # :call-seq:
212
+ # into(path) => self
213
+ #
214
+ # Sets the target directory and returns self. This will also set the Javadoc task
215
+ # as a prerequisite to a file task on the target directory.
216
+ #
217
+ # For example:
218
+ # package :zip, :classifier=>'docs', :include=>javadoc.target
219
+ def into(path)
220
+ @target = file(path.to_s).enhance([self]) unless @target && @target.to_s == path.to_s
221
+ self
222
+ end
223
+
224
+ # :call-seq:
225
+ # include(*files) => self
226
+ #
227
+ # Includes additional source files and directories when generating the documentation
228
+ # and returns self. When specifying a directory, includes all .java files in that directory.
229
+ def include(*files)
230
+ @files.include *files.flatten.compact
231
+ self
232
+ end
233
+
234
+ # :call-seq:
235
+ # exclude(*files) => self
236
+ #
237
+ # Excludes source files and directories from generating the documentation.
238
+ def exclude(*files)
239
+ @files.exclude *files
240
+ self
241
+ end
242
+
243
+ # Classpath dependencies.
244
+ attr_accessor :classpath
245
+
246
+ # :call-seq:
247
+ # with(*artifacts) => self
248
+ #
249
+ # Adds files and artifacts as classpath dependencies, and returns self.
250
+ def with(*specs)
251
+ @classpath |= Buildr.artifacts(specs.flatten).uniq
252
+ self
253
+ end
254
+
255
+ # Additional sourcepaths that are not part of the documented files.
256
+ attr_accessor :sourcepath
257
+
258
+ # Returns the Javadoc options.
259
+ attr_reader :options
260
+
261
+ # :call-seq:
262
+ # using(options) => self
263
+ #
264
+ # Sets the Javadoc options from a hash and returns self.
265
+ #
266
+ # For example:
267
+ # javadoc.using :windowtitle=>'My application'
268
+ def using(*args)
269
+ args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
270
+ args.each { |key| @options[key.to_sym] = true }
271
+ self
272
+ end
273
+
274
+ # :call-seq:
275
+ # from(*sources) => self
276
+ #
277
+ # Includes files, directories and projects in the Javadoc documentation and returns self.
278
+ #
279
+ # You can call this method with Java source files and directories containing Java source files
280
+ # to include these files in the Javadoc documentation, similar to #include. You can also call
281
+ # this method with projects. When called with a project, it includes all the source files compiled
282
+ # by that project and classpath dependencies used when compiling.
283
+ #
284
+ # For example:
285
+ # javadoc.from projects('myapp:foo', 'myapp:bar')
286
+ def from(*sources)
287
+ sources.flatten.each do |source|
288
+ case source
289
+ when Project
290
+ self.enhance source.prerequisites
291
+ self.include source.compile.sources
292
+ self.with source.compile.dependencies
293
+ when Rake::Task, String
294
+ self.include source
295
+ else
296
+ fail "Don't know how to generate Javadocs from #{source || 'nil'}"
297
+ end
298
+ end
299
+ self
300
+ end
301
+
302
+ def prerequisites() #:nodoc:
303
+ super + @files + classpath + sourcepath
304
+ end
305
+
306
+ def source_files() #:nodoc:
307
+ @source_files ||= @files.map(&:to_s).
308
+ map { |file| File.directory?(file) ? FileList[File.join(file, "**/*.java")] : file }.
309
+ flatten.reject { |file| @files.exclude?(file) }
310
+ end
311
+
312
+ def needed?() #:nodoc:
313
+ return false if source_files.empty?
314
+ return true unless File.exist?(target.to_s)
315
+ source_files.map { |src| File.stat(src.to_s).mtime }.max > File.stat(target.to_s).mtime
316
+ end
317
+
318
+ private
319
+
320
+ def generate(sources, target, options = {})
321
+ cmd_args = [ '-d', target, Buildr.application.options.trace ? '-verbose' : '-quiet' ]
322
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
323
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
324
+ each do |key, value|
325
+ case value
326
+ when true, nil
327
+ cmd_args << "-#{key}"
328
+ when false
329
+ cmd_args << "-no#{key}"
330
+ when Hash
331
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
332
+ else
333
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
334
+ end
335
+ end
336
+ [:sourcepath, :classpath].each do |option|
337
+ Array(options[option]).flatten.tap do |paths|
338
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
339
+ end
340
+ end
341
+ cmd_args += sources.flatten.uniq
342
+ unless Buildr.application.options.dryrun
343
+ puts "Generating Javadoc for #{name}" if verbose
344
+ puts (['javadoc'] + cmd_args).join(' ') if Buildr.application.options.trace
345
+ Java.load
346
+ Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
347
+ fail 'Failed to generate Javadocs, see errors above'
348
+ end
349
+ end
350
+
351
+ end
352
+
353
+
354
+ include Extension
355
+
356
+ first_time do
357
+ desc 'Create the Javadocs for this project'
358
+ Project.local_task('javadoc')
359
+ end
360
+
361
+ before_define do |project|
362
+ JavadocTask.define_task('javadoc').tap do |javadoc|
363
+ javadoc.into project.path_to(:target, :javadoc)
364
+ javadoc.using :windowtitle=>project.comment || project.name
365
+ end
366
+ end
367
+
368
+ after_define do |project|
369
+ project.javadoc.from project
370
+ end
371
+
372
+ # :call-seq:
373
+ # javadoc(*sources) => JavadocTask
374
+ #
375
+ # This method returns the project's Javadoc task. It also accepts a list of source files,
376
+ # directories and projects to include when generating the Javadocs.
377
+ #
378
+ # By default the Javadoc task uses all the source directories from compile.sources and generates
379
+ # Javadocs in the target/javadoc directory. This method accepts sources and adds them by calling
380
+ # JavadocsTask#from.
381
+ #
382
+ # For example, if you want to generate Javadocs for a given project that includes all source files
383
+ # in two of its sub-projects:
384
+ # javadoc projects('myapp:foo', 'myapp:bar').using(:windowtitle=>'Docs for foo and bar')
385
+ def javadoc(*sources, &block)
386
+ task('javadoc').from(*sources).enhance &block
387
+ end
388
+
389
+ end
390
+
391
+
392
+ # Methods added to Project to support the Java Annotation Processor.
393
+ module Apt
394
+
395
+ # :call-seq:
396
+ # apt(*sources) => task
397
+ #
398
+ # Returns a task that will use Java#apt to generate source files in target/generated/apt,
399
+ # from all the source directories passed as arguments. Uses the compile.sources list if
400
+ # on arguments supplied.
401
+ #
402
+ # For example:
403
+ #
404
+ def apt(*sources)
405
+ sources = compile.sources if sources.empty?
406
+ file(path_to(:target, 'generated/apt')=>sources) do |task|
407
+ cmd_args = [ Buildr.application.options.trace ? '-verbose' : '-nowarn' ]
408
+ cmd_args << '-nocompile' << '-s' << task.name
409
+ cmd_args << '-source' << compile.options.source if compile.options.source
410
+ classpath = Buildr.artifacts(compile.dependencies).map(&:to_s).each { |t| task(t).invoke }
411
+ cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
412
+ cmd_args += (sources.map(&:to_s) - [task.name]).
413
+ map { |file| File.directory?(file) ? FileList["#{file}/**/*.java"] : file }.flatten
414
+ unless Buildr.application.options.dryrun
415
+ puts 'Running apt' if verbose
416
+ puts (['apt'] + cmd_args).join(' ') if Buildr.application.options.trace
417
+ Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
418
+ fail 'Failed to process annotations, see errors above'
419
+ end
420
+ end
421
+ end
422
+
423
+ end
424
+
425
+ end
426
+
427
+ Buildr::Compiler << Buildr::Compiler::Javac
428
+ Buildr::Compiler << Buildr::Compiler::Scalac
429
+ class Buildr::Project
430
+ include Buildr::Javadoc
431
+ include Buildr::Apt
432
+ 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