Method: Bee::Task::Java#javadoc

Defined in:
lib/bee_task_java.rb

#javadoc(params) ⇒ Object

Generate Java documentation. Parameters is a hash with following entries:

  • src: directory or list of directories for Java source files to document.

  • includes: glob or list of globs for files to document.

  • excludes: glob or list of globs for files to exclude from documentation.

  • dest: destination directory for generated documentation.

  • verbose: tells if we should generate verbose output, must be true or false (defaults to false).

  • options: custom options to use on command line (optional).

Example

- java.javadoc:
    src: :src
    dest: "#{build_dir}/api"


296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/bee_task_java.rb', line 296

def javadoc(params)
  # check parameters
  params_desc = {
    :src      => { :mandatory => false, :type => :string_or_array },
    :includes => { :mandatory => false, :type => :string_or_array },
    :excludes => { :mandatory => false, :type => :string_or_array },
    :dest     => { :mandatory => true,  :type => :string },
    :verbose  => { :mandatory => false, :type => :boolean,
                   :default => false },
    :options  => { :mandatory => false, :type => :string }
  }
  check_parameters(params, params_desc)
  src      = params[:src]
  includes = params[:includes]
  excludes = params[:excludes]
  dest     = params[:dest]
  verbose  = params[:verbose]
  options  = params[:options]
  error "javadoc 'src' or 'includes' parameter must be specified" unless
    src or includes
  # select files to document
  files = []
  if src
    dirs = Array(src)
    for dir in dirs
      files += Dir.glob("#{dir}/**/*.java")
    end
  end
  if includes
    files = filter_files(nil, includes, excludes)
  end
  files.map! { |file| "\"#{file}\"" }
  # run command line
  puts "Running javadoc on #{files.length} Java source file(s)"
  command = "javadoc -d \"#{dest}\" "
  command += "-quiet " if not verbose
  command += "#{options} " if options
  command += "#{files.join(' ')}"
  puts "Running command '#{command}'" if @verbose
  ok = system(command)
  error "Error running javadoc" unless ok
end