Class: Buildr::Compiler::Ajc
- Inherits:
-
Base
- Object
- Base
- Buildr::Compiler::Ajc
- Defined in:
- lib/ajc.rb
Constant Summary collapse
- REQUIRES =
Buildr.struct( #:aspectj => "org.aspectj:aspectjrt:jar:1.6.9", #:aspectjlib => "org.aspectj:aspectjlib:jar:1.6.2", #:aspectjweaver => "org.aspectj:aspectjweaver:jar:1.6.9", :aspectjtools => "org.aspectj:aspectjtools:jar:1.6.9" )
- OPTIONS =
[:warnings, :debug, :deprecation, :source, :target, :lint, :other, :Xlint, :aspectpath, :verbose]
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
-
#compile(sources, target, dependencies) ⇒ Object
:nodoc:.
-
#initialize(project, options) ⇒ Ajc
constructor
:nodoc:.
Constructor Details
#initialize(project, options) ⇒ Ajc
:nodoc:
26 27 28 29 |
# File 'lib/ajc.rb', line 26 def initialize(project, ) #:nodoc: super @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
24 25 26 |
# File 'lib/ajc.rb', line 24 def project @project end |
Instance Method Details
#compile(sources, target, dependencies) ⇒ Object
:nodoc:
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ajc.rb', line 31 def compile(sources, target, dependencies) #:nodoc: return if Buildr.application..dryrun info "options: #{.inspect}" info "sources: #{sources.inspect}" info "dependencies: #{dependencies}" [:source] ||= "1.6" cmd_args = [] cmd_args << '-d' << File.(target) cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty? in_paths = sources.select { |source| File.directory?(source) } puts "inpath: #{in_paths.inspect}" cmd_args << '-inpath' << in_paths.join(File::PATH_SEPARATOR) unless in_paths.empty? cmd_args += javac_args cmd_args += files_from_sources(sources) aspect_path = [] if [:aspectpath] and not [:aspectpath].empty? dependencies.each { |dep| [:aspectpath].each { |regex| aspect_path<< dep if Regexp.new(regex).match dep} } end aspect_path << [:test_apspectpath] if [:test_apspectpath] info "aspect path: #{aspect_path.inspect}" cmd_args << '-aspectpath' << aspect_path.join(File::PATH_SEPARATOR) Java.load # may be called by other extension before...so this has no effect = Java.org.aspectj.bridge.MessageHandler.new Java.org.aspectj.tools.ajc.Main.new.run(cmd_args.to_java(Java.java.lang.String), ) .get_unmodifiable_list_view.each { |i| info i } if [:verbose] .get_warnings.each { |w| warn w } .get_errors.each { |e| error e } fail 'Failed to compile, see errors above' if .get_errors.length > 0 end |