Class: Buildr::Javadoc::JavadocTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- Buildr::Javadoc::JavadocTask
- Defined in:
- lib/buildr/java/compiler.rb
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:
javadoc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
Or, short and sweet:
desc 'My App'
define 'myapp' do
. . .
javadoc projects('myapp:foo', 'myapp:bar')
end
Instance Attribute Summary collapse
-
#classpath ⇒ Object
Classpath dependencies.
-
#options ⇒ Object
readonly
Returns the Javadoc options.
-
#sourcepath ⇒ Object
Additional sourcepaths that are not part of the documented files.
-
#target ⇒ Object
readonly
The target directory for the generated Javadoc files.
Instance Method Summary collapse
-
#exclude(*files) ⇒ Object
:call-seq: exclude(*files) => self.
-
#from(*sources) ⇒ Object
:call-seq: from(*sources) => self.
-
#include(*files) ⇒ Object
:call-seq: include(*files) => self.
-
#initialize(*args) ⇒ JavadocTask
constructor
:nodoc:.
-
#into(path) ⇒ Object
:call-seq: into(path) => self.
-
#needed? ⇒ Boolean
:nodoc:.
-
#prerequisites ⇒ Object
:nodoc:.
-
#source_files ⇒ Object
:nodoc:.
-
#using(*args) ⇒ Object
:call-seq: using(options) => self.
-
#with(*specs) ⇒ Object
:call-seq: with(*artifacts) => self.
Methods inherited from Rake::Task
#invoke, #invoke_with_call_chain
Constructor Details
#initialize(*args) ⇒ JavadocTask
:nodoc:
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/buildr/java/compiler.rb', line 112 def initialize(*args) #:nodoc: super @options = {} @classpath = [] @sourcepath = [] @files = FileList[] enhance do |task| rm_rf target.to_s, :verbose=>false generate source_files, File.(target.to_s), .merge(:classpath=>classpath, :sourcepath=>sourcepath) touch target.to_s, :verbose=>false end end |
Instance Attribute Details
#classpath ⇒ Object
Classpath dependencies.
161 162 163 |
# File 'lib/buildr/java/compiler.rb', line 161 def classpath @classpath end |
#options ⇒ Object (readonly)
Returns the Javadoc options.
176 177 178 |
# File 'lib/buildr/java/compiler.rb', line 176 def @options end |
#sourcepath ⇒ Object
Additional sourcepaths that are not part of the documented files.
173 174 175 |
# File 'lib/buildr/java/compiler.rb', line 173 def sourcepath @sourcepath end |
#target ⇒ Object (readonly)
The target directory for the generated Javadoc files.
126 127 128 |
# File 'lib/buildr/java/compiler.rb', line 126 def target @target end |
Instance Method Details
#exclude(*files) ⇒ Object
:call-seq:
exclude(*files) => self
Excludes source files and directories from generating the documentation.
155 156 157 158 |
# File 'lib/buildr/java/compiler.rb', line 155 def exclude(*files) @files.exclude *files self end |
#from(*sources) ⇒ Object
:call-seq:
from(*sources) => self
Includes files, directories and projects in the Javadoc documentation and returns self.
You can call this method with Java source files and directories containing Java source files to include these files in the Javadoc documentation, similar to #include. You can also call this method with projects. When called with a project, it includes all the source files compiled by that project and classpath dependencies used when compiling.
For example:
javadoc.from projects('myapp:foo', 'myapp:bar')
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/buildr/java/compiler.rb', line 203 def from(*sources) sources.flatten.each do |source| case source when Project self.enhance source.prerequisites self.include source.compile.sources self.with source.compile.dependencies when Rake::Task, String self.include source else fail "Don't know how to generate Javadocs from #{source || 'nil'}" end end self end |
#include(*files) ⇒ Object
:call-seq:
include(*files) => self
Includes additional source files and directories when generating the documentation and returns self. When specifying a directory, includes all .java files in that directory.
146 147 148 149 |
# File 'lib/buildr/java/compiler.rb', line 146 def include(*files) @files.include *files.flatten.compact self end |
#into(path) ⇒ Object
:call-seq:
into(path) => self
Sets the target directory and returns self. This will also set the Javadoc task as a prerequisite to a file task on the target directory.
For example:
package :zip, :classifier=>'docs', :include=>javadoc.target
136 137 138 139 |
# File 'lib/buildr/java/compiler.rb', line 136 def into(path) @target = file(path.to_s).enhance([self]) unless @target && @target.to_s == path.to_s self end |
#needed? ⇒ Boolean
:nodoc:
229 230 231 232 233 |
# File 'lib/buildr/java/compiler.rb', line 229 def needed?() #:nodoc: return false if source_files.empty? return true unless File.exist?(target.to_s) source_files.map { |src| File.stat(src.to_s).mtime }.max > File.stat(target.to_s).mtime end |
#prerequisites ⇒ Object
:nodoc:
219 220 221 |
# File 'lib/buildr/java/compiler.rb', line 219 def prerequisites() #:nodoc: super + @files + classpath + sourcepath end |
#source_files ⇒ Object
:nodoc:
223 224 225 226 227 |
# File 'lib/buildr/java/compiler.rb', line 223 def source_files() #:nodoc: @source_files ||= @files.map(&:to_s). map { |file| File.directory?(file) ? FileList[File.join(file, "**/*.java")] : file }. flatten.reject { |file| @files.exclude?(file) } end |
#using(*args) ⇒ Object
:call-seq:
using() => self
Sets the Javadoc options from a hash and returns self.
For example:
javadoc.using :windowtitle=>'My application'
185 186 187 188 189 |
# File 'lib/buildr/java/compiler.rb', line 185 def using(*args) args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last args.each { |key| @options[key.to_sym] = true } self end |