buildr 1.3.0-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 +780 -0
- data/DISCLAIMER +7 -0
- data/KEYS +151 -0
- data/LICENSE +176 -0
- data/NOTICE +31 -0
- data/README +173 -0
- data/Rakefile +63 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +232 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/nailgun.rb +892 -0
- data/addon/buildr/openjpa.rb +90 -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/xmlbeans.rb +93 -0
- data/bin/buildr +21 -0
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +47 -0
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/buildr/core/build.rb +262 -0
- data/lib/buildr/core/checks.rb +382 -0
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +890 -0
- data/lib/buildr/core/test.rb +690 -0
- data/lib/buildr/core/transports.rb +486 -0
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +181 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/buildr/packaging/artifact.rb +729 -0
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/buildr/packaging/tar.rb +104 -0
- data/lib/buildr/packaging/zip.rb +719 -0
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +324 -0
|
@@ -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.javadoc 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.javadoc 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.javadoc 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,137 @@
|
|
|
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
|
|
18
|
+
module Compiler
|
|
19
|
+
# Groovyc compiler:
|
|
20
|
+
# compile.using(:groovyc)
|
|
21
|
+
#
|
|
22
|
+
# You need to require 'buildr/java/groovyc' 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 < 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
|
+
end
|
|
136
|
+
|
|
137
|
+
Buildr::Compiler.compilers.unshift Buildr::Compiler::Groovyc
|
|
@@ -0,0 +1,99 @@
|
|
|
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 'java'
|
|
18
|
+
require 'jruby'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
|
|
22
|
+
# you to access Java classes and create Java objects.
|
|
23
|
+
#
|
|
24
|
+
# Java classes are accessed as static methods on the Java module, for example:
|
|
25
|
+
# str = Java.java.lang.String.new('hai!')
|
|
26
|
+
# str.toUpperCase
|
|
27
|
+
# => 'HAI!'
|
|
28
|
+
# Java.java.lang.String.isInstance(str)
|
|
29
|
+
# => true
|
|
30
|
+
# Java.com.sun.tools.javac.Main.compile(args)
|
|
31
|
+
#
|
|
32
|
+
# The classpath attribute allows Buildr to add JARs and directories to the classpath,
|
|
33
|
+
# for example, we use it to load Ant and various Ant tasks, code generators, test
|
|
34
|
+
# frameworks, and so forth.
|
|
35
|
+
#
|
|
36
|
+
# When using an artifact specification, Buildr will automatically download and
|
|
37
|
+
# install the artifact before adding it to the classpath.
|
|
38
|
+
#
|
|
39
|
+
# For example, Ant is loaded as follows:
|
|
40
|
+
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
|
41
|
+
#
|
|
42
|
+
# Artifacts can only be downloaded after the Buildfile has loaded, giving it
|
|
43
|
+
# a chance to specify which remote repositories to use, so adding to classpath
|
|
44
|
+
# does not by itself load any libraries. You must call Java.load before accessing
|
|
45
|
+
# any Java classes to give Buildr a chance to load the libraries specified in the
|
|
46
|
+
# classpath.
|
|
47
|
+
#
|
|
48
|
+
# When building an extension, make sure to follow these rules:
|
|
49
|
+
# 1. Add to the classpath when the extension is loaded (i.e. in module or class
|
|
50
|
+
# definition), so the first call to Java.load anywhere in the code will include
|
|
51
|
+
# the libraries you specify.
|
|
52
|
+
# 2. Call Java.load once before accessing any Java classes, allowing Buildr to
|
|
53
|
+
# set up the classpath.
|
|
54
|
+
# 3. Only call Java.load when invoked, otherwise you may end up loading the JVM
|
|
55
|
+
# with a partial classpath, or before all remote repositories are listed.
|
|
56
|
+
# 4. Check on a clean build with empty local repository.
|
|
57
|
+
module Java
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
|
|
61
|
+
# Returns the classpath, an array listing directories, JAR files and
|
|
62
|
+
# artifacts. Use when loading the extension to add any additional
|
|
63
|
+
# libraries used by that extension.
|
|
64
|
+
#
|
|
65
|
+
# For example, Ant is loaded as follows:
|
|
66
|
+
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
|
67
|
+
def classpath
|
|
68
|
+
@classpath ||= []
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Loads the JVM and all the libraries listed on the classpath. Call this
|
|
72
|
+
# method before accessing any Java class, but only call it from methods
|
|
73
|
+
# used in the build, giving the Buildfile a chance to load all extensions
|
|
74
|
+
# that append to the classpath and specify which remote repositories to use.
|
|
75
|
+
def load
|
|
76
|
+
return self if @loaded
|
|
77
|
+
cp = Buildr.artifacts(classpath).map(&:to_s).each { |path| file(path).invoke }
|
|
78
|
+
#cp ||= java.lang.System.getProperty('java.class.path').split(':').compact
|
|
79
|
+
# Use system ClassLoader to add classpath.
|
|
80
|
+
sysloader = java.lang.ClassLoader.getSystemClassLoader
|
|
81
|
+
add_url_method = java.lang.Class.forName('java.net.URLClassLoader').
|
|
82
|
+
getDeclaredMethod('addURL', [java.net.URL].to_java(java.lang.Class))
|
|
83
|
+
add_url_method.setAccessible(true)
|
|
84
|
+
add_path = lambda { |path| add_url_method.invoke(sysloader, [java.io.File.new(path).toURI.toURL].to_java(java.net.URL)) }
|
|
85
|
+
# Include tools (compiler, Javadoc, etc) for all platforms except OS/X.
|
|
86
|
+
unless Config::CONFIG['host_os'] =~ /darwin/i
|
|
87
|
+
home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
|
|
88
|
+
tools = File.expand_path('lib/tools.jar', home)
|
|
89
|
+
raise "Missing #{tools}, perhaps your JAVA_HOME is not correclty set" unless File.file?(tools)
|
|
90
|
+
add_path[tools]
|
|
91
|
+
end
|
|
92
|
+
cp.each { |path| add_path[path] }
|
|
93
|
+
@loaded = true
|
|
94
|
+
self
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
14
|
+
* under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
package org.apache.buildr;
|
|
19
|
+
|
|
20
|
+
import com.martiansoftware.nailgun.NGContext;
|
|
21
|
+
|
|
22
|
+
public interface BuildrNail {
|
|
23
|
+
|
|
24
|
+
public void main(NGContext ctx);
|
|
25
|
+
|
|
26
|
+
public static class Main {
|
|
27
|
+
private static BuildrNail nail;
|
|
28
|
+
public static void setNail(BuildrNail _nail) { nail = _nail; }
|
|
29
|
+
public static void nailMain(NGContext ctx) {
|
|
30
|
+
nail.main(ctx);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Local Variables:
|
|
38
|
+
* indent-tabs-mode: nil
|
|
39
|
+
* c-basic-offset: 2
|
|
40
|
+
* End:
|
|
41
|
+
*/
|
|
Binary file
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
|
14
|
+
* under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
package org.apache.buildr;
|
|
19
|
+
|
|
20
|
+
import java.lang.reflect.Method;
|
|
21
|
+
import java.io.File;
|
|
22
|
+
import java.io.IOException;
|
|
23
|
+
import java.net.URL;
|
|
24
|
+
import java.net.URLClassLoader;
|
|
25
|
+
import java.net.MalformedURLException;
|
|
26
|
+
import java.util.Iterator;
|
|
27
|
+
import java.util.Vector;
|
|
28
|
+
|
|
29
|
+
public class JavaTestFilter {
|
|
30
|
+
|
|
31
|
+
private ClassLoader _loader;
|
|
32
|
+
private Vector methodAnnotations = new Vector();
|
|
33
|
+
private Vector classAnnotations = new Vector();
|
|
34
|
+
private Vector interfaces = new Vector();
|
|
35
|
+
|
|
36
|
+
public JavaTestFilter(String[] paths) throws IOException {
|
|
37
|
+
URL[] urls = new URL[paths.length];
|
|
38
|
+
for (int i = 0 ; i < paths.length ; ++i) {
|
|
39
|
+
File file = new File(paths[i]).getCanonicalFile();
|
|
40
|
+
if (file.exists())
|
|
41
|
+
urls[i] = file.toURL();
|
|
42
|
+
else
|
|
43
|
+
throw new IOException("No file or directory with the name " + file);
|
|
44
|
+
}
|
|
45
|
+
_loader = new URLClassLoader(urls, getClass().getClassLoader());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public JavaTestFilter addInterfaces(String[] names) throws ClassNotFoundException {
|
|
49
|
+
for (int i = names.length; i -- > 0;) {
|
|
50
|
+
String name = names[i];
|
|
51
|
+
interfaces.add(_loader.loadClass(name));
|
|
52
|
+
}
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public JavaTestFilter addClassAnnotations(String[] names) throws ClassNotFoundException {
|
|
57
|
+
for (int i = names.length; i -- > 0;) {
|
|
58
|
+
String name = names[i];
|
|
59
|
+
classAnnotations.add(_loader.loadClass(name));
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public JavaTestFilter addMethodAnnotations(String[] names) throws ClassNotFoundException {
|
|
65
|
+
for (int i = names.length; i -- > 0;) {
|
|
66
|
+
String name = names[i];
|
|
67
|
+
methodAnnotations.add(_loader.loadClass(name));
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private boolean isTest(Class cls) {
|
|
73
|
+
if (interfaces != null) {
|
|
74
|
+
for (Iterator it = interfaces.iterator(); it.hasNext(); ) {
|
|
75
|
+
Class iface = (Class) it.next();
|
|
76
|
+
if (iface.isAssignableFrom(cls)) { return true; }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (classAnnotations != null) {
|
|
80
|
+
for (Iterator it = classAnnotations.iterator(); it.hasNext(); ) {
|
|
81
|
+
Class annotation = (Class) it.next();
|
|
82
|
+
if (cls.isAnnotationPresent(annotation)) { return true; }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (methodAnnotations != null) {
|
|
86
|
+
Method[] methods = cls.getMethods();
|
|
87
|
+
for (int j = methods.length ; j-- > 0 ;) {
|
|
88
|
+
for (Iterator it = methodAnnotations.iterator(); it.hasNext(); ) {
|
|
89
|
+
Class annotation = (Class) it.next();
|
|
90
|
+
if (methods[j].isAnnotationPresent(annotation)) { return true; }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
public String[] filter(String[] names) throws ClassNotFoundException {
|
|
99
|
+
Vector testCases = new Vector();
|
|
100
|
+
for (int i = names.length ; i-- > 0 ;) {
|
|
101
|
+
Class cls = _loader.loadClass(names[i]);
|
|
102
|
+
if (isTest(cls)) { testCases.add(names[i]); }
|
|
103
|
+
}
|
|
104
|
+
String[] result = new String[testCases.size()];
|
|
105
|
+
testCases.toArray(result);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* Local Variables:
|
|
113
|
+
* indent-tabs-mode: nil
|
|
114
|
+
* c-basic-offset: 2
|
|
115
|
+
* End:
|
|
116
|
+
*/
|