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,210 @@
|
|
|
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/packaging'
|
|
19
|
+
require 'stringio'
|
|
20
|
+
require 'rexml/document'
|
|
21
|
+
|
|
22
|
+
module Buildr
|
|
23
|
+
module Idea7x #:nodoc:
|
|
24
|
+
|
|
25
|
+
include Extension
|
|
26
|
+
|
|
27
|
+
CLASSIFIER = "-7x"
|
|
28
|
+
IML_SUFFIX = CLASSIFIER + ".iml"
|
|
29
|
+
IPR_TEMPLATE = "idea7x.ipr.template"
|
|
30
|
+
MODULE_DIR = "$MODULE_DIR$"
|
|
31
|
+
FILE_PATH_PREFIX = "file://"
|
|
32
|
+
MODULE_DIR_URL = FILE_PATH_PREFIX + MODULE_DIR
|
|
33
|
+
PROJECT_DIR = "$PROJECT_DIR$"
|
|
34
|
+
PROJECT_DIR_URL = FILE_PATH_PREFIX + PROJECT_DIR
|
|
35
|
+
|
|
36
|
+
first_time do
|
|
37
|
+
# Global task "idea" generates artifacts for all projects.
|
|
38
|
+
desc "Generate Idea 7.x artifacts for all projects"
|
|
39
|
+
Project.local_task "idea7x"=>"artifacts"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
before_define do |project|
|
|
43
|
+
project.recursive_task("idea7x")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
after_define do |project|
|
|
47
|
+
idea7x = project.task("idea7x")
|
|
48
|
+
|
|
49
|
+
# We need paths relative to the top project's base directory.
|
|
50
|
+
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
|
|
51
|
+
|
|
52
|
+
sources = Buildr.application.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
53
|
+
sources << File.expand_path(Buildr.application.buildfile, root_path) if Buildr.application.buildfile
|
|
54
|
+
|
|
55
|
+
# Find a path relative to the project's root directory.
|
|
56
|
+
relative = lambda { |path| Util.relative_path(File.expand_path(path.to_s), project.path_to) }
|
|
57
|
+
|
|
58
|
+
m2repo = Buildr::Repositories.instance.local
|
|
59
|
+
excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
60
|
+
|
|
61
|
+
# Only for projects that are packageable.
|
|
62
|
+
task_name = project.path_to("#{project.name.gsub(':', '-')}#{IML_SUFFIX}")
|
|
63
|
+
idea7x.enhance [ file(task_name) ]
|
|
64
|
+
|
|
65
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
66
|
+
file(task_name=>sources) do |task|
|
|
67
|
+
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
68
|
+
deps = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s ]
|
|
69
|
+
|
|
70
|
+
# Convert classpath elements into applicable Project objects
|
|
71
|
+
deps.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
|
72
|
+
|
|
73
|
+
# project_libs: artifacts created by other projects
|
|
74
|
+
project_libs, others = deps.partition { |path| path.is_a?(Project) }
|
|
75
|
+
|
|
76
|
+
# Separate artifacts from Maven2 repository
|
|
77
|
+
m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
|
|
78
|
+
|
|
79
|
+
# Generated: classpath elements in the project are assumed to be generated
|
|
80
|
+
generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
|
|
81
|
+
|
|
82
|
+
# Project type is going to be the first package type
|
|
83
|
+
if package = project.packages.first
|
|
84
|
+
puts "Writing #{task.name}" if verbose
|
|
85
|
+
File.open(task.name, "w") do |file|
|
|
86
|
+
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
87
|
+
xml.module(:version=>"4", :relativePaths=>"true", :type=>"JAVA_MODULE") do
|
|
88
|
+
xml.component(:name=>"NewModuleRootManager", "inherit-compiler-output"=>"false") do
|
|
89
|
+
|
|
90
|
+
Buildr::Idea7x.generate_compile_output(project, xml, relative)
|
|
91
|
+
|
|
92
|
+
Buildr::Idea7x.generate_content(project, xml, generated, relative)
|
|
93
|
+
|
|
94
|
+
Buildr::Idea7x.generate_order_entries(project_libs, xml)
|
|
95
|
+
|
|
96
|
+
ext_libs = libs.map {|path| "#{MODULE_DIR}/#{path.to_s}" } + m2_libs.map { |path| path.to_s.sub(m2repo, "$M2_REPO$") }
|
|
97
|
+
Buildr::Idea7x.generate_module_libs(xml, ext_libs)
|
|
98
|
+
|
|
99
|
+
xml.orderEntryProperties
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Root project aggregates all the subprojects.
|
|
107
|
+
if project.parent == nil
|
|
108
|
+
Buildr::Idea7x.generate_ipr(project, idea7x, sources)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end # after_define
|
|
112
|
+
|
|
113
|
+
class << self
|
|
114
|
+
|
|
115
|
+
def generate_order_entries(project_libs, xml)
|
|
116
|
+
xml.orderEntry :type=>"sourceFolder", :forTests=>"false"
|
|
117
|
+
xml.orderEntry :type=>"inheritedJdk"
|
|
118
|
+
|
|
119
|
+
# Classpath elements from other projects
|
|
120
|
+
project_libs.map(&:id).sort.uniq.each do |project_id|
|
|
121
|
+
xml.orderEntry :type=>'module', "module-name"=>"#{project_id}#{CLASSIFIER}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def generate_compile_output(project, xml, relative)
|
|
126
|
+
xml.output(:url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}") if project.compile.target
|
|
127
|
+
xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def generate_content(project, xml, generated, relative)
|
|
131
|
+
xml.content(:url=>"#{MODULE_DIR_URL}") do
|
|
132
|
+
unless project.compile.sources.empty?
|
|
133
|
+
srcs = project.compile.sources.map { |src| relative[src.to_s] } + generated.map { |src| relative[src.to_s] }
|
|
134
|
+
srcs.sort.uniq.each do |path|
|
|
135
|
+
xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"false"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
unless project.test.compile.sources.empty?
|
|
139
|
+
test_sources = project.test.compile.sources.map { |src| relative[src.to_s] }
|
|
140
|
+
test_sources.each do |paths|
|
|
141
|
+
paths.sort.uniq.each do |path|
|
|
142
|
+
xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"true"
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
[project.resources=>false, project.test.resources=>true].each do |resources, test|
|
|
147
|
+
resources.each do |path|
|
|
148
|
+
path[0].sources.each do |srcpath|
|
|
149
|
+
xml.sourceFolder :url=>"#{FILE_PATH_PREFIX}#{srcpath}", :isTestSource=>path[1].to_s
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}" if project.compile.target
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def generate_module_libs(xml, ext_libs)
|
|
158
|
+
ext_libs.each do |path|
|
|
159
|
+
xml.orderEntry :type=>"module-library" do
|
|
160
|
+
xml.library do
|
|
161
|
+
xml.CLASSES do
|
|
162
|
+
xml.root :url=>"jar://#{path}!/"
|
|
163
|
+
end
|
|
164
|
+
xml.JAVADOC
|
|
165
|
+
xml.SOURCES
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def generate_ipr(project, idea7x, sources)
|
|
172
|
+
task_name = project.path_to("#{project.name.gsub(':', '-')}-7x.ipr")
|
|
173
|
+
idea7x.enhance [ file(task_name) ]
|
|
174
|
+
file(task_name=>sources) do |task|
|
|
175
|
+
puts "Writing #{task.name}" if verbose
|
|
176
|
+
|
|
177
|
+
# Generating just the little stanza that chanages from one project to another
|
|
178
|
+
partial = StringIO.new
|
|
179
|
+
xml = Builder::XmlMarkup.new(:target=>partial, :indent=>2)
|
|
180
|
+
xml.component(:name=>"ProjectModuleManager") do
|
|
181
|
+
xml.modules do
|
|
182
|
+
project.projects.each do |subp|
|
|
183
|
+
module_name = subp.name.gsub(":", "-")
|
|
184
|
+
module_path = subp.name.split(":"); module_path.shift
|
|
185
|
+
module_path = module_path.join(File::SEPARATOR)
|
|
186
|
+
path = "#{module_path}/#{module_name}#{IML_SUFFIX}"
|
|
187
|
+
xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{path}", :filepath=>"#{PROJECT_DIR}/#{path}"
|
|
188
|
+
end
|
|
189
|
+
if package = project.packages.first
|
|
190
|
+
xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{project.name}#{IML_SUFFIX}", :filepath=>"#{PROJECT_DIR}/#{project.name}#{IML_SUFFIX}"
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Loading the whole fairly constant crap
|
|
196
|
+
template_xml = REXML::Document.new(File.open(File.join(File.dirname(__FILE__), IPR_TEMPLATE)))
|
|
197
|
+
include_xml = REXML::Document.new(partial.string)
|
|
198
|
+
template_xml.root.add_element(include_xml.root)
|
|
199
|
+
template_xml.write(File.new(task.name, "w"))
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
end # module Idea7x
|
|
206
|
+
end # module Buildr
|
|
207
|
+
|
|
208
|
+
class Buildr::Project
|
|
209
|
+
include Buildr::Idea7x
|
|
210
|
+
end
|
data/lib/buildr/java.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
|
|
18
|
+
require PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
require 'buildr/java/compilers'
|
|
22
|
+
require 'buildr/java/test_frameworks'
|
|
23
|
+
require 'buildr/java/bdd_frameworks'
|
|
24
|
+
require 'buildr/java/packaging'
|
|
25
|
+
require 'buildr/java/commands'
|
|
26
|
+
require 'buildr/java/deprecated'
|
|
@@ -0,0 +1,71 @@
|
|
|
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 'antwrap'
|
|
18
|
+
require 'buildr/core/project'
|
|
19
|
+
require 'buildr/core/help'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
module Buildr
|
|
23
|
+
module Ant
|
|
24
|
+
|
|
25
|
+
# Which version of Ant we're using by default.
|
|
26
|
+
VERSION = '1.7.0' unless const_defined?('VERSION')
|
|
27
|
+
|
|
28
|
+
# Libraries used by Ant.
|
|
29
|
+
REQUIRES = [ "org.apache.ant:ant:jar:#{VERSION}", "org.apache.ant:ant-launcher:jar:#{VERSION}", 'xerces:xercesImpl:jar:2.6.2' ]
|
|
30
|
+
Java.classpath << REQUIRES
|
|
31
|
+
|
|
32
|
+
# :call-seq:
|
|
33
|
+
# ant(name) { |AntProject| ... } => AntProject
|
|
34
|
+
#
|
|
35
|
+
# Creates a new AntProject with the specified name, yield to the block for defining various
|
|
36
|
+
# Ant tasks, and executes each task as it's defined.
|
|
37
|
+
#
|
|
38
|
+
# For example:
|
|
39
|
+
# ant("hibernatedoclet') do |doclet|
|
|
40
|
+
# doclet.taskdef :name=>'hibernatedoclet',
|
|
41
|
+
# :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
|
|
42
|
+
# doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
|
|
43
|
+
# hibernate :version=>'3.0'
|
|
44
|
+
# fileset :dir=>source, :includes=>'**/*.java'
|
|
45
|
+
# end
|
|
46
|
+
# end
|
|
47
|
+
def ant(name, &block)
|
|
48
|
+
options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
|
|
49
|
+
options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if Buildr.application.options.trace
|
|
50
|
+
Java.load
|
|
51
|
+
Antwrap::AntProject.new(options).tap do |project|
|
|
52
|
+
# Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
|
|
53
|
+
project.project.getBuildListeners().get(0).
|
|
54
|
+
setMessageOutputLevel((Buildr.application.options.trace && 4) || (verbose && 2) || 0)
|
|
55
|
+
yield project if block_given?
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
include Ant
|
|
62
|
+
class Project
|
|
63
|
+
include Ant
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Buildr.help do
|
|
67
|
+
Java.load
|
|
68
|
+
"\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant::VERSION}."
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,267 @@
|
|
|
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/test_frameworks'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module Buildr
|
|
21
|
+
|
|
22
|
+
# Mixin for test frameworks using src/spec/{lang}
|
|
23
|
+
module TestFramework::JavaBDD #:nodoc:
|
|
24
|
+
|
|
25
|
+
class << self
|
|
26
|
+
def included(mod)
|
|
27
|
+
mod.module_eval do
|
|
28
|
+
include TestFramework::JavaTest
|
|
29
|
+
include ClassMethods
|
|
30
|
+
end
|
|
31
|
+
mod.extend ClassMethods
|
|
32
|
+
mod.bdd_dir = :spec
|
|
33
|
+
mod.lang = :java
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
module ClassMethods
|
|
39
|
+
attr_accessor :lang, :bdd_dir
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def initialize(task, options)
|
|
43
|
+
self.bdd_dir = self.class.bdd_dir
|
|
44
|
+
project = task.project
|
|
45
|
+
project.task('test:compile').tap do |comp|
|
|
46
|
+
comp.send :associate_with, project, bdd_dir
|
|
47
|
+
self.lang = comp.language || self.class.lang
|
|
48
|
+
end
|
|
49
|
+
project.task('test:resources').tap do |res|
|
|
50
|
+
res.send :associate_with, project, bdd_dir
|
|
51
|
+
res.filter.clear
|
|
52
|
+
project.path_to(:source, bdd_dir, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
|
|
53
|
+
end
|
|
54
|
+
super
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class RSpec < TestFramework::Base
|
|
59
|
+
include TestFramework::JavaBDD
|
|
60
|
+
self.lang = :ruby
|
|
61
|
+
|
|
62
|
+
REQUIRES = ['org.jruby:jruby-complete:jar:1.1']
|
|
63
|
+
TESTS_PATTERN = [ /_spec.rb$/ ]
|
|
64
|
+
OPTIONS = [:properties, :java_args]
|
|
65
|
+
|
|
66
|
+
def self.applies_to?(project) #:nodoc:
|
|
67
|
+
!Dir[project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].empty?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def tests(dependencies) #:nodoc:
|
|
71
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].
|
|
72
|
+
select do |name|
|
|
73
|
+
selector = ENV['SPEC']
|
|
74
|
+
selector.nil? || Regexp.new(selector) === name
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def run(tests, dependencies) #:nodoc:
|
|
79
|
+
cmd_options = task.options.only(:properties, :java_args)
|
|
80
|
+
cmd_options.update :classpath => dependencies, :project => task.project
|
|
81
|
+
# TODO: Setting up JRuby is something to do before running Buildr.
|
|
82
|
+
#install_gems(cmd_options)
|
|
83
|
+
|
|
84
|
+
report_dir = task.report_to.to_s
|
|
85
|
+
FileUtils.rm_rf report_dir
|
|
86
|
+
ENV['CI_REPORTS'] = report_dir
|
|
87
|
+
|
|
88
|
+
jruby("-Ilib", "-S", "spec",
|
|
89
|
+
#"--require", gem_path(task.project, "ci_reporter", "lib/ci/reporter/rake/rspec_loader"),
|
|
90
|
+
"--require", "ci/reporter/rake/rspec_loader",
|
|
91
|
+
"--format", "CI::Reporter::RSpecDoc", tests,
|
|
92
|
+
cmd_options.merge({:name => "RSpec"}))
|
|
93
|
+
tests
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
def jruby_home(project)
|
|
98
|
+
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : File.expand_path(".jruby", ENV['HOME'])
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def gem_path(project, gem_name, *additional)
|
|
102
|
+
dir = Dir["#{jruby_home(project)}/lib/ruby/gems/1.8/gems/#{gem_name}*"].to_a.first
|
|
103
|
+
dir = File.join(dir, *additional) unless additional.empty?
|
|
104
|
+
dir
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def required_gems(options)
|
|
108
|
+
["ci_reporter", options[:required_gems]].flatten.compact
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def jruby(*args)
|
|
112
|
+
java_args = ["org.jruby.Main", *args]
|
|
113
|
+
java_args << {} unless Hash === args.last
|
|
114
|
+
cmd_options = java_args.last
|
|
115
|
+
project = cmd_options.delete(:project)
|
|
116
|
+
if RUBY_PLATFORM =~ /java/
|
|
117
|
+
# when run from within JRuby, use jars in launched-JRuby's classpath rather than the
|
|
118
|
+
# stated dependency
|
|
119
|
+
cmd_options[:classpath].delete_if {|e| File.basename(e) =~ /^jruby-complete-.*\.jar$/ }
|
|
120
|
+
cmd_options[:classpath].unshift *(java.lang.System.getProperty("java.class.path").split(File::PATH_SEPARATOR))
|
|
121
|
+
end
|
|
122
|
+
cmd_options[:java_args] ||= []
|
|
123
|
+
cmd_options[:java_args] << "-Xmx512m" unless cmd_options[:java_args].detect {|a| a =~ /^-Xmx/}
|
|
124
|
+
cmd_options[:properties] ||= {}
|
|
125
|
+
cmd_options[:properties]["jruby.home"] = jruby_home(project)
|
|
126
|
+
Java::Commands.java(*java_args)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#def install_gems(options)
|
|
130
|
+
# unless required_gems(options).all? {|g| gem_path(options[:project], g)}
|
|
131
|
+
# args = ["-S", "maybe_install_gems", *required_gems(options)]
|
|
132
|
+
# args << {:name => "JRuby Setup"}.merge(options)
|
|
133
|
+
# jruby(*args)
|
|
134
|
+
# end
|
|
135
|
+
#end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
class JtestR < TestFramework::Base
|
|
140
|
+
include TestFramework::JavaBDD
|
|
141
|
+
self.lang = :ruby
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# JBehave is a Java BDD framework. To use in your project:
|
|
145
|
+
# test.using :jbehave
|
|
146
|
+
#
|
|
147
|
+
# This framework will search in your project for:
|
|
148
|
+
# src/spec/java/**/*Behaviour.java
|
|
149
|
+
#
|
|
150
|
+
# JMock libraries are included on runtime.
|
|
151
|
+
#
|
|
152
|
+
# Support the following options:
|
|
153
|
+
# * :properties -- Hash of properties to the test suite
|
|
154
|
+
# * :java_args -- Arguments passed to the JVM
|
|
155
|
+
class JBehave < TestFramework::Base
|
|
156
|
+
include TestFramework::JavaBDD
|
|
157
|
+
|
|
158
|
+
VERSION = "1.0.1" unless const_defined?('VERSION')
|
|
159
|
+
REQUIRES = ["org.jbehave:jbehave:jar:#{VERSION}",
|
|
160
|
+
"jmock:jmock-cglib:jar:#{JMock::VERSION}",
|
|
161
|
+
"cglib:cglib-full:jar:2.0.2",
|
|
162
|
+
] + JUnit::REQUIRES
|
|
163
|
+
TESTS_PATTERN = [ /Behaviou?r$/ ]
|
|
164
|
+
|
|
165
|
+
def self.applies_to?(project) #:nodoc:
|
|
166
|
+
%w{
|
|
167
|
+
**/*Behaviour.java **/*Behavior.java
|
|
168
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def tests(dependencies) #:nodoc:
|
|
172
|
+
filter_classes(dependencies, :class_names => TESTS_PATTERN,
|
|
173
|
+
:interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def run(tests, dependencies) #:nodoc:
|
|
177
|
+
cmd_args = ['org.jbehave.core.BehaviourRunner']
|
|
178
|
+
cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
|
|
179
|
+
tests.inject([]) do |passed, test|
|
|
180
|
+
begin
|
|
181
|
+
Java::Commands.java cmd_args, test, cmd_options
|
|
182
|
+
passed << test
|
|
183
|
+
rescue
|
|
184
|
+
passed
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# EasyB is a Groovy based BDD framework.
|
|
192
|
+
# To use in your project:
|
|
193
|
+
#
|
|
194
|
+
# test.using :easyb
|
|
195
|
+
#
|
|
196
|
+
# This framework will search in your project for:
|
|
197
|
+
# src/spec/groovy/**/*Story.groovy
|
|
198
|
+
# src/spec/groovy/**/*Behavior.groovy
|
|
199
|
+
#
|
|
200
|
+
# Support the following options:
|
|
201
|
+
# * :format -- Report format :txt or :xml, default is :txt
|
|
202
|
+
# * :properties -- Hash of properties passed to the test suite.
|
|
203
|
+
# * :java_args -- Arguments passed to the JVM.
|
|
204
|
+
class EasyB < TestFramework::Base
|
|
205
|
+
include TestFramework::JavaBDD
|
|
206
|
+
self.lang = :groovy
|
|
207
|
+
|
|
208
|
+
VERSION = "0.7" unless const_defined?(:VERSION)
|
|
209
|
+
REQUIRES = ["org.easyb:easyb:jar:#{VERSION}",
|
|
210
|
+
'org.codehaus.groovy:groovy:jar:1.5.3',
|
|
211
|
+
'asm:asm:jar:2.2.3',
|
|
212
|
+
'commons-cli:commons-cli:jar:1.0',
|
|
213
|
+
'antlr:antlr:jar:2.7.7']
|
|
214
|
+
TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
|
|
215
|
+
OPTIONS = [:format, :properties, :java_args]
|
|
216
|
+
|
|
217
|
+
def self.applies_to?(project) #:nodoc:
|
|
218
|
+
%w{
|
|
219
|
+
**/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
|
|
220
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def tests(dependencies) #:nodoc:
|
|
224
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
|
|
225
|
+
select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def run(tests, dependencies) #:nodoc:
|
|
229
|
+
options = { :format => :txt }.merge(self.options).only(*OPTIONS)
|
|
230
|
+
|
|
231
|
+
if :txt == options[:format]
|
|
232
|
+
easyb_format, ext = 'txtstory', '.txt'
|
|
233
|
+
elsif :xml == options[:format]
|
|
234
|
+
easyb_format, ext = 'xmlbehavior', '.xml'
|
|
235
|
+
else
|
|
236
|
+
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
|
|
240
|
+
cmd_options = { :properties => options[:properties],
|
|
241
|
+
:java_args => options[:java_args],
|
|
242
|
+
:classpath => dependencies }
|
|
243
|
+
|
|
244
|
+
tests.inject([]) do |passed, test|
|
|
245
|
+
name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
|
|
246
|
+
report = File.join(task.report_to.to_s, name + ext)
|
|
247
|
+
mkpath report.pathmap('%d'), :verbose => false
|
|
248
|
+
begin
|
|
249
|
+
Java::Commands.java cmd_args,
|
|
250
|
+
"-#{easyb_format}", report,
|
|
251
|
+
test, cmd_options.merge(:name => name)
|
|
252
|
+
rescue => e
|
|
253
|
+
passed
|
|
254
|
+
else
|
|
255
|
+
passed << test
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end # EasyB
|
|
261
|
+
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
Buildr::TestFramework << Buildr::RSpec
|
|
265
|
+
Buildr::TestFramework << Buildr::JtestR
|
|
266
|
+
Buildr::TestFramework << Buildr::JBehave
|
|
267
|
+
Buildr::TestFramework << Buildr::EasyB
|