mguymon-buildr 1.4.5-java
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.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +88 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +151 -0
- data/doc/extending.textile +212 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +600 -0
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
require 'buildr/core/project'
|
|
18
|
+
require 'buildr/core/common'
|
|
19
|
+
require 'buildr/core/compile'
|
|
20
|
+
require 'buildr/packaging'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
module Buildr
|
|
24
|
+
module Compiler
|
|
25
|
+
|
|
26
|
+
# Javac compiler:
|
|
27
|
+
# compile.using(:javac)
|
|
28
|
+
# Used by default if .java files are found in the src/main/java directory (or src/test/java)
|
|
29
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
|
30
|
+
#
|
|
31
|
+
# Accepts the following options:
|
|
32
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
|
33
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
|
34
|
+
# environment variable/global option.
|
|
35
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
|
36
|
+
# * :source -- Source code compatibility.
|
|
37
|
+
# * :target -- Bytecode compatibility.
|
|
38
|
+
# * :lint -- Lint option is one of true, false (default), name (e.g. 'cast') or array.
|
|
39
|
+
# * :other -- Array of options passed to the compiler
|
|
40
|
+
# (e.g. ['-implicit:none', '-encoding', 'iso-8859-1'])
|
|
41
|
+
class Javac < Base
|
|
42
|
+
|
|
43
|
+
OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
|
|
44
|
+
|
|
45
|
+
specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
|
|
46
|
+
|
|
47
|
+
def initialize(project, options) #:nodoc:
|
|
48
|
+
super
|
|
49
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
|
50
|
+
options[:warnings] ||= false
|
|
51
|
+
options[:deprecation] ||= false
|
|
52
|
+
options[:lint] ||= false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def compile(sources, target, dependencies) #:nodoc:
|
|
56
|
+
check_options options, OPTIONS
|
|
57
|
+
cmd_args = []
|
|
58
|
+
# tools.jar contains the Java compiler.
|
|
59
|
+
dependencies << Java.tools_jar if Java.tools_jar
|
|
60
|
+
cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
|
|
61
|
+
source_paths = sources.select { |source| File.directory?(source) }
|
|
62
|
+
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
|
63
|
+
cmd_args << '-d' << File.expand_path(target)
|
|
64
|
+
cmd_args += javac_args
|
|
65
|
+
cmd_args += files_from_sources(sources)
|
|
66
|
+
unless Buildr.application.options.dryrun
|
|
67
|
+
trace((['javac'] + cmd_args).join(' '))
|
|
68
|
+
Java.load
|
|
69
|
+
Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
|
70
|
+
fail 'Failed to compile, see errors above'
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def javac_args #:nodoc:
|
|
77
|
+
args = []
|
|
78
|
+
args << '-nowarn' unless options[:warnings]
|
|
79
|
+
args << '-verbose' if trace? :javac
|
|
80
|
+
args << '-g' if options[:debug]
|
|
81
|
+
args << '-deprecation' if options[:deprecation]
|
|
82
|
+
args << '-source' << options[:source].to_s if options[:source]
|
|
83
|
+
args << '-target' << options[:target].to_s if options[:target]
|
|
84
|
+
case options[:lint]
|
|
85
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
|
86
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
|
87
|
+
when true then args << '-Xlint'
|
|
88
|
+
end
|
|
89
|
+
args + Array(options[:other])
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Methods added to Project to support the Java Annotation Processor.
|
|
98
|
+
module Apt
|
|
99
|
+
|
|
100
|
+
# :call-seq:
|
|
101
|
+
# apt(*sources) => task
|
|
102
|
+
#
|
|
103
|
+
# Returns a task that will use Java#apt to generate source files in target/generated/apt,
|
|
104
|
+
# from all the source directories passed as arguments. Uses the compile.sources list if
|
|
105
|
+
# on arguments supplied.
|
|
106
|
+
#
|
|
107
|
+
# For example:
|
|
108
|
+
#
|
|
109
|
+
def apt(*sources)
|
|
110
|
+
sources = compile.sources if sources.empty?
|
|
111
|
+
file(path_to(:target, 'generated/apt')=>sources) do |task|
|
|
112
|
+
cmd_args = [ trace?(:apt) ? '-verbose' : '-nowarn' ]
|
|
113
|
+
cmd_args << '-nocompile' << '-s' << task.name
|
|
114
|
+
cmd_args << '-source' << compile.options.source if compile.options.source
|
|
115
|
+
classpath = Buildr.artifacts(compile.dependencies).map(&:to_s).each { |t| task(t).invoke }
|
|
116
|
+
cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
|
117
|
+
cmd_args += (sources.map(&:to_s) - [task.name]).
|
|
118
|
+
map { |file| File.directory?(file) ? FileList["#{file}/**/*.java"] : file }.flatten
|
|
119
|
+
unless Buildr.application.options.dryrun
|
|
120
|
+
info 'Running apt'
|
|
121
|
+
trace (['apt'] + cmd_args).join(' ')
|
|
122
|
+
Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
|
123
|
+
fail 'Failed to process annotations, see errors above'
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
Buildr::Compiler << Buildr::Compiler::Javac
|
|
133
|
+
class Buildr::Project
|
|
134
|
+
include Buildr::Apt
|
|
135
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
require 'buildr/core/project'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module Java
|
|
21
|
+
|
|
22
|
+
# *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
|
|
23
|
+
# From this version forward, we apply with JRuby style for importing Java classes:
|
|
24
|
+
# Java.java.lang.String.new('hai!')
|
|
25
|
+
# You still need to call Java.load before using any Java code: it resolves, downloads
|
|
26
|
+
# and installs various dependencies that are required on the classpath before calling
|
|
27
|
+
# any Java code (e.g. Ant and its tasks).
|
|
28
|
+
class JavaWrapper
|
|
29
|
+
|
|
30
|
+
include Singleton
|
|
31
|
+
|
|
32
|
+
# *Deprecated:* Append to Java.classpath directly.
|
|
33
|
+
def classpath
|
|
34
|
+
Buildr.application.deprecated 'Append to Java.classpath instead.'
|
|
35
|
+
::Java.classpath
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def classpath=(paths)
|
|
39
|
+
fail 'Deprecated: Append to Java.classpath, you cannot replace the classpath.'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# *Deprecated:* No longer necessary.
|
|
43
|
+
def setup
|
|
44
|
+
Buildr.application.deprecated 'See documentation for new way to access Java code.'
|
|
45
|
+
yield self if block_given?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# *Deprecated:* Use Java.load instead.
|
|
49
|
+
def load
|
|
50
|
+
Buildr.application.deprecated 'Use Java.load instead.'
|
|
51
|
+
::Java.load
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
alias :onload :setup
|
|
55
|
+
|
|
56
|
+
# *Deprecated:* Use Java.pkg.pkg.ClassName to import a Java class.
|
|
57
|
+
def import(class_name)
|
|
58
|
+
Buildr.application.deprecated 'Use Java.pkg.pkg.ClassName to import a Java class.'
|
|
59
|
+
::Java.instance_eval(class_name)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class << self
|
|
65
|
+
|
|
66
|
+
# *Deprecated*: Use Java::Commands.java instead.
|
|
67
|
+
def java(*args, &block)
|
|
68
|
+
return send(:method_missing, :java) if args.empty?
|
|
69
|
+
Buildr.application.deprecated 'Use Java::Commands.java instead.'
|
|
70
|
+
Commands.java(*args, &block)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# *Deprecated*: Use Java::Commands.apt instead.
|
|
74
|
+
def apt(*args)
|
|
75
|
+
Buildr.application.deprecated 'Use Java::Commands.apt instead.'
|
|
76
|
+
Commands.apt(*args)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# *Deprecated*: Use Java::Commands.javac instead.
|
|
80
|
+
def javac(*args)
|
|
81
|
+
Buildr.application.deprecated 'Use Java::Commands.javac instead.'
|
|
82
|
+
Commands.javac(*args)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# *Deprecated*: Use Java::Commands.javadoc instead.
|
|
86
|
+
def javadoc(*args)
|
|
87
|
+
Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
|
|
88
|
+
Commands.javadoc(*args)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# *Deprecated:* Use ENV_JAVA['java.version'] instead.
|
|
92
|
+
def version
|
|
93
|
+
Buildr.application.deprecated 'Use ENV_JAVA[\'java.version\'] instead.'
|
|
94
|
+
Java.load
|
|
95
|
+
ENV_JAVA['java.version']
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# *Deprecated:* Use ENV['JAVA_HOME'] instead
|
|
99
|
+
def home
|
|
100
|
+
Buildr.application.deprecated 'Use ENV[\'JAVA_HOME\'] instead.'
|
|
101
|
+
ENV['JAVA_HOME']
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
|
|
105
|
+
# From this version forward, we apply with JRuby style for importing Java classes:
|
|
106
|
+
# Java.java.lang.String.new('hai!')
|
|
107
|
+
# You still need to call Java.load before using any Java code: it resolves, downloads
|
|
108
|
+
# and installs various dependencies that are required on the classpath before calling
|
|
109
|
+
# any Java code (e.g. Ant and its tasks).
|
|
110
|
+
def wrapper
|
|
111
|
+
Buildr.application.deprecated 'See documentation for new way to access Java code.'
|
|
112
|
+
if block_given?
|
|
113
|
+
Java.load
|
|
114
|
+
yield JavaWrapper.instance
|
|
115
|
+
else
|
|
116
|
+
JavaWrapper.instance
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
alias :rjb :wrapper
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Options
|
|
126
|
+
|
|
127
|
+
# *Deprecated:* Use ENV['JAVA_OPTS'] instead.
|
|
128
|
+
def java_args
|
|
129
|
+
Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
|
|
130
|
+
(ENV["JAVA_OPTS"] || ENV["JAVA_OPTIONS"]).to_s.split
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# *Deprecated:* Use ENV['JAVA_OPTS'] instead.
|
|
134
|
+
def java_args=(args)
|
|
135
|
+
Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
|
|
136
|
+
ENV['JAVA_OPTS'] = Array(args).join(' ')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
require 'buildr/core/doc'
|
|
17
|
+
|
|
18
|
+
module Buildr
|
|
19
|
+
module Doc
|
|
20
|
+
|
|
21
|
+
module JavadocDefaults
|
|
22
|
+
include Extension
|
|
23
|
+
|
|
24
|
+
# Default javadoc -windowtitle to project's comment or name
|
|
25
|
+
after_define(:javadoc => :doc) do |project|
|
|
26
|
+
if project.doc.engine? Javadoc
|
|
27
|
+
options = project.doc.options
|
|
28
|
+
options[:windowtitle] = (project.comment || project.name) unless options[:windowtitle]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# A convenient task for creating Javadocs from the project's compile task. Minimizes all
|
|
34
|
+
# the hard work to calling #from and #using.
|
|
35
|
+
#
|
|
36
|
+
# For example:
|
|
37
|
+
# doc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
|
|
38
|
+
# Or, short and sweet:
|
|
39
|
+
# desc 'My App'
|
|
40
|
+
# define 'myapp' do
|
|
41
|
+
# . . .
|
|
42
|
+
# doc projects('myapp:foo', 'myapp:bar')
|
|
43
|
+
# end
|
|
44
|
+
class Javadoc < Base
|
|
45
|
+
|
|
46
|
+
specify :language => :java, :source_ext => 'java'
|
|
47
|
+
|
|
48
|
+
def generate(sources, target, options = {})
|
|
49
|
+
cmd_args = [ '-d', target, trace?(:javadoc) ? '-verbose' : '-quiet' ]
|
|
50
|
+
options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
|
|
51
|
+
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
|
52
|
+
each do |key, value|
|
|
53
|
+
case value
|
|
54
|
+
when true, nil
|
|
55
|
+
cmd_args << "-#{key}"
|
|
56
|
+
when false
|
|
57
|
+
cmd_args << "-no#{key}"
|
|
58
|
+
when Hash
|
|
59
|
+
value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
|
|
60
|
+
else
|
|
61
|
+
cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
[:sourcepath, :classpath].each do |option|
|
|
65
|
+
Array(options[option]).flatten.tap do |paths|
|
|
66
|
+
cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
cmd_args += sources.flatten.uniq
|
|
70
|
+
unless Buildr.application.options.dryrun
|
|
71
|
+
info "Generating Javadoc for #{project.name}"
|
|
72
|
+
trace (['javadoc'] + cmd_args).join(' ')
|
|
73
|
+
Java.load
|
|
74
|
+
Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
|
|
75
|
+
fail 'Failed to generate Javadocs, see errors above'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class Project
|
|
82
|
+
include JavadocDefaults
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Buildr::Doc.engines << Buildr::Doc::Javadoc
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
module Buildr
|
|
17
|
+
module Compiler
|
|
18
|
+
|
|
19
|
+
class Ecj < Javac
|
|
20
|
+
|
|
21
|
+
OPTIONS = Buildr::Compiler::Javac::OPTIONS
|
|
22
|
+
|
|
23
|
+
specify :language=>:java, :sources => 'java', :source_ext => 'java',
|
|
24
|
+
:target=>'classes', :target_ext=>'class', :packaging=>:jar
|
|
25
|
+
|
|
26
|
+
def compile(sources, target, dependencies) #:nodoc:
|
|
27
|
+
check_options options, OPTIONS
|
|
28
|
+
cmd_args = []
|
|
29
|
+
# tools.jar contains the Java compiler.
|
|
30
|
+
dependencies << Java.tools_jar if Java.tools_jar
|
|
31
|
+
cmd_args << '-classpath' << ('"' + dependencies.join(File::PATH_SEPARATOR) + '"') unless dependencies.empty?
|
|
32
|
+
source_paths = sources.select { |source| File.directory?(source) }
|
|
33
|
+
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
|
34
|
+
cmd_args << '-d' << File.expand_path(target)
|
|
35
|
+
cmd_args += ecj_args
|
|
36
|
+
cmd_args += files_from_sources(sources)
|
|
37
|
+
unless Buildr.application.options.dryrun
|
|
38
|
+
trace((%w[javac -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
|
|
39
|
+
Java.load
|
|
40
|
+
Java.org.eclipse.jdt.internal.compiler.batch.Main.compile(cmd_args.join(" ")) or
|
|
41
|
+
fail 'Failed to compile, see errors above'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# See arg list here: http://publib.boulder.ibm.com/infocenter/rsahelp/v7r0m0/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
|
|
48
|
+
def ecj_args #:nodoc:
|
|
49
|
+
args = []
|
|
50
|
+
args << '-warn:none' unless options[:warnings]
|
|
51
|
+
args << '-verbose' if trace?(:ecj)
|
|
52
|
+
args << '-g' if options[:debug]
|
|
53
|
+
args << '-deprecation' if options[:deprecation]
|
|
54
|
+
args << '-source' << options[:source].to_s if options[:source]
|
|
55
|
+
args << '-target' << options[:target].to_s if options[:target]
|
|
56
|
+
case options[:lint]
|
|
57
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
|
58
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
|
59
|
+
when true then args << '-Xlint'
|
|
60
|
+
end
|
|
61
|
+
args + Array(options[:other])
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Java.classpath << "org.eclipse.jdt.core.compiler:ecj:jar:3.5.1"
|
|
68
|
+
# Adding ecj before javac
|
|
69
|
+
Buildr::Compiler.compilers.unshift Buildr::Compiler::Ecj
|
|
@@ -0,0 +1,244 @@
|
|
|
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
|
+
require 'buildr/java'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module Buildr
|
|
21
|
+
|
|
22
|
+
# Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
|
|
23
|
+
# Require explicitly using <code>require "buildr/emma"</code>.
|
|
24
|
+
#
|
|
25
|
+
# You can generate emma reports for a single project
|
|
26
|
+
# using the project name as prefix:
|
|
27
|
+
#
|
|
28
|
+
# project_name:emma:html
|
|
29
|
+
#
|
|
30
|
+
# You can also specify which classes to include/exclude from instrumentation by
|
|
31
|
+
# passing a class name regexp to the <code>emma.include</code> or
|
|
32
|
+
# <code>emma.exclude</code> methods.
|
|
33
|
+
#
|
|
34
|
+
# define 'someModule' do
|
|
35
|
+
# emma.include 'some.package.*'
|
|
36
|
+
# emma.exclude 'some.foo.util.SimpleUtil'
|
|
37
|
+
# end
|
|
38
|
+
module Emma
|
|
39
|
+
|
|
40
|
+
VERSION = '2.0.5312'
|
|
41
|
+
|
|
42
|
+
class << self
|
|
43
|
+
|
|
44
|
+
def version
|
|
45
|
+
Buildr.settings.build['emma'] || VERSION
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def dependencies
|
|
49
|
+
@dependencies ||= ["emma:emma_ant:jar:#{version}", "emma:emma:jar:#{version}"]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def report_to format=nil
|
|
53
|
+
File.expand_path('reports/emma')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def data_file()
|
|
57
|
+
File.join(report_to, 'coverage.es')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def ant
|
|
61
|
+
|
|
62
|
+
Buildr.ant 'emma' do |ant|
|
|
63
|
+
ant.taskdef :resource=>'emma_ant.properties',
|
|
64
|
+
:classpath=>Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
|
|
65
|
+
ant.emma :verbosity=>(trace?(:emma) ? 'verbose' : 'warning') do
|
|
66
|
+
yield ant
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class EmmaConfig # :nodoc:
|
|
73
|
+
|
|
74
|
+
def initialize(project)
|
|
75
|
+
@project = project
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
attr_reader :project
|
|
79
|
+
private :project
|
|
80
|
+
|
|
81
|
+
attr_writer :metadata_file, :coverage_file, :instrumented_dir, :report_dir
|
|
82
|
+
|
|
83
|
+
def coverage_file
|
|
84
|
+
@coverage_file ||= File.join(report_dir, 'coverage.ec')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def metadata_file
|
|
88
|
+
@metadata_file ||= File.join(report_dir, 'coverage.em')
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def instrumented_dir
|
|
92
|
+
@instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def report_dir
|
|
96
|
+
@report_dir ||= project.path_to(:reports, :emma)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def report_to format
|
|
100
|
+
report_dir
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# :call-seq:
|
|
104
|
+
# project.emma.include(*classPatterns)
|
|
105
|
+
#
|
|
106
|
+
def include(*classPatterns)
|
|
107
|
+
includes.push(*classPatterns)
|
|
108
|
+
self
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def includes
|
|
112
|
+
@includeClasses ||= []
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# :call-seq:
|
|
116
|
+
# project.emma.exclude(*classPatterns)
|
|
117
|
+
#
|
|
118
|
+
def exclude(*classPatterns)
|
|
119
|
+
excludes.push(*classPatterns)
|
|
120
|
+
self
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def excludes
|
|
124
|
+
@excludeClasses ||= []
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def sources
|
|
128
|
+
project.compile.sources
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
module EmmaExtension # :nodoc:
|
|
133
|
+
include Buildr::Extension
|
|
134
|
+
|
|
135
|
+
def emma
|
|
136
|
+
@emma_config ||= EmmaConfig.new(self)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
after_define do |project|
|
|
140
|
+
emma = project.emma
|
|
141
|
+
|
|
142
|
+
namespace 'emma' do
|
|
143
|
+
unless project.compile.target.nil?
|
|
144
|
+
# Instrumented bytecode goes in a different directory. This task creates before running the test
|
|
145
|
+
# cases and monitors for changes in the generate bytecode.
|
|
146
|
+
instrumented = project.file(emma.instrumented_dir => project.compile.target) do |task|
|
|
147
|
+
unless project.compile.sources.empty?
|
|
148
|
+
info "Instrumenting classes with emma metadata file #{emma.metadata_file}"
|
|
149
|
+
Emma.ant do |ant|
|
|
150
|
+
ant.instr :instrpath=>project.compile.target.to_s, :destdir=>task.to_s, :metadatafile=>emma.metadata_file do
|
|
151
|
+
ant.filter :includes=>emma.includes.join(', ') unless emma.includes.empty?
|
|
152
|
+
ant.filter :excludes=>emma.excludes.join(', ') unless emma.excludes.empty?
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
touch task.to_s
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
task 'instrument' => instrumented
|
|
160
|
+
|
|
161
|
+
# We now have two target directories with bytecode.
|
|
162
|
+
project.test.dependencies.unshift emma.instrumented_dir
|
|
163
|
+
project.test.with Emma.dependencies
|
|
164
|
+
project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
|
|
165
|
+
|
|
166
|
+
[:xml, :html].each do |format|
|
|
167
|
+
task format => ['instrument', 'test'] do
|
|
168
|
+
missing_required_files = [emma.metadata_file, emma.coverage_file].reject { |f| File.exist?(f) }
|
|
169
|
+
if missing_required_files.empty?
|
|
170
|
+
info "Creating test coverage reports in #{emma.report_dir}"
|
|
171
|
+
mkdir_p emma.report_dir
|
|
172
|
+
Emma.ant do |ant|
|
|
173
|
+
ant.report do
|
|
174
|
+
ant.infileset :file=>emma.metadata_file
|
|
175
|
+
ant.infileset :file=>emma.coverage_file
|
|
176
|
+
ant.send format, :outfile=>File.join(emma.report_to(format),"coverage.#{format}")
|
|
177
|
+
ant.sourcepath do
|
|
178
|
+
emma.sources.flatten.each do |src|
|
|
179
|
+
ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
else
|
|
185
|
+
info "No test coverage report for #{project}. Missing: #{missing_required_files.join(', ')}"
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
project.clean do
|
|
193
|
+
rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir]
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
class Buildr::Project
|
|
201
|
+
include EmmaExtension
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
namespace "emma" do
|
|
205
|
+
|
|
206
|
+
Project.local_task('instrument') { |name| "Instrumenting #{name}" }
|
|
207
|
+
|
|
208
|
+
[:xml, :html].each do |format|
|
|
209
|
+
desc "Run the test cases and produce code coverage reports in #{format}"
|
|
210
|
+
task format => ['instrument', 'test'] do
|
|
211
|
+
info "Creating test coverage reports in #{format}"
|
|
212
|
+
mkdir_p report_to(format)
|
|
213
|
+
Emma.ant do |ant|
|
|
214
|
+
ant.merge :outfile=>data_file do
|
|
215
|
+
Buildr.projects.each do |project|
|
|
216
|
+
[project.emma.metadata_file, project.emma.coverage_file].each do |data_file|
|
|
217
|
+
ant.fileset :file=>data_file if File.exist?(data_file)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
ant.report do
|
|
222
|
+
ant.infileset :file=>data_file
|
|
223
|
+
ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
|
|
224
|
+
ant.sourcepath do
|
|
225
|
+
Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
|
|
226
|
+
ant.dirset :dir=>src if File.exist?(src)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
task :clean do
|
|
235
|
+
rm_rf [report_to, data_file]
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
task :clean do
|
|
240
|
+
task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
end
|
|
244
|
+
end
|