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:
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/buildr/java/compiler.rb', line 113 def initialize(*args) #:nodoc: super @options = {} @classpath = [] @sourcepath = [] @files = FileList[] enhance do |task| rm_rf target.to_s generate source_files, File.(target.to_s), .merge(:classpath=>classpath, :sourcepath=>sourcepath) touch target.to_s end end |
Instance Attribute Details
#classpath ⇒ Object
Classpath dependencies.
162 163 164 |
# File 'lib/buildr/java/compiler.rb', line 162 def classpath @classpath end |
#options ⇒ Object (readonly)
Returns the Javadoc options.
177 178 179 |
# File 'lib/buildr/java/compiler.rb', line 177 def @options end |
#sourcepath ⇒ Object
Additional sourcepaths that are not part of the documented files.
174 175 176 |
# File 'lib/buildr/java/compiler.rb', line 174 def sourcepath @sourcepath end |
#target ⇒ Object (readonly)
The target directory for the generated Javadoc files.
127 128 129 |
# File 'lib/buildr/java/compiler.rb', line 127 def target @target end |
Instance Method Details
#exclude(*files) ⇒ Object
:call-seq:
exclude(*files) => self
Excludes source files and directories from generating the documentation.
156 157 158 159 |
# File 'lib/buildr/java/compiler.rb', line 156 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')
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/buildr/java/compiler.rb', line 204 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.
147 148 149 150 |
# File 'lib/buildr/java/compiler.rb', line 147 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
137 138 139 140 |
# File 'lib/buildr/java/compiler.rb', line 137 def into(path) @target = file(path.to_s).enhance([self]) unless @target && @target.to_s == path.to_s self end |
#needed? ⇒ Boolean
:nodoc:
230 231 232 233 234 |
# File 'lib/buildr/java/compiler.rb', line 230 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:
220 221 222 |
# File 'lib/buildr/java/compiler.rb', line 220 def prerequisites() #:nodoc: super + @files + classpath + sourcepath end |
#source_files ⇒ Object
:nodoc:
224 225 226 227 228 |
# File 'lib/buildr/java/compiler.rb', line 224 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'
186 187 188 189 190 |
# File 'lib/buildr/java/compiler.rb', line 186 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 |