Class: Raven::JavaDocTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/raven/java_tasks.rb

Overview

Executes JavaDoc by passing it everything it needs. Stuff like a classpath and sources. The result is generated in target/jdoc. Can be customized exactly in the same way as the javac task.

Instance Method Summary collapse

Instance Method Details

#build_pathObject



282
283
284
# File 'lib/raven/java_tasks.rb', line 282

def build_path
  @build_path ||= []
end

#build_path=(p) ⇒ Object



286
287
288
# File 'lib/raven/java_tasks.rb', line 286

def build_path=(p)
  @build_path = [p]
end

#executeObject



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/raven/java_tasks.rb', line 253

def execute
  super
  classpath = Raven.build_cp(prerequisites)
  classpath << "target/classes"
  @build_path = ["src/main/java"] unless @build_path
  
  puts "Executing JavaDoc using source path #{@build_path.join(' ')}" if RakeFileUtils.verbose_flag
  
  Dir.mkdir("target") unless File.exist?("target")
  Dir.mkdir("target/jdoc")  unless File.exist?("target/jdoc")
  
  packages = Set[]
  @build_path.each do |d|
    Dir.glob("#{d}/**/*.java").each do |java| 
      packages << java[(d.length + 1)..(java.rindex('/') - 1)].gsub(%r{[\\/]}, '.')
    end
  end
  packages = packages.to_a
  
  if (packages.size > 0)
    puts "javadoc -classpath #{classpath.join(CP_SEP)} -sourcepath #{@build_path.join(CP_SEP)} -d target/jdoc #{packages.join(' ')}" if RakeFileUtils.verbose_flag
    `javadoc -classpath #{classpath.join(CP_SEP)} -sourcepath #{@build_path.join(CP_SEP)} -d target/jdoc #{packages.join(' ')}`
    unless $?.exitstatus == 0
      puts "Javadoc failed, see above errors."
      exit
    end
  end
end