buildr 1.3.5-x86-mswin32

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.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,212 @@
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
+
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
+ # Find a path relative to the project's root directory.
53
+ relative = lambda { |path| Util.relative_path(File.expand_path(path.to_s), project.path_to) }
54
+
55
+ m2repo = Buildr::Repositories.instance.local
56
+ excludes = [ '**/.svn/', '**/CVS/' ].join('|')
57
+
58
+ # Only for projects that are packageable.
59
+ task_name = project.path_to("#{project.name.gsub(':', '-')}#{IML_SUFFIX}")
60
+ idea7x.enhance [ file(task_name) ]
61
+
62
+ # The only thing we need to look for is a change in the Buildfile.
63
+ file(task_name=>Buildr.application.buildfile) do |task|
64
+ # Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
65
+ deps = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s ]
66
+
67
+ # Convert classpath elements into applicable Project objects
68
+ deps.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
69
+
70
+ # project_libs: artifacts created by other projects
71
+ project_libs, others = deps.partition { |path| path.is_a?(Project) }
72
+
73
+ # Separate artifacts from Maven2 repository
74
+ m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
75
+
76
+ # Project type is going to be the first package type
77
+ if package = project.packages.first
78
+ info "Writing #{task.name}"
79
+ File.open(task.name, "w") do |file|
80
+ xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
81
+ xml.module(:version=>"4", :relativePaths=>"true", :type=>"JAVA_MODULE") do
82
+ xml.component(:name=>"NewModuleRootManager", "inherit-compiler-output"=>"false") do
83
+
84
+ Buildr::Idea7x.generate_compile_output(project, xml, relative)
85
+
86
+ Buildr::Idea7x.generate_content(project, xml, relative)
87
+
88
+ Buildr::Idea7x.generate_order_entries(project_libs, xml)
89
+
90
+ ext_libs = m2_libs.map { |path| "jar://#{path.to_s.sub(m2repo, "$M2_REPO$")}!/" }
91
+ ext_libs << "#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
92
+ ext_libs << "#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
93
+
94
+ Buildr::Idea7x.generate_module_libs(xml, ext_libs)
95
+ xml.orderEntryProperties
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ # Root project aggregates all the subprojects.
103
+ if project.parent == nil
104
+ Buildr::Idea7x.generate_ipr(project, idea7x, Buildr.application.buildfile)
105
+ end
106
+
107
+ end # after_define
108
+
109
+ class << self
110
+
111
+ def generate_order_entries(project_libs, xml)
112
+ xml.orderEntry :type=>"sourceFolder", :forTests=>"false"
113
+ xml.orderEntry :type=>"inheritedJdk"
114
+
115
+ # Classpath elements from other projects
116
+ project_libs.map(&:id).sort.uniq.each do |project_id|
117
+ xml.orderEntry :type=>'module', "module-name"=>"#{project_id}#{CLASSIFIER}"
118
+ end
119
+ end
120
+
121
+ def generate_compile_output(project, xml, relative)
122
+ xml.output(:url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}") if project.compile.target
123
+ xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target
124
+ xml.tag!("exclude-output")
125
+ end
126
+
127
+ def generate_content(project, xml, relative)
128
+ xml.content(:url=>"#{MODULE_DIR_URL}") do
129
+ unless project.compile.sources.empty?
130
+ srcs = project.compile.sources.map { |src| relative[src.to_s] }
131
+ srcs.sort.uniq.each do |path|
132
+ xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"false"
133
+ end
134
+ end
135
+ unless project.test.compile.sources.empty?
136
+ test_sources = project.test.compile.sources.map { |src| relative[src.to_s] }
137
+ test_sources.each do |paths|
138
+ paths.sort.uniq.each do |path|
139
+ xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"true"
140
+ end
141
+ end
142
+ end
143
+ [project.resources=>false, project.test.resources=>true].each do |resources, test|
144
+ resources.each do |path|
145
+ path[0].sources.each do |srcpath|
146
+ xml.sourceFolder :url=>"#{FILE_PATH_PREFIX}#{srcpath}", :isTestSource=>path[1].to_s
147
+ end
148
+ end
149
+ end
150
+ xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
151
+ xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
152
+ end
153
+ end
154
+
155
+ def generate_module_libs(xml, ext_libs)
156
+ ext_libs.each do |path|
157
+ xml.orderEntry :type=>"module-library" do
158
+ xml.library do
159
+ xml.CLASSES do
160
+ xml.root :url=> path
161
+ end
162
+ xml.JAVADOC
163
+ xml.SOURCES do
164
+ xml.root :url=>"jar://#{path.sub(/\.jar$/, "-sources.jar")}!/"
165
+ end
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
+ info "Writing #{task.name}"
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.base_dir ? subp.base_dir.gsub(/^#{project.base_dir}\//, '') :
185
+ subp.name.split(":")[1 .. -1].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
+ File.open task.name, 'w' do |file|
200
+ template_xml.write file
201
+ end
202
+ end
203
+ end
204
+
205
+ end
206
+
207
+ end # module Idea7x
208
+ end # module Buildr
209
+
210
+ class Buildr::Project
211
+ include Buildr::Idea7x
212
+ end
@@ -0,0 +1,23 @@
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 RUBY_PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
18
+ require 'buildr/java/compiler'
19
+ require 'buildr/java/tests'
20
+ require 'buildr/java/bdd'
21
+ require 'buildr/java/packaging'
22
+ require 'buildr/java/commands'
23
+ require 'buildr/java/deprecated'
@@ -0,0 +1,94 @@
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
+ gem 'Antwrap'
18
+ autoload :Antwrap, 'antwrap'
19
+ autoload :Logger, 'logger'
20
+ require 'buildr/core/project'
21
+ require 'buildr/core/help'
22
+
23
+
24
+ module Buildr
25
+ module Ant
26
+
27
+ # Which version of Ant we're using by default.
28
+ VERSION = '1.7.1'
29
+
30
+ class << self
31
+ # Current version of Ant being used.
32
+ def version
33
+ Buildr.settings.build['ant'] || VERSION
34
+ end
35
+
36
+ # Ant classpath dependencies.
37
+ def dependencies
38
+ # Ant-Trax required for running the JUnitReport task, and there's no other place
39
+ # to put it but the root classpath.
40
+ @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
41
+ "org.apache.ant:ant-trax:jar:#{version}"]
42
+ end
43
+
44
+ private
45
+ def const_missing(const)
46
+ return super unless const == :REQUIRES # TODO: remove in 1.5
47
+ Buildr.application.deprecated "Please use Ant.dependencies/.version instead of Ant::REQUIRES/VERSION"
48
+ dependencies
49
+ end
50
+ end
51
+
52
+
53
+ Java.classpath << lambda { Ant.dependencies }
54
+
55
+ # :call-seq:
56
+ # ant(name) { |AntProject| ... } => AntProject
57
+ #
58
+ # Creates a new AntProject with the specified name, yield to the block for defining various
59
+ # Ant tasks, and executes each task as it's defined.
60
+ #
61
+ # For example:
62
+ # ant("hibernatedoclet') do |doclet|
63
+ # doclet.taskdef :name=>'hibernatedoclet',
64
+ # :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
65
+ # doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
66
+ # hibernate :version=>'3.0'
67
+ # fileset :dir=>source, :includes=>'**/*.java'
68
+ # end
69
+ # end
70
+ def ant(name, &block)
71
+ options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
72
+ options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if Buildr.application.options.trace
73
+ Java.load
74
+ Antwrap::AntProject.new(options).tap do |project|
75
+ # Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
76
+ project.project.getBuildListeners().get(0).
77
+ setMessageOutputLevel((Buildr.application.options.trace && 4) || (verbose && 2) || 0)
78
+ yield project if block_given?
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ include Ant
85
+ class Project
86
+ include Ant
87
+ end
88
+
89
+ Buildr.help do
90
+ Java.load
91
+ "\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant.version}."
92
+ end
93
+
94
+ end
@@ -0,0 +1,459 @@
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/tests'
18
+ require 'buildr/java/test_result'
19
+
20
+
21
+ module Buildr
22
+
23
+ # Mixin for test frameworks using src/spec/{lang}
24
+ class TestFramework::JavaBDD < TestFramework::Java #:nodoc:
25
+
26
+ class << self
27
+ attr_reader :lang, :bdd_dir
28
+ end
29
+ attr_accessor :lang, :bdd_dir
30
+
31
+ def initialize(task, options)
32
+ self.bdd_dir = self.class.bdd_dir
33
+ project = task.project
34
+ project.task('test:compile').tap do |comp|
35
+ comp.send :associate_with, project, bdd_dir
36
+ self.lang = comp.language || self.class.lang
37
+ end
38
+ project.task('test:resources').tap do |res|
39
+ res.send :associate_with, project, bdd_dir
40
+ res.filter.clear
41
+ project.path_to(:source, bdd_dir, :resources).tap { |dir| res.from dir if File.exist?(dir) }
42
+ end
43
+ super
44
+ end
45
+
46
+ end
47
+
48
+ module TestFramework::JRubyBased
49
+ extend self
50
+
51
+ VERSION = '1.3.1'
52
+
53
+ class << self
54
+ def version
55
+ Buildr.settings.build['jruby'] || VERSION
56
+ end
57
+
58
+ def jruby_artifact
59
+ "org.jruby:jruby-complete:jar:#{version}"
60
+ end
61
+
62
+ def dependencies
63
+ [jruby_artifact]
64
+ end
65
+
66
+ def included(mod)
67
+ mod.extend ClassMethods
68
+ super
69
+ end
70
+ end
71
+
72
+ module ClassMethods
73
+ def dependencies
74
+ deps = super
75
+ unless RUBY_PLATFORM[/java/] && TestFramework::JRubyBased.jruby_installed?
76
+ deps |= TestFramework::JRubyBased.dependencies
77
+ end
78
+ deps
79
+ end
80
+ end
81
+
82
+ def run(tests, dependencies)
83
+ maybe_install_jruby
84
+ dependencies |= [task.compile.target.to_s]
85
+
86
+ spec_dir = task.project.path_to(:source, :spec, :ruby)
87
+ report_dir = task.report_to.to_s
88
+ rm_rf report_dir
89
+ mkdir_p report_dir
90
+ ENV['CI_REPORTS'] = report_dir
91
+
92
+ runner = runner_config
93
+ runner.content = runner_content(binding)
94
+
95
+ Buildr.write(runner.file, runner.content)
96
+ rm_f runner.result
97
+
98
+ if RUBY_PLATFORM[/java/] && !options.fork
99
+ runtime = new_runtime
100
+ runtime.getObject.java.lang.System.getProperties().putAll(options[:properties] || {})
101
+ runtime.getLoadService.require runner.file
102
+ else
103
+ cmd_options = task.options.only(:properties, :java_args)
104
+ cmd_options.update(:classpath => dependencies, :project => task.project)
105
+ jruby runner.file, tests, cmd_options
106
+ end
107
+
108
+ result = YAML.load(File.read(runner.result))
109
+ if Exception === result
110
+ raise [result.message, result.backtrace].flatten.join("\n")
111
+ end
112
+ tests - result.failed
113
+ end
114
+
115
+ def jruby_home
116
+ @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] :
117
+ ( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
118
+ end
119
+
120
+ def jruby_installed?
121
+ !Dir.glob(File.join(jruby_home, 'lib', 'jruby*.jar')).empty?
122
+ end
123
+
124
+ protected
125
+ def maybe_install_jruby
126
+ unless jruby_installed?
127
+ jruby_artifact = Buildr.artifact(TestFramework::JRubyBased.jruby_artifact)
128
+ msg = "JRUBY_HOME is not correctly set or points to an invalid JRuby installation: #{jruby_home}"
129
+ say msg
130
+ say ''
131
+ say "You need to install JRuby version #{jruby_artifact.version} using your system package manager."
132
+ say 'Or you can just execute the following command: '
133
+ say ''
134
+ say " java -jar #{jruby_artifact} -S extract '#{jruby_home}'"
135
+ say ''
136
+ if agree('Do you want me to execute it for you? [y/N]', false)
137
+ jruby_artifact.invoke
138
+ Java::Commands.java('-jar', jruby_artifact.to_s, '-S', 'extract', jruby_home)
139
+ end
140
+
141
+ fail msg unless jruby_installed?
142
+ end
143
+ end
144
+
145
+ def jruby(*args)
146
+ java_args = ['org.jruby.Main', *args]
147
+ java_args << {} unless Hash === args.last
148
+ cmd_options = java_args.last
149
+ project = cmd_options.delete(:project)
150
+ cmd_options[:classpath] ||= []
151
+ Dir.glob(File.join(jruby_home, 'lib', '*.jar')) { |jar| cmd_options[:classpath] << jar }
152
+ cmd_options[:java_args] ||= []
153
+ cmd_options[:java_args] << '-Xmx512m' unless cmd_options[:java_args].detect {|a| a =~ /^-Xmx/}
154
+ cmd_options[:properties] ||= {}
155
+ cmd_options[:properties]['jruby.home'] = jruby_home
156
+ Java::Commands.java(*java_args)
157
+ end
158
+
159
+ def new_runtime(cfg = {})
160
+ config = Java.org.jruby.RubyInstanceConfig.new
161
+ cfg.each_pair do |name, value|
162
+ config.send("#{name}=", value)
163
+ end
164
+ yield config if block_given?
165
+ Java.org.jruby.Ruby.newInstance config
166
+ end
167
+
168
+ def jruby_gem
169
+ %{
170
+ require 'jruby'
171
+ def JRuby.gem(name, version = '>0', *args)
172
+ require 'rbconfig'
173
+ jruby_home = Config::CONFIG['prefix']
174
+ expected_version = '#{TestFramework::JRubyBased.version}'
175
+ unless JRUBY_VERSION >= expected_version
176
+ fail "Expected JRuby version \#{expected_version} installed at \#{jruby_home} but got \#{JRUBY_VERSION}"
177
+ end
178
+ require 'rubygems'
179
+ begin
180
+ Kernel.send :gem, name, version
181
+ rescue LoadError, Gem::LoadError => e
182
+ require 'rubygems/gem_runner'
183
+ Gem.manage_gems
184
+ args = ['install', name, '--version', version] + args
185
+ Gem::GemRunner.new.run(args)
186
+ Kernel.send :gem, name, version
187
+ end
188
+ end
189
+ }
190
+ end
191
+
192
+ def runner_config(runner = OpenStruct.new)
193
+ [:requires, :gems, :output, :format].each do |key|
194
+ runner.send("#{key}=", options[key])
195
+ end
196
+ runner.html_report ||= File.join(task.report_to.to_s, 'report.html')
197
+ runner.result ||= task.project.path_to(:target, :spec, 'result.yaml')
198
+ runner.file ||= task.project.path_to(:target, :spec, 'runner.rb')
199
+ runner.requires ||= []
200
+ runner.requires.unshift File.join(File.dirname(__FILE__), 'test_result')
201
+ runner.gems ||= {}
202
+ runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
203
+ runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
204
+ runner.rspec.push '--format', "#{runner_formatter}:#{runner.result}"
205
+ runner
206
+ end
207
+
208
+ def runner_formatter
209
+ "Buildr::TestFramework::TestResult::YamlFormatter"
210
+ end
211
+
212
+ end
213
+
214
+ # <a href="http://rspec.info">RSpec</a> is the defacto BDD framework for ruby.
215
+ # To test your project with RSpec use:
216
+ # test.using :rspec
217
+ #
218
+ #
219
+ # Support the following options:
220
+ # * :gems -- A hash of gems to install before running the tests.
221
+ # The keys of this hash are the gem name, the value must be the required version.
222
+ # * :requires -- A list of ruby files to require before running the specs
223
+ # Mainly used if an rspec format needs to require some file.
224
+ # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
225
+ # * :output -- File path to output dump. @false@ to supress output
226
+ # * :fork -- Create a new JavaVM to run the tests on
227
+ # * :properties -- Hash of properties passed to the test suite.
228
+ # * :java_args -- Arguments passed to the JVM.
229
+ class RSpec < TestFramework::JavaBDD
230
+ @lang = :ruby
231
+ @bdd_dir = :spec
232
+
233
+ include TestFramework::JRubyBased
234
+
235
+ TESTS_PATTERN = [ /_spec.rb$/ ]
236
+ OPTIONS = [:properties, :java_args]
237
+
238
+ def self.applies_to?(project) #:nodoc:
239
+ !Dir[project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].empty?
240
+ end
241
+
242
+ def tests(dependencies) #:nodoc:
243
+ Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].select do |name|
244
+ selector = ENV['SPEC']
245
+ selector.nil? || Regexp.new(selector) === name
246
+ end
247
+ end
248
+
249
+ def runner_config
250
+ runner = super
251
+ runner.gems.update 'rspec' => '>0'
252
+ runner.requires.unshift 'spec'
253
+ runner
254
+ end
255
+
256
+ def runner_content(binding)
257
+ runner_erb = %q{
258
+ <%= jruby_gem %>
259
+ <%= dependencies.inspect %>.each { |dep| $CLASSPATH << dep }
260
+ <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
261
+ <%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
262
+ <% if runner.output == false %>
263
+ output = StringIO.new
264
+ <% elsif runner.output.kind_of?(String) %>
265
+ output = File.open(<%= result.output.inspect %>, 'w')
266
+ <% else %>
267
+ output = STDOUT
268
+ <% end %>
269
+ parser = ::Spec::Runner::OptionParser.new(output, output)
270
+ argv = <%= runner.rspec.inspect %> || []
271
+ argv.push *<%= tests.inspect %>
272
+ parser.order!(argv)
273
+ $rspec_options = parser.options
274
+
275
+ Buildr::TestFramework::TestResult::Error.guard('<%= runner.result %>') do
276
+ ::Spec::Runner::CommandLine.run($rspec_options)
277
+ end
278
+ exit 0 # let buildr figure the result from the yaml file
279
+ }
280
+ Filter::Mapper.new(:erb, binding).transform(runner_erb)
281
+ end
282
+
283
+ end
284
+
285
+ # <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
286
+ # To test your project with JtestR use:
287
+ # test.using :jtestr
288
+ #
289
+ #
290
+ # Support the following options:
291
+ # * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
292
+ # * :gems -- A hash of gems to install before running the tests.
293
+ # The keys of this hash are the gem name, the value must be the required version.
294
+ # * :requires -- A list of ruby files to require before running the specs
295
+ # Mainly used if an rspec format needs to require some file.
296
+ # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
297
+ # * :output -- File path to output dump. @false@ to supress output
298
+ # * :fork -- Create a new JavaVM to run the tests on
299
+ # * :properties -- Hash of properties passed to the test suite.
300
+ # * :java_args -- Arguments passed to the JVM.
301
+ class JtestR < TestFramework::JavaBDD
302
+ @lang = :ruby
303
+ @bdd_dir = :spec
304
+
305
+ include TestFramework::JRubyBased
306
+
307
+ VERSION = '0.3.1'
308
+
309
+ # pattern for rspec stories
310
+ STORY_PATTERN = /_(steps|story)\.rb$/
311
+ # pattern for test_unit files
312
+ TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
313
+ # pattern for test files using http://expectations.rubyforge.org/
314
+ EXPECT_PATTERN = /_expect\.rb$/
315
+
316
+ TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
317
+
318
+ class << self
319
+
320
+ def version
321
+ Buildr.settings.build['jtestr'] || VERSION
322
+ end
323
+
324
+ def dependencies
325
+ @dependencies ||= Array(super) + ["org.jtestr:jtestr:jar:#{version}"] +
326
+ JUnit.dependencies + TestNG.dependencies
327
+ end
328
+
329
+ def applies_to?(project) #:nodoc:
330
+ File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
331
+ Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
332
+ JUnit.applies_to?(project) || TestNG.applies_to?(project)
333
+ end
334
+
335
+ private
336
+ def const_missing(const)
337
+ return super unless const == :REQUIRES # TODO: remove in 1.5
338
+ Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
339
+ dependencies
340
+ end
341
+
342
+ end
343
+
344
+ def initialize(task, options) #:nodoc:
345
+ super
346
+ [:test, :spec].each do |usage|
347
+ java_tests = task.project.path_to(:source, usage, :java)
348
+ task.compile.from java_tests if File.directory?(java_tests)
349
+ resources = task.project.path_to(:source, usage, :resources)
350
+ task.resources.from resources if File.directory?(resources)
351
+ end
352
+ end
353
+
354
+ def user_config
355
+ options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
356
+ end
357
+
358
+ def tests(dependencies) #:nodoc:
359
+ dependencies |= [task.compile.target.to_s]
360
+ types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
361
+ :testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
362
+ tests = types.keys.inject({}) { |h, k| h[k] = []; h }
363
+ tests[:junit] = JUnit.new(task, {}).tests(dependencies)
364
+ tests[:testng] = TestNG.new(task, {}).tests(dependencies)
365
+ Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
366
+ type = types.find { |k, v| Array(v).any? { |r| r === rb } }
367
+ tests[type.first] << rb if type
368
+ end
369
+ @jtestr_tests = tests
370
+ tests.values.flatten
371
+ end
372
+
373
+ def runner_config
374
+ runner = super
375
+ # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included,
376
+ # so the rspec version used depends on the jtestr jar.
377
+ runner.requires.unshift 'jtestr'
378
+ runner
379
+ end
380
+
381
+ def runner_content(binding)
382
+ runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
383
+ Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
384
+ end
385
+
386
+ def runner_formatter
387
+ 'Buildr::TestFramework::TestResult::JtestRYamlFormatter'
388
+ end
389
+
390
+ end
391
+
392
+
393
+ # JBehave is a Java BDD framework. To use in your project:
394
+ # test.using :jbehave
395
+ #
396
+ # This framework will search in your project for:
397
+ # src/spec/java/**/*Behaviour.java
398
+ #
399
+ # JMock libraries are included on runtime.
400
+ #
401
+ # Support the following options:
402
+ # * :properties -- Hash of properties to the test suite
403
+ # * :java_args -- Arguments passed to the JVM
404
+ class JBehave < TestFramework::JavaBDD
405
+ @lang = :java
406
+ @bdd_dir = :spec
407
+
408
+ VERSION = '1.0.1'
409
+ TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
410
+
411
+ class << self
412
+ def version
413
+ Buildr.settings.build['jbehave'] || VERSION
414
+ end
415
+
416
+ def dependencies
417
+ @dependencies ||= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
418
+ JMock.dependencies + JUnit.dependencies
419
+ end
420
+
421
+ def applies_to?(project) #:nodoc:
422
+ %w{
423
+ **/*Behaviour.java **/*Behavior.java
424
+ }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
425
+ end
426
+
427
+ private
428
+ def const_missing(const)
429
+ return super unless const == :REQUIRES # TODO: remove in 1.5
430
+ Buildr.application.deprecated 'Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION'
431
+ dependencies
432
+ end
433
+ end
434
+
435
+ def tests(dependencies) #:nodoc:
436
+ filter_classes(dependencies, :class_names => TESTS_PATTERN,
437
+ :interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
438
+ end
439
+
440
+ def run(tests, dependencies) #:nodoc:
441
+ cmd_args = ['org.jbehave.core.BehaviourRunner']
442
+ cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
443
+ tests.inject([]) do |passed, test|
444
+ begin
445
+ Java::Commands.java cmd_args, test, cmd_options
446
+ passed << test
447
+ rescue
448
+ passed
449
+ end
450
+ end
451
+ end
452
+
453
+ end
454
+
455
+ end
456
+
457
+ Buildr::TestFramework << Buildr::RSpec
458
+ Buildr::TestFramework << Buildr::JtestR
459
+ Buildr::TestFramework << Buildr::JBehave