Class: Buildr::Mirah::Mirahc

Inherits:
Compiler::Base
  • Object
show all
Defined in:
lib/buildr/mirah.rb

Constant Summary collapse

REQUIRES =
ArtifactNamespace.for(self) do |ns|
  ns.mirah! "org.mirah:mirah-complete:jar:>=0.0.7"
end
CLASSNAME =
"org.mirah.MirahCommand"
OPTIONS =
[:classpath, :dest]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applies_to?(project, task) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/buildr/mirah.rb', line 15

def applies_to?(project, task)
  paths = task.sources + [sources].flatten.map do |src|
    Array(project.path_to(:source, task.usage, src.to_sym))
  end
  paths.flatten!
  paths.any? { |path| !Dir["#{path}/**/*.mirah"].empty? }
end

.dependenciesObject



11
12
13
# File 'lib/buildr/mirah.rb', line 11

def dependencies
  REQUIRES.artifacts
end

Instance Method Details

#compile(sources, target, dependencies) ⇒ Object



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
# File 'lib/buildr/mirah.rb', line 31

def compile(sources, target, dependencies)
  return if Buildr.application.options.dryrun
  Buildr.ant "mirahc" do |ant|
    refid = "mirahc-classpath"
    ant.path(:id => refid) do
      dependencies.each { |dep| ant.pathelement :location => dep }
    end
    java_options = {
      :classname    => "org.mirah.MirahCommand",
      :classpathref => refid,
      :fork         => true,
      :failonerror  => true,
    }
    ant.java(java_options) do
      ant.arg(:value => "compile")

      mirahc_options = options.to_hash.only(*OPTIONS)
      mirahc_options[:dest] = target

      mirahc_options.each_pair do |key, value|
        ant.arg(:value => "--#{key.to_s}")
        ant.arg(:value => value)
      end
      ant.arg(:value => "--explicit-packages")
      sources.each do |src|
        ant.arg(:value => src)
      end
    end
  end
end