Class: Buildr::Doc::Javadoc
Overview
A convenient task for creating Javadocs from the project’s compile task. Minimizes all the hard work to calling #from and #using.
For example:
doc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
Or, short and sweet:
desc 'My App'
define 'myapp' do
. . .
doc projects('myapp:foo', 'myapp:bar')
end
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Buildr::Doc::Base
Instance Method Details
#generate(sources, target, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/buildr/java/doc.rb', line 48 def generate(sources, target, = {}) cmd_args = [ '-d', target, trace?(:javadoc) ? '-verbose' : '-quiet' ] .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([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..dryrun info "Generating Javadoc for #{project.name}" trace (['javadoc'] + cmd_args).join(' ') Java.load Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or fail 'Failed to generate Javadocs, see errors above' end end |