C0 code coverage information
Generated on Wed Oct 07 08:34:00 -0700 2009 with rcov 0.8.2.1
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with this
3 # work for additional information regarding copyright ownership. The ASF
4 # licenses this file to you under the Apache License, Version 2.0 (the
5 # "License"); you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations under
14 # the License.
15
16
17 module Buildr::Groovy
18
19 # Groovyc compiler:
20 # compile.using(:groovyc)
21 #
22 # You need to require 'buildr/groovy/compiler' if you need to use this compiler.
23 #
24 # Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
25 # and sets the target directory to target/classes (or target/test/classes).
26 #
27 # Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
28 # to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
29 # src/main/groovy directory, even though this compiler also looks in src/main/java
30 #
31 # Groovyc accepts the following options:
32 #
33 # * :encoding -- Encoding of source files
34 # * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
35 # * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
36 # * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
37 # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
38 # * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
39 # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
40 # * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
41 # * :stacktrace -- If true each compile error message will contain a stacktrace
42 # * :warnings -- Issue warnings when compiling. True when running in verbose mode.
43 # * :debug -- Generates bytecode with debugging information. Set from the debug
44 # environment variable/global option.
45 # * :deprecation -- If true, shows deprecation messages. False by default.
46 # * :optimise -- Generates faster bytecode by applying optimisations to the program.
47 # * :source -- Source code compatibility.
48 # * :target -- Bytecode compatibility.
49 # * :javac -- Hash of options passed to the ant javac task
50 #
51 class Groovyc < Compiler::Base
52
53 # The groovyc compiler jars are added to classpath at load time,
54 # if you want to customize artifact versions, you must set them on the
55 #
56 # artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
57 #
58 # namespace before this file is required.
59 REQUIRES = ArtifactNamespace.for(self) do |ns|
60 ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
61 ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
62 ns.asm! 'asm:asm:jar:>=2.2'
63 ns.antlr! 'antlr:antlr:jar:>=2.7.7'
64 end
65
66 ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
67 GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
68 JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
69 OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
70
71 class << self
72 def dependencies #:nodoc:
73 REQUIRES.artifacts
74 end
75
76 def applies_to?(project, task) #:nodoc:
77 paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
78 paths.flatten!
79 # Just select if we find .groovy files
80 paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
81 end
82 end
83
84 Java.classpath << dependencies
85
86 specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
87 :target => 'classes', :target_ext => 'class', :packaging => :jar
88
89 def initialize(project, options) #:nodoc:
90 super
91 options[:debug] = Buildr.options.debug if options[:debug].nil?
92 options[:deprecation] ||= false
93 options[:optimise] ||= false
94 options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
95 options[:warnings] = verbose if options[:warnings].nil?
96 options[:javac] = OpenObject.new if options[:javac].nil?
97 end
98
99 # http://groovy.codehaus.org/The+groovyc+Ant+Task
100 def compile(sources, target, dependencies) #:nodoc:
101 return if Buildr.application.options.dryrun
102 Buildr.ant 'groovyc' do |ant|
103 classpath = dependencies | self.class.dependencies.map(&:to_s)
104 ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
105 ant.groovyc groovyc_options(sources, target) do
106 sources.each { |src| ant.src :path => src }
107 ant.classpath do
108 classpath.each { |dep| ant.pathelement :path => dep }
109 end
110 ant.javac(javac_options)
111 end
112 end
113 end
114
115 private
116 def groovyc_options(sources, target)
117 check_options options, OPTIONS
118 groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
119 groovyc_options[:destdir] = File.expand_path(target)
120 groovyc_options
121 end
122
123 def javac_options
124 check_options options, OPTIONS
125 javac_options = options.to_hash.only(*JAVAC_OPTIONS)
126 javac_options[:optimize] = (javac_options.delete(:optimise) || false)
127 javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
128 other = javac_options.delete(:javac) || {}
129 javac_options.merge!(other)
130 javac_options
131 end
132
133 end
134 end
135
136 # Groovy compiler comes first, ahead of Javac, this allows it to pick
137 # projects that mix Groovy and Java code by spotting Groovy code first.
138 Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc
Generated using the rcov code coverage analysis tool for Ruby
version 0.8.2.1.