class Buildr::Doc::Groovydoc

Public Instance Methods

generate(sources, target, options = {}) click to toggle source
# File lib/buildr/groovy/doc.rb, line 34
def generate(sources, target, options = {})
 mkdir_p target
 cmd_args = [ '-d', target, trace?(:groovydoc) ? '-verbose' : nil ].compact
 options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
 each { |key, value| value.invoke if value.respond_to?(:invoke) }.
 each do |key, value|
 case value
 when true, nil
 cmd_args << "-#{key}"
 when false
 cmd_args << "-no#{key}"
 when Hash
 value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
 else
 cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
 end
 end
 [:sourcepath, :classpath].each do |option|
 Array(options[option]).flatten.tap do |paths|
 cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
 end
 end
 cmd_args += sources.flatten.uniq
 unless Buildr.application.options.dryrun
 info "Generating Groovydoc for #{project.name}"
 trace (['groovydoc'] + cmd_args).join(' ')
 result = Java::Commands.java('org.codehaus.groovy.tools.groovydoc.Main', cmd_args,
 :classpath => Buildr::Groovy.dependencies)
 end
end