assaf-buildr 1.3.3

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 (163) hide show
  1. data/CHANGELOG +887 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,141 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'buildr/core/project'
18
+
19
+
20
+ module Java
21
+
22
+ # *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
23
+ # From this version forward, we apply with JRuby style for importing Java classes:
24
+ # Java.java.lang.String.new('hai!')
25
+ # You still need to call Java.load before using any Java code: it resolves, downloads
26
+ # and installs various dependencies that are required on the classpath before calling
27
+ # any Java code (e.g. Ant and its tasks).
28
+ class JavaWrapper
29
+
30
+ include Singleton
31
+
32
+ # *Deprecated:* Append to Java.classpath directly.
33
+ def classpath
34
+ Buildr.application.deprecated 'Append to Java.classpath instead.'
35
+ ::Java.classpath
36
+ end
37
+
38
+ def classpath=(paths)
39
+ fail 'Deprecated: Append to Java.classpath, you cannot replace the classpath.'
40
+ end
41
+
42
+ # *Deprecated:* No longer necessary.
43
+ def setup
44
+ Buildr.application.deprecated 'See documentation for new way to access Java code.'
45
+ yield self if block_given?
46
+ end
47
+
48
+ # *Deprecated:* Use Java.load instead.
49
+ def load
50
+ Buildr.application.deprecated 'Use Java.load instead.'
51
+ ::Java.load
52
+ end
53
+
54
+ alias :onload :setup
55
+
56
+ # *Deprecated:* Use Java.pkg.pkg.ClassName to import a Java class.
57
+ def import(class_name)
58
+ Buildr.application.deprecated 'Use Java.pkg.pkg.ClassName to import a Java class.'
59
+ ::Java.instance_eval(class_name)
60
+ end
61
+ end
62
+
63
+
64
+ class << self
65
+
66
+ # *Deprecated*: Use Java::Commands.java instead.
67
+ def java(*args, &block)
68
+ return send(:method_missing, :java) if args.empty?
69
+ Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
70
+ Commands.java(*args, &block)
71
+ end
72
+
73
+ # *Deprecated*: Use Java::Commands.apt instead.
74
+ def apt(*args)
75
+ Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
76
+ Commands.apt(*args)
77
+ end
78
+
79
+ # *Deprecated*: Use Java::Commands.javac instead.
80
+ def javac(*args)
81
+ Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
82
+ Commands.javac(*args)
83
+ end
84
+
85
+ # *Deprecated*: Use Java::Commands.javadoc instead.
86
+ def javadoc(*args)
87
+ Buildr.application.deprecated 'Use Java::Commands.javadoc instead.'
88
+ Commands.javadoc(*args)
89
+ end
90
+
91
+ # *Deprecated:* Use ENV_JAVA['java.version'] instead.
92
+ def version
93
+ Buildr.application.deprecated 'Use ENV_JAVA[\'java.version\'] instead.'
94
+ Java.load
95
+ ENV_JAVA['java.version']
96
+ end
97
+
98
+ # *Deprecated:* Use ENV['JAVA_HOME'] instead
99
+ def home
100
+ Buildr.application.deprecated 'Use ENV[\'JAVA_HOME\'] instead.'
101
+ ENV['JAVA_HOME']
102
+ end
103
+
104
+ # *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
105
+ # From this version forward, we apply with JRuby style for importing Java classes:
106
+ # Java.java.lang.String.new('hai!')
107
+ # You still need to call Java.load before using any Java code: it resolves, downloads
108
+ # and installs various dependencies that are required on the classpath before calling
109
+ # any Java code (e.g. Ant and its tasks).
110
+ def wrapper
111
+ Buildr.application.deprecated 'See documentation for new way to access Java code.'
112
+ if block_given?
113
+ Java.load
114
+ yield JavaWrapper.instance
115
+ else
116
+ JavaWrapper.instance
117
+ end
118
+ end
119
+
120
+ alias :rjb :wrapper
121
+
122
+ end
123
+
124
+
125
+ class Options
126
+
127
+ # *Deprecated:* Use ENV['JAVA_OPTS'] instead.
128
+ def java_args
129
+ Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
130
+ (ENV["JAVA_OPTS"] || ENV["JAVA_OPTIONS"]).to_s.split
131
+ end
132
+
133
+ # *Deprecated:* Use ENV['JAVA_OPTS'] instead.
134
+ def java_args=(args)
135
+ Buildr.application.deprecated "Use ENV['JAVA_OPTS'] instead"
136
+ ENV['JAVA_OPTS'] = Array(args).join(' ')
137
+ end
138
+
139
+ end
140
+
141
+ end
@@ -0,0 +1,117 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'java'
18
+ require 'jruby'
19
+
20
+
21
+ # Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
22
+ # you to access Java classes and create Java objects.
23
+ #
24
+ # Java classes are accessed as static methods on the Java module, for example:
25
+ # str = Java.java.lang.String.new('hai!')
26
+ # str.toUpperCase
27
+ # => 'HAI!'
28
+ # Java.java.lang.String.isInstance(str)
29
+ # => true
30
+ # Java.com.sun.tools.javac.Main.compile(args)
31
+ #
32
+ # The classpath attribute allows Buildr to add JARs and directories to the classpath,
33
+ # for example, we use it to load Ant and various Ant tasks, code generators, test
34
+ # frameworks, and so forth.
35
+ #
36
+ # When using an artifact specification, Buildr will automatically download and
37
+ # install the artifact before adding it to the classpath.
38
+ #
39
+ # For example, Ant is loaded as follows:
40
+ # Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
41
+ #
42
+ # Artifacts can only be downloaded after the Buildfile has loaded, giving it
43
+ # a chance to specify which remote repositories to use, so adding to classpath
44
+ # does not by itself load any libraries. You must call Java.load before accessing
45
+ # any Java classes to give Buildr a chance to load the libraries specified in the
46
+ # classpath.
47
+ #
48
+ # When building an extension, make sure to follow these rules:
49
+ # 1. Add to the classpath when the extension is loaded (i.e. in module or class
50
+ # definition), so the first call to Java.load anywhere in the code will include
51
+ # the libraries you specify.
52
+ # 2. Call Java.load once before accessing any Java classes, allowing Buildr to
53
+ # set up the classpath.
54
+ # 3. Only call Java.load when invoked, otherwise you may end up loading the JVM
55
+ # with a partial classpath, or before all remote repositories are listed.
56
+ # 4. Check on a clean build with empty local repository.
57
+ module Java
58
+
59
+ # Since we already have a JVM loaded, we can use it to guess where JAVA_HOME is.
60
+ # We set JAVA_HOME early so we can use it without calling Java.load first.
61
+ ENV['JAVA_HOME'] ||= java.lang.System.getProperty("java.home")
62
+
63
+ class << self
64
+
65
+ # Returns the classpath, an array listing directories, JAR files and
66
+ # artifacts. Use when loading the extension to add any additional
67
+ # libraries used by that extension.
68
+ #
69
+ # For example, Ant is loaded as follows:
70
+ # Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
71
+ def classpath
72
+ @classpath ||= []
73
+ end
74
+
75
+ # Most platforms requires tools.jar to be on the classpath, tools.jar contains the
76
+ # Java compiler (OS X and AIX are two exceptions we know about, may be more).
77
+ # Guess where tools.jar is from JAVA_HOME, which hopefully points to the JDK,
78
+ # but maybe the JRE. Return nil if not found.
79
+ def tools_jar #:nodoc:
80
+ @tools_jar ||= ['lib/tools.jar', '../lib/tools.jar'].map { |path| File.expand_path(path, ENV['JAVA_HOME']) }.
81
+ find { |path| File.exist?(path) }
82
+ end
83
+
84
+ # Loads the JVM and all the libraries listed on the classpath. Call this
85
+ # method before accessing any Java class, but only call it from methods
86
+ # used in the build, giving the Buildfile a chance to load all extensions
87
+ # that append to the classpath and specify which remote repositories to use.
88
+ def load
89
+ return self if @loaded
90
+
91
+ # Adding jars to the jruby's $CLASSPATH should be the correct thing, however it
92
+ # seems like some tools require their jars on system class loader (javadoc, junit, etc)
93
+ # cp.each { |path| $CLASSPATH << path }
94
+
95
+ # Use system ClassLoader to add classpath
96
+ sysloader = java.lang.ClassLoader.getSystemClassLoader
97
+ add_url_method = java.lang.Class.forName('java.net.URLClassLoader').
98
+ getDeclaredMethod('addURL', [java.net.URL.java_class].to_java(java.lang.Class))
99
+ add_url_method.setAccessible(true)
100
+ add_path = lambda { |path| add_url_method.invoke(sysloader, [java.io.File.new(path).toURI.toURL].to_java(java.net.URL)) }
101
+
102
+ # Most platforms requires tools.jar to be on the classpath.
103
+ add_path[tools_jar] if tools_jar
104
+
105
+ classpath.map! { |path| Proc === path ? path.call : path }
106
+ Buildr.artifacts(classpath).map(&:to_s).each do |path|
107
+ file(path).invoke
108
+ add_path[path]
109
+ end
110
+
111
+ @loaded = true
112
+ self
113
+ end
114
+
115
+ end
116
+
117
+ end
@@ -0,0 +1,116 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ # ___ ___ _ _ ___ _____ ___ ___ ___ _____ _____ _ _ ___ ___
17
+ # | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| |_ _| || |_ _/ __|
18
+ # | |) | (_) | | .` | (_) || | | _|| |) | | | | | | | __ || |\__ \
19
+ # |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| |_| |_||_|___|___/
20
+ #
21
+ # ___ ___ _ ___
22
+ # | __|_ _| | | __| CHANGES TO THIS FILE WILL BE LOST
23
+ # | _| | || |__| _| AUTO-GENERATED BY BUILDR on <%= Time.now %>
24
+ # |_| |___|____|___| PREFER TO EDIT JtestR CONFIGURATION FILE:
25
+ #
26
+ # <%= user_config %>
27
+
28
+ begin
29
+
30
+ <%= jruby_gem %>
31
+ <%= dependencies.map(&:to_s).inspect %>.each { |dep| $CLASSPATH << dep }
32
+ <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
33
+ <%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
34
+
35
+ jtestr = JtestR::TestRunner.new
36
+
37
+ class << jtestr
38
+ def config(&block)
39
+ @config_blocks ||= []
40
+ @config_blocks << block if block
41
+ @config_blocks
42
+ end
43
+
44
+ def load_configuration
45
+ super
46
+ config.each { |block| @configuration.instance_eval(&block) }
47
+ end
48
+ end
49
+
50
+ jtestr.config do
51
+ classpath [] # already loaded
52
+ add_common_classpath false
53
+
54
+ <% ts = ( @jtestr_tests[:junit] & tests ).map { |c| 'Java.' + c } %>
55
+ junit [<%= ts.join(', ') %>]
56
+
57
+ <% ts = ( @jtestr_tests[:testng] & tests ).map { |c| 'Java.' + c } %>
58
+ testng [<%= ts.join(', ') %>]
59
+
60
+ <% ts = @jtestr_tests[:testunit] & tests %>
61
+ test_unit <%= ts.inspect %>
62
+
63
+ <% ts = @jtestr_tests[:story] & tests %>
64
+ story <%= ts.inspect %>
65
+
66
+ <% ts = @jtestr_tests[:rspec] & tests %>
67
+ rspec <%= ts.inspect %>
68
+
69
+ <% ts = @jtestr_tests[:expect] & tests %>
70
+ expectations <%= ts.inspect %>
71
+
72
+ ignore __FILE__
73
+
74
+ if File.file?(<%= user_config.inspect %>)
75
+ ignore <%= user_config.inspect %>
76
+ load <%= user_config.inspect %>
77
+ end
78
+ end # config
79
+
80
+ fake_out = StringIO.new
81
+
82
+ <% if runner.output == false %>
83
+ output = fake_out
84
+ <% elsif runner.output.kind_of?(String) %>
85
+ output = File.open(<%= result.output.inspect %>, 'w')
86
+ <% else %>
87
+ output = STDOUT
88
+ <% end %>
89
+
90
+
91
+ args = [ '<%= spec_dir %>', # the directory to search for jtestr files
92
+ JtestR::SimpleLogger::ERR, # log level
93
+ JtestR::GenericResultHandler::QUIET, #output level
94
+ fake_out, # output STDOUT
95
+ [], # groups to run
96
+ Buildr::TestFramework::TestResult::RSpecResultHandler, # result handler
97
+ [] # classpath
98
+ ]
99
+
100
+ argv = <%= runner.rspec.inspect %> || []
101
+ argv.push *<%= tests.inspect %>
102
+ Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
103
+
104
+ jtestr.run *args
105
+
106
+ rescue => e
107
+ Buildr::TestFramework::TestResult::Error.dump_yaml('<%= runner.result %>', e) rescue \
108
+ puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
109
+ end
110
+
111
+ exit 0 # let buildr find the erros from the result yaml
112
+
113
+ # Local Variables:
114
+ # mode: ruby
115
+ # End:
116
+
@@ -0,0 +1,119 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with this
3
+ * work for additional information regarding copyright ownership. The ASF
4
+ * licenses this file to you under the Apache License, Version 2.0 (the
5
+ * "License"); you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ * License for the specific language governing permissions and limitations
14
+ * under the License.
15
+ */
16
+
17
+
18
+ package org.apache.buildr;
19
+
20
+ import java.lang.reflect.Method;
21
+ import java.lang.reflect.Modifier;
22
+ import java.io.File;
23
+ import java.io.IOException;
24
+ import java.net.URL;
25
+ import java.net.URLClassLoader;
26
+ import java.net.MalformedURLException;
27
+ import java.util.Iterator;
28
+ import java.util.Vector;
29
+
30
+ public class JavaTestFilter {
31
+
32
+ private ClassLoader _loader;
33
+ private Vector methodAnnotations = new Vector();
34
+ private Vector classAnnotations = new Vector();
35
+ private Vector interfaces = new Vector();
36
+
37
+ public JavaTestFilter(String[] paths) throws IOException {
38
+ URL[] urls = new URL[paths.length];
39
+ for (int i = 0 ; i < paths.length ; ++i) {
40
+ File file = new File(paths[i]).getCanonicalFile();
41
+ if (file.exists())
42
+ urls[i] = file.toURL();
43
+ else
44
+ throw new IOException("No file or directory with the name " + file);
45
+ }
46
+ _loader = new URLClassLoader(urls, getClass().getClassLoader());
47
+ }
48
+
49
+ public JavaTestFilter addInterfaces(String[] names) throws ClassNotFoundException {
50
+ for (int i = names.length; i -- > 0;) {
51
+ String name = names[i];
52
+ interfaces.add(_loader.loadClass(name));
53
+ }
54
+ return this;
55
+ }
56
+
57
+ public JavaTestFilter addClassAnnotations(String[] names) throws ClassNotFoundException {
58
+ for (int i = names.length; i -- > 0;) {
59
+ String name = names[i];
60
+ classAnnotations.add(_loader.loadClass(name));
61
+ }
62
+ return this;
63
+ }
64
+
65
+ public JavaTestFilter addMethodAnnotations(String[] names) throws ClassNotFoundException {
66
+ for (int i = names.length; i -- > 0;) {
67
+ String name = names[i];
68
+ methodAnnotations.add(_loader.loadClass(name));
69
+ }
70
+ return this;
71
+ }
72
+
73
+ private boolean isTest(Class cls) {
74
+ if (Modifier.isAbstract(cls.getModifiers()) || !Modifier.isPublic(cls.getModifiers()))
75
+ return false;
76
+ if (interfaces != null) {
77
+ for (Iterator it = interfaces.iterator(); it.hasNext(); ) {
78
+ Class iface = (Class) it.next();
79
+ if (iface.isAssignableFrom(cls)) { return true; }
80
+ }
81
+ }
82
+ if (classAnnotations != null) {
83
+ for (Iterator it = classAnnotations.iterator(); it.hasNext(); ) {
84
+ Class annotation = (Class) it.next();
85
+ if (cls.isAnnotationPresent(annotation)) { return true; }
86
+ }
87
+ }
88
+ if (methodAnnotations != null) {
89
+ Method[] methods = cls.getMethods();
90
+ for (int j = methods.length ; j-- > 0 ;) {
91
+ for (Iterator it = methodAnnotations.iterator(); it.hasNext(); ) {
92
+ Class annotation = (Class) it.next();
93
+ if (methods[j].isAnnotationPresent(annotation)) { return true; }
94
+ }
95
+ }
96
+ }
97
+ return false;
98
+ }
99
+
100
+
101
+ public String[] filter(String[] names) throws ClassNotFoundException {
102
+ Vector testCases = new Vector();
103
+ for (int i = names.length ; i-- > 0 ;) {
104
+ Class cls = _loader.loadClass(names[i]);
105
+ if (isTest(cls)) { testCases.add(names[i]); }
106
+ }
107
+ String[] result = new String[testCases.size()];
108
+ testCases.toArray(result);
109
+ return result;
110
+ }
111
+
112
+ }
113
+
114
+ /*
115
+ * Local Variables:
116
+ * indent-tabs-mode: nil
117
+ * c-basic-offset: 2
118
+ * End:
119
+ */