Class: Buildr::Java::CompileTask::Options
- Inherits:
-
Object
- Object
- Buildr::Java::CompileTask::Options
- Includes:
- Attributes
- Defined in:
- lib/java/compile.rb
Overview
Compiler options, accessible from Compiler#options.
Supported options are:
-
warnings – Generate warnings if true (opposite of -nowarn).
-
verbose – Output messages about what the compiler is doing.
-
deprecation – Output source locations where deprecated APIs are used.
-
source – Source compatibility with specified release.
-
target – Class file compatibility with specified release.
-
lint – Value to pass to xlint argument. Use true to enable default lint options, or pass a specific setting as string or array of strings.
-
debug – Generate debugging info.
-
other – Array of options to pass to the Java compiler as is.
For example:
.verbose = true
.source = .target = "1.6"
Constant Summary collapse
- OPTIONS =
[:warnings, :verbose, :deprecation, :source, :target, :lint, :debug, :other]
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(parent = nil) ⇒ Options
constructor
A new instance of Options.
-
#javac_args ⇒ Object
Returns Javac command line arguments from the set of options.
- #to_s ⇒ Object
Methods included from Attributes
Constructor Details
#initialize(parent = nil) ⇒ Options
Returns a new instance of Options.
48 49 50 |
# File 'lib/java/compile.rb', line 48 def initialize(parent = nil) @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
52 53 54 |
# File 'lib/java/compile.rb', line 52 def parent @parent end |
Instance Method Details
#clear ⇒ Object
54 55 56 |
# File 'lib/java/compile.rb', line 54 def clear() OPTIONS.each { |name| send "#{name}=", nil } end |
#javac_args ⇒ Object
Returns Javac command line arguments from the set of options.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/java/compile.rb', line 63 def javac_args() args = [] args << "-nowarn" unless warnings && Rake.application..trace args << "-verbose" if verbose args << "-g" if debug args << "-deprecation" if deprecation args << ["-source", source.to_s] if source args << ["-target", target.to_s] if target case lint when Array args << "-Xlint:#{lint.join(',')}" when String args << "-Xlint:#{lint}" when true args << "-Xlint" end args << other if other args end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/java/compile.rb', line 58 def to_s() OPTIONS.inject({}){ |hash, name| hash[name] = send(name) ; hash }.reject{ |name,value| value.nil? }.inspect end |