ittayd-buildr 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/CHANGELOG +62 -9
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +20 -39
  5. data/_buildr +1 -0
  6. data/{spec/java/ant.rb → _jbuildr} +11 -15
  7. metadata +30 -210
  8. data/DISCLAIMER +0 -7
  9. data/addon/buildr/antlr.rb +0 -65
  10. data/addon/buildr/cobertura.rb +0 -22
  11. data/addon/buildr/drb.rb +0 -281
  12. data/addon/buildr/emma.rb +0 -22
  13. data/addon/buildr/hibernate.rb +0 -142
  14. data/addon/buildr/javacc.rb +0 -85
  15. data/addon/buildr/jdepend.rb +0 -60
  16. data/addon/buildr/jetty.rb +0 -248
  17. data/addon/buildr/jibx.rb +0 -86
  18. data/addon/buildr/nailgun.rb +0 -221
  19. data/addon/buildr/openjpa.rb +0 -90
  20. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
  27. data/addon/buildr/path.rb +0 -136
  28. data/addon/buildr/xmlbeans.rb +0 -93
  29. data/buildr.buildfile +0 -53
  30. data/buildr.gemspec +0 -58
  31. data/doc/css/default.css +0 -228
  32. data/doc/css/print.css +0 -100
  33. data/doc/css/syntax.css +0 -52
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +0 -207
  44. data/doc/pages/building.textile +0 -240
  45. data/doc/pages/contributing.textile +0 -208
  46. data/doc/pages/download.textile +0 -62
  47. data/doc/pages/extending.textile +0 -175
  48. data/doc/pages/getting_started.textile +0 -273
  49. data/doc/pages/index.textile +0 -42
  50. data/doc/pages/languages.textile +0 -407
  51. data/doc/pages/mailing_lists.textile +0 -17
  52. data/doc/pages/more_stuff.textile +0 -314
  53. data/doc/pages/packaging.textile +0 -427
  54. data/doc/pages/projects.textile +0 -274
  55. data/doc/pages/recipes.textile +0 -103
  56. data/doc/pages/settings_profiles.textile +0 -274
  57. data/doc/pages/testing.textile +0 -212
  58. data/doc/pages/troubleshooting.textile +0 -103
  59. data/doc/pages/whats_new.textile +0 -323
  60. data/doc/print.haml +0 -51
  61. data/doc/print.toc.yaml +0 -29
  62. data/doc/scripts/buildr-git.rb +0 -412
  63. data/doc/scripts/install-jruby.sh +0 -44
  64. data/doc/scripts/install-linux.sh +0 -64
  65. data/doc/scripts/install-osx.sh +0 -52
  66. data/doc/site.haml +0 -56
  67. data/doc/site.toc.yaml +0 -47
  68. data/etc/KEYS +0 -151
  69. data/etc/git-svn-authors +0 -16
  70. data/lib/buildr.rb +0 -33
  71. data/lib/buildr/core.rb +0 -29
  72. data/lib/buildr/core/application.rb +0 -665
  73. data/lib/buildr/core/build.rb +0 -311
  74. data/lib/buildr/core/checks.rb +0 -254
  75. data/lib/buildr/core/common.rb +0 -150
  76. data/lib/buildr/core/compile.rb +0 -590
  77. data/lib/buildr/core/environment.rb +0 -117
  78. data/lib/buildr/core/filter.rb +0 -366
  79. data/lib/buildr/core/generate.rb +0 -195
  80. data/lib/buildr/core/help.rb +0 -119
  81. data/lib/buildr/core/osx.rb +0 -49
  82. data/lib/buildr/core/progressbar.rb +0 -156
  83. data/lib/buildr/core/project.rb +0 -923
  84. data/lib/buildr/core/test.rb +0 -715
  85. data/lib/buildr/core/transports.rb +0 -560
  86. data/lib/buildr/core/util.rb +0 -294
  87. data/lib/buildr/groovy.rb +0 -18
  88. data/lib/buildr/groovy/bdd.rb +0 -106
  89. data/lib/buildr/groovy/compiler.rb +0 -138
  90. data/lib/buildr/ide.rb +0 -19
  91. data/lib/buildr/ide/eclipse.rb +0 -222
  92. data/lib/buildr/ide/idea.ipr.template +0 -300
  93. data/lib/buildr/ide/idea.rb +0 -190
  94. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  95. data/lib/buildr/ide/idea7x.rb +0 -212
  96. data/lib/buildr/java.rb +0 -23
  97. data/lib/buildr/java/ant.rb +0 -92
  98. data/lib/buildr/java/bdd.rb +0 -451
  99. data/lib/buildr/java/cobertura.rb +0 -236
  100. data/lib/buildr/java/commands.rb +0 -211
  101. data/lib/buildr/java/compiler.rb +0 -348
  102. data/lib/buildr/java/deprecated.rb +0 -141
  103. data/lib/buildr/java/emma.rb +0 -238
  104. data/lib/buildr/java/jruby.rb +0 -117
  105. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  106. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  107. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
  108. data/lib/buildr/java/packaging.rb +0 -717
  109. data/lib/buildr/java/pom.rb +0 -174
  110. data/lib/buildr/java/rjb.rb +0 -155
  111. data/lib/buildr/java/test_result.rb +0 -307
  112. data/lib/buildr/java/tests.rb +0 -329
  113. data/lib/buildr/java/version_requirement.rb +0 -172
  114. data/lib/buildr/packaging.rb +0 -24
  115. data/lib/buildr/packaging/archive.rb +0 -488
  116. data/lib/buildr/packaging/artifact.rb +0 -759
  117. data/lib/buildr/packaging/artifact_namespace.rb +0 -972
  118. data/lib/buildr/packaging/artifact_search.rb +0 -140
  119. data/lib/buildr/packaging/gems.rb +0 -102
  120. data/lib/buildr/packaging/package.rb +0 -233
  121. data/lib/buildr/packaging/tar.rb +0 -186
  122. data/lib/buildr/packaging/version_requirement.rb +0 -172
  123. data/lib/buildr/packaging/zip.rb +0 -64
  124. data/lib/buildr/packaging/ziptask.rb +0 -313
  125. data/lib/buildr/resources/buildr.icns +0 -0
  126. data/lib/buildr/scala.rb +0 -19
  127. data/lib/buildr/scala/compiler.rb +0 -109
  128. data/lib/buildr/scala/tests.rb +0 -203
  129. data/rakelib/apache.rake +0 -191
  130. data/rakelib/changelog.rake +0 -57
  131. data/rakelib/doc.rake +0 -103
  132. data/rakelib/package.rake +0 -76
  133. data/rakelib/release.rake +0 -65
  134. data/rakelib/rspec.rake +0 -83
  135. data/rakelib/rubyforge.rake +0 -56
  136. data/rakelib/scm.rake +0 -49
  137. data/rakelib/setup.rake +0 -81
  138. data/rakelib/stage.rake +0 -48
  139. data/spec/addon/drb_spec.rb +0 -328
  140. data/spec/core/application_spec.rb +0 -419
  141. data/spec/core/build_spec.rb +0 -423
  142. data/spec/core/checks_spec.rb +0 -519
  143. data/spec/core/common_spec.rb +0 -670
  144. data/spec/core/compile_spec.rb +0 -582
  145. data/spec/core/generate_spec.rb +0 -33
  146. data/spec/core/project_spec.rb +0 -776
  147. data/spec/core/test_spec.rb +0 -1098
  148. data/spec/core/transport_spec.rb +0 -500
  149. data/spec/groovy/bdd_spec.rb +0 -80
  150. data/spec/groovy/compiler_spec.rb +0 -239
  151. data/spec/ide/eclipse_spec.rb +0 -311
  152. data/spec/java/bdd_spec.rb +0 -358
  153. data/spec/java/cobertura_spec.rb +0 -77
  154. data/spec/java/compiler_spec.rb +0 -446
  155. data/spec/java/emma_spec.rb +0 -120
  156. data/spec/java/java_spec.rb +0 -96
  157. data/spec/java/packaging_spec.rb +0 -1120
  158. data/spec/java/test_coverage_spec.rb +0 -255
  159. data/spec/java/tests_spec.rb +0 -471
  160. data/spec/packaging/archive_spec.rb +0 -503
  161. data/spec/packaging/artifact_namespace_spec.rb +0 -646
  162. data/spec/packaging/artifact_spec.rb +0 -795
  163. data/spec/packaging/packaging_helper.rb +0 -63
  164. data/spec/packaging/packaging_spec.rb +0 -589
  165. data/spec/sandbox.rb +0 -139
  166. data/spec/scala/compiler_spec.rb +0 -228
  167. data/spec/scala/tests_spec.rb +0 -215
  168. data/spec/spec_helpers.rb +0 -327
  169. data/spec/version_requirement_spec.rb +0 -123
@@ -1,212 +0,0 @@
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.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
- 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
@@ -1,23 +0,0 @@
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'
@@ -1,92 +0,0 @@
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' ; autoload :Antwrap, 'antwrap'
18
- require 'buildr/core/project'
19
- require 'buildr/core/help'
20
- require 'logger'
21
-
22
- module Buildr
23
- module Ant
24
-
25
- # Which version of Ant we're using by default.
26
- VERSION = '1.7.1'
27
-
28
- class << self
29
- # Current version of Ant being used.
30
- def version
31
- Buildr.settings.build['ant'] || VERSION
32
- end
33
-
34
- # Ant classpath dependencies.
35
- def dependencies
36
- # Ant-Trax required for running the JUnitReport task, and there's no other place
37
- # to put it but the root classpath.
38
- @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
39
- "org.apache.ant:ant-trax:jar:#{version}"]
40
- end
41
-
42
- private
43
- def const_missing(const)
44
- return super unless const == :REQUIRES # TODO: remove in 1.5
45
- Buildr.application.deprecated "Please use Ant.dependencies/.version instead of Ant::REQUIRES/VERSION"
46
- dependencies
47
- end
48
- end
49
-
50
-
51
- Java.classpath << lambda { Ant.dependencies }
52
-
53
- # :call-seq:
54
- # ant(name) { |AntProject| ... } => AntProject
55
- #
56
- # Creates a new AntProject with the specified name, yield to the block for defining various
57
- # Ant tasks, and executes each task as it's defined.
58
- #
59
- # For example:
60
- # ant("hibernatedoclet') do |doclet|
61
- # doclet.taskdef :name=>'hibernatedoclet',
62
- # :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
63
- # doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
64
- # hibernate :version=>'3.0'
65
- # fileset :dir=>source, :includes=>'**/*.java'
66
- # end
67
- # end
68
- def ant(name, &block)
69
- options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
70
- options.merge!(:logger=> ::Logger.new(STDOUT), :loglevel=> ::Logger::DEBUG) if Buildr.application.options.trace
71
- Java.load
72
- Antwrap::AntProject.new(options).tap do |project|
73
- # Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
74
- project.project.getBuildListeners().get(0).
75
- setMessageOutputLevel((Buildr.application.options.trace && 4) || (verbose && 2) || 0)
76
- yield project if block_given?
77
- end
78
- end
79
-
80
- end
81
-
82
- include Ant
83
- class Project
84
- include Ant
85
- end
86
-
87
- Buildr.help do
88
- Java.load
89
- "\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant.version}."
90
- end
91
-
92
- end
@@ -1,451 +0,0 @@
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.1.3'
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
- FileUtils.rm_rf report_dir
89
- FileUtils.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
- FileUtils.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
- result.succeeded
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.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.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', "Buildr::TestFramework::TestResult::YamlFormatter:#{runner.result}"
205
- runner
206
- end
207
-
208
- end
209
-
210
- # <a href="http://rspec.info">RSpec</a> is the defacto BDD framework for ruby.
211
- # To test your project with RSpec use:
212
- # test.using :rspec
213
- #
214
- #
215
- # Support the following options:
216
- # * :gems -- A hash of gems to install before running the tests.
217
- # The keys of this hash are the gem name, the value must be the required version.
218
- # * :requires -- A list of ruby files to require before running the specs
219
- # Mainly used if an rspec format needs to require some file.
220
- # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
221
- # * :output -- File path to output dump. @false@ to supress output
222
- # * :fork -- Create a new JavaVM to run the tests on
223
- # * :properties -- Hash of properties passed to the test suite.
224
- # * :java_args -- Arguments passed to the JVM.
225
- class RSpec < TestFramework::JavaBDD
226
- @lang = :ruby
227
- @bdd_dir = :spec
228
-
229
- include TestFramework::JRubyBased
230
-
231
- TESTS_PATTERN = [ /_spec.rb$/ ]
232
- OPTIONS = [:properties, :java_args]
233
-
234
- def self.applies_to?(project) #:nodoc:
235
- !Dir[project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].empty?
236
- end
237
-
238
- def tests(dependencies) #:nodoc:
239
- Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].
240
- select do |name|
241
- selector = ENV['SPEC']
242
- selector.nil? || Regexp.new(selector) === name
243
- end
244
- end
245
-
246
- def runner_config
247
- runner = super
248
- runner.gems.update 'rspec' => '>0'
249
- runner.requires.unshift 'spec'
250
- runner
251
- end
252
-
253
- def runner_content(binding)
254
- runner_erb = %q{
255
- <%= jruby_gem %>
256
- <%= dependencies.inspect %>.each { |dep| $CLASSPATH << dep }
257
- <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
258
- <%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
259
- <% if runner.output == false %>
260
- output = StringIO.new
261
- <% elsif runner.output.kind_of?(String) %>
262
- output = File.open(<%= result.output.inspect %>, 'w')
263
- <% else %>
264
- output = STDOUT
265
- <% end %>
266
- parser = ::Spec::Runner::OptionParser.new(output, output)
267
- argv = <%= runner.rspec.inspect %> || []
268
- argv.push *<%= tests.inspect %>
269
- parser.order!(argv)
270
- $rspec_options = parser.options
271
- Buildr::TestFramework::TestResult::Error.guard('<%= runner.file %>') do
272
- ::Spec::Runner::CommandLine.run($rspec_options)
273
- end
274
- exit 0 # let buildr figure the result from the yaml file
275
- }
276
- Filter::Mapper.new(:erb, binding).transform(runner_erb)
277
- end
278
-
279
- end
280
-
281
- # <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
282
- # To test your project with JtestR use:
283
- # test.using :jtestr
284
- #
285
- #
286
- # Support the following options:
287
- # * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
288
- # * :gems -- A hash of gems to install before running the tests.
289
- # The keys of this hash are the gem name, the value must be the required version.
290
- # * :requires -- A list of ruby files to require before running the specs
291
- # Mainly used if an rspec format needs to require some file.
292
- # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
293
- # * :output -- File path to output dump. @false@ to supress output
294
- # * :fork -- Create a new JavaVM to run the tests on
295
- # * :properties -- Hash of properties passed to the test suite.
296
- # * :java_args -- Arguments passed to the JVM.
297
- class JtestR < TestFramework::JavaBDD
298
- @lang = :ruby
299
- @bdd_dir = :spec
300
-
301
- include TestFramework::JRubyBased
302
-
303
- VERSION = '0.3.1'
304
-
305
- # pattern for rspec stories
306
- STORY_PATTERN = /_(steps|story)\.rb$/
307
- # pattern for test_unit files
308
- TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
309
- # pattern for test files using http://expectations.rubyforge.org/
310
- EXPECT_PATTERN = /_expect\.rb$/
311
-
312
- TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
313
-
314
- class << self
315
-
316
- def version
317
- Buildr.settings.build['jtestr'] || VERSION
318
- end
319
-
320
- def dependencies
321
- @dependencies ||= Array(super) + ["org.jtestr:jtestr:jar:#{version}"] +
322
- JUnit.dependencies + TestNG.dependencies
323
- end
324
-
325
- def applies_to?(project) #:nodoc:
326
- File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
327
- Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
328
- JUnit.applies_to?(project) || TestNG.applies_to?(project)
329
- end
330
-
331
- private
332
- def const_missing(const)
333
- return super unless const == :REQUIRES # TODO: remove in 1.5
334
- Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
335
- dependencies
336
- end
337
-
338
- end
339
-
340
- def initialize(task, options) #:nodoc:
341
- super
342
- [:test, :spec].each do |usage|
343
- java_tests = task.project.path_to(:source, usage, :java)
344
- task.compile.from java_tests if File.directory?(java_tests)
345
- resources = task.project.path_to(:source, usage, :resources)
346
- task.resources.from resources if File.directory?(resources)
347
- end
348
- end
349
-
350
- def user_config
351
- options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
352
- end
353
-
354
- def tests(dependencies) #:nodoc:
355
- dependencies |= [task.compile.target.to_s]
356
- types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
357
- :testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
358
- tests = types.keys.inject({}) { |h, k| h[k] = []; h }
359
- tests[:junit] = JUnit.new(task, {}).tests(dependencies)
360
- tests[:testng] = TestNG.new(task, {}).tests(dependencies)
361
- Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
362
- type = types.find { |k, v| Array(v).any? { |r| r === rb } }
363
- tests[type.first] << rb if type
364
- end
365
- @jtestr_tests = tests
366
- tests.values.flatten
367
- end
368
-
369
- def runner_config
370
- runner = super
371
- # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included,
372
- # so the rspec version used depends on the jtestr jar.
373
- runner.requires.unshift 'jtestr'
374
- runner
375
- end
376
-
377
- def runner_content(binding)
378
- runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
379
- Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
380
- end
381
-
382
- end
383
-
384
-
385
- # JBehave is a Java BDD framework. To use in your project:
386
- # test.using :jbehave
387
- #
388
- # This framework will search in your project for:
389
- # src/spec/java/**/*Behaviour.java
390
- #
391
- # JMock libraries are included on runtime.
392
- #
393
- # Support the following options:
394
- # * :properties -- Hash of properties to the test suite
395
- # * :java_args -- Arguments passed to the JVM
396
- class JBehave < TestFramework::JavaBDD
397
- @lang = :java
398
- @bdd_dir = :spec
399
-
400
- VERSION = '1.0.1'
401
- TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
402
-
403
- class << self
404
- def version
405
- Buildr.settings.build['jbehave'] || VERSION
406
- end
407
-
408
- def dependencies
409
- @dependencies ||= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
410
- JMock.dependencies + JUnit.dependencies
411
- end
412
-
413
- def applies_to?(project) #:nodoc:
414
- %w{
415
- **/*Behaviour.java **/*Behavior.java
416
- }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
417
- end
418
-
419
- private
420
- def const_missing(const)
421
- return super unless const == :REQUIRES # TODO: remove in 1.5
422
- Buildr.application.deprecated 'Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION'
423
- dependencies
424
- end
425
- end
426
-
427
- def tests(dependencies) #:nodoc:
428
- filter_classes(dependencies, :class_names => TESTS_PATTERN,
429
- :interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
430
- end
431
-
432
- def run(tests, dependencies) #:nodoc:
433
- cmd_args = ['org.jbehave.core.BehaviourRunner']
434
- cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
435
- tests.inject([]) do |passed, test|
436
- begin
437
- Java::Commands.java cmd_args, test, cmd_options
438
- passed << test
439
- rescue
440
- passed
441
- end
442
- end
443
- end
444
-
445
- end
446
-
447
- end
448
-
449
- Buildr::TestFramework << Buildr::RSpec
450
- Buildr::TestFramework << Buildr::JtestR
451
- Buildr::TestFramework << Buildr::JBehave