buildr-ajc 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/LICENSE +3 -0
  2. data/README +3 -0
  3. data/Rakefile +46 -0
  4. data/lib/ajc.rb +107 -0
  5. metadata +68 -0
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ == buildr-ajc
2
+
3
+ Put appropriate LICENSE for your project here.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ == buildr-ajc
2
+
3
+ You should document your project here.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/testtask'
7
+ require 'spec/rake/spectask'
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'buildr-ajc'
11
+ s.version = '1.0.0'
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = ['README', 'LICENSE']
14
+ s.summary = 'java ajc compiler for buildr'
15
+ s.description = s.summary
16
+ s.author = 'Nico Mainka'
17
+ s.email = 'nico.maninka@gmail.com'
18
+ # s.executables = ['your_executable_here']
19
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
20
+ s.require_path = "lib"
21
+ s.bindir = "bin"
22
+ end
23
+
24
+ Rake::GemPackageTask.new(spec) do |p|
25
+ p.gem_spec = spec
26
+ p.need_tar = true
27
+ p.need_zip = true
28
+ end
29
+
30
+ Rake::RDocTask.new do |rdoc|
31
+ files =['README', 'LICENSE', 'lib/**/*.rb']
32
+ rdoc.rdoc_files.add(files)
33
+ rdoc.main = "README" # page to start on
34
+ rdoc.title = "buildr-ajc Docs"
35
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
36
+ rdoc.options << '--line-numbers'
37
+ end
38
+
39
+ Rake::TestTask.new do |t|
40
+ t.test_files = FileList['test/**/*.rb']
41
+ end
42
+
43
+ Spec::Rake::SpecTask.new do |t|
44
+ t.spec_files = FileList['spec/**/*.rb']
45
+ t.libs << Dir["lib"]
46
+ end
data/lib/ajc.rb ADDED
@@ -0,0 +1,107 @@
1
+ require 'buildr/core/project'
2
+ require 'buildr/core/common'
3
+ require 'buildr/core/compile'
4
+ require 'buildr/packaging/artifact'
5
+ require 'buildr/packaging'
6
+
7
+ module Buildr
8
+ module Compiler
9
+ class Ajc < Base
10
+
11
+ REQUIRES = Buildr.struct(
12
+ #:aspectj => "org.aspectj:aspectjrt:jar:1.6.9",
13
+ #:aspectjlib => "org.aspectj:aspectjlib:jar:1.6.2",
14
+ #:aspectjweaver => "org.aspectj:aspectjweaver:jar:1.6.9",
15
+ :aspectjtools => "org.aspectj:aspectjtools:jar:1.6.9"
16
+ ) unless const_defined?('REQUIRES')
17
+
18
+ Java.classpath << Buildr.artifacts(REQUIRES)
19
+
20
+ OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other, :Xlint, :aspectpath, :verbose]
21
+
22
+ specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
23
+
24
+ attr_reader :project
25
+
26
+ def initialize(project, options) #:nodoc:
27
+ super
28
+ @project = project
29
+ end
30
+
31
+ def compile(sources, target, dependencies) #:nodoc:
32
+ return if Buildr.application.options.dryrun
33
+
34
+ info "options: #{options.inspect}"
35
+ info "sources: #{sources.inspect}"
36
+ info "dependencies: #{dependencies}"
37
+
38
+ options[:source] ||= "1.6"
39
+
40
+ cmd_args = []
41
+ cmd_args << '-d' << File.expand_path(target)
42
+
43
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
44
+
45
+ in_paths = sources.select { |source| File.directory?(source) }
46
+ puts "inpath: #{in_paths.inspect}"
47
+ cmd_args << '-inpath' << in_paths.join(File::PATH_SEPARATOR) unless in_paths.empty?
48
+
49
+ cmd_args += javac_args
50
+
51
+ cmd_args += files_from_sources(sources)
52
+
53
+ aspect_path = []
54
+ if options[:aspectpath] and not options[:aspectpath].empty?
55
+ dependencies.each { |dep| options[:aspectpath].each { |regex| aspect_path<< dep if Regexp.new(regex).match dep} }
56
+ end
57
+ aspect_path << options[:test_apspectpath] if options[:test_apspectpath]
58
+ info "aspect path: #{aspect_path.inspect}"
59
+ cmd_args << '-aspectpath' << aspect_path.join(File::PATH_SEPARATOR)
60
+
61
+ Java.load # may be called by other extension before...so this has no effect
62
+
63
+ messages = Java.org.aspectj.bridge.MessageHandler.new
64
+ Java.org.aspectj.tools.ajc.Main.new.run(cmd_args.to_java(Java.java.lang.String), messages)
65
+
66
+ messages.get_unmodifiable_list_view.each { |i| info i } if options[:verbose]
67
+ messages.get_warnings.each { |w| warn w }
68
+ messages.get_errors.each { |e| error e }
69
+
70
+ fail 'Failed to compile, see errors above' if messages.get_errors.length > 0
71
+ end
72
+
73
+ private
74
+
75
+ def javac_args #:nodoc:
76
+ args = []
77
+ args << '-nowarn' unless options[:warnings]
78
+ args << '-verbose' if options[:verbose]
79
+ args << '-g' if options[:debug]
80
+ args << '-deprecation' if options[:deprecation]
81
+ args << '-source' << options[:source].to_s if options[:source]
82
+ args << '-target' << options[:target].to_s if options[:target]
83
+ case options[:lint]
84
+ when Array then args << "-Xlint:#{options[:lint].join(',')}"
85
+ when String then args << "-Xlint:#{options[:lint]}"
86
+ when true then args << '-Xlint'
87
+ end
88
+ args + Array(options[:other])
89
+ end
90
+
91
+ end
92
+ end
93
+ end
94
+
95
+ Buildr::Compiler << Buildr::Compiler::Ajc
96
+
97
+ def compile_with_ajc(*opts)
98
+ compile.using :ajc
99
+ test.compile.using :ajc
100
+
101
+ hash_opts = {}
102
+ hash_opts ||= opts.last if Hash === opts.last
103
+ compile.using hash_opts
104
+
105
+ hash_opts[:test_apspectpath] = compile.target.to_s
106
+ test.compile.using hash_opts
107
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildr-ajc
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Nico Mainka
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-13 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: java ajc compiler for buildr
22
+ email: nico.maninka@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ - LICENSE
30
+ files:
31
+ - LICENSE
32
+ - README
33
+ - Rakefile
34
+ - lib/ajc.rb
35
+ has_rdoc: true
36
+ homepage:
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.7
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: java ajc compiler for buildr
67
+ test_files: []
68
+