buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,135 @@
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/core/common'
19
+ require 'buildr/core/compile'
20
+ require 'buildr/packaging'
21
+
22
+
23
+ module Buildr
24
+ module Compiler
25
+
26
+ # Javac compiler:
27
+ # compile.using(:javac)
28
+ # Used by default if .java files are found in the src/main/java directory (or src/test/java)
29
+ # and sets the target directory to target/classes (or target/test/classes).
30
+ #
31
+ # Accepts the following options:
32
+ # * :warnings -- Issue warnings when compiling. True when running in verbose mode.
33
+ # * :debug -- Generates bytecode with debugging information. Set from the debug
34
+ # environment variable/global option.
35
+ # * :deprecation -- If true, shows deprecation messages. False by default.
36
+ # * :source -- Source code compatibility.
37
+ # * :target -- Bytecode compatibility.
38
+ # * :lint -- Lint option is one of true, false (default), name (e.g. 'cast') or array.
39
+ # * :other -- Array of options passed to the compiler
40
+ # (e.g. ['-implicit:none', '-encoding', 'iso-8859-1'])
41
+ class Javac < Base
42
+
43
+ OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
44
+
45
+ specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
46
+
47
+ def initialize(project, options) #:nodoc:
48
+ super
49
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
50
+ options[:warnings] ||= false
51
+ options[:deprecation] ||= false
52
+ options[:lint] ||= false
53
+ end
54
+
55
+ def compile(sources, target, dependencies) #:nodoc:
56
+ check_options options, OPTIONS
57
+ cmd_args = []
58
+ # tools.jar contains the Java compiler.
59
+ dependencies << Java.tools_jar if Java.tools_jar
60
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
61
+ source_paths = sources.select { |source| File.directory?(source) }
62
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
63
+ cmd_args << '-d' << File.expand_path(target)
64
+ cmd_args += javac_args
65
+ cmd_args += files_from_sources(sources)
66
+ unless Buildr.application.options.dryrun
67
+ trace((['javac'] + cmd_args).join(' '))
68
+ Java.load
69
+ Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
70
+ fail 'Failed to compile, see errors above'
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def javac_args #:nodoc:
77
+ args = []
78
+ args << '-nowarn' unless options[:warnings]
79
+ args << '-verbose' if trace? :javac
80
+ args << '-g' if options[:debug]
81
+ args << '-deprecation' if options[:deprecation]
82
+ args << '-source' << options[:source].to_s if options[:source]
83
+ args << '-target' << options[:target].to_s if options[:target]
84
+ case options[:lint]
85
+ when Array then args << "-Xlint:#{options[:lint].join(',')}"
86
+ when String then args << "-Xlint:#{options[:lint]}"
87
+ when true then args << '-Xlint'
88
+ end
89
+ args + Array(options[:other])
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
96
+
97
+ # Methods added to Project to support the Java Annotation Processor.
98
+ module Apt
99
+
100
+ # :call-seq:
101
+ # apt(*sources) => task
102
+ #
103
+ # Returns a task that will use Java#apt to generate source files in target/generated/apt,
104
+ # from all the source directories passed as arguments. Uses the compile.sources list if
105
+ # on arguments supplied.
106
+ #
107
+ # For example:
108
+ #
109
+ def apt(*sources)
110
+ sources = compile.sources if sources.empty?
111
+ file(path_to(:target, 'generated/apt')=>sources) do |task|
112
+ cmd_args = [ trace?(:apt) ? '-verbose' : '-nowarn' ]
113
+ cmd_args << '-nocompile' << '-s' << task.name
114
+ cmd_args << '-source' << compile.options.source if compile.options.source
115
+ classpath = Buildr.artifacts(compile.dependencies).map(&:to_s).each { |t| task(t).invoke }
116
+ cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
117
+ cmd_args += (sources.map(&:to_s) - [task.name]).
118
+ map { |file| File.directory?(file) ? FileList["#{file}/**/*.java"] : file }.flatten
119
+ unless Buildr.application.options.dryrun
120
+ info 'Running apt'
121
+ trace (['apt'] + cmd_args).join(' ')
122
+ Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
123
+ fail 'Failed to process annotations, see errors above'
124
+ end
125
+ end
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+
132
+ Buildr::Compiler << Buildr::Compiler::Javac
133
+ class Buildr::Project
134
+ include Buildr::Apt
135
+ end
@@ -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.java 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.apt 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.javac 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,86 @@
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
+ require 'buildr/core/doc'
17
+
18
+ module Buildr
19
+ module Doc
20
+
21
+ module JavadocDefaults
22
+ include Extension
23
+
24
+ # Default javadoc -windowtitle to project's comment or name
25
+ after_define(:javadoc => :doc) do |project|
26
+ if project.doc.engine? Javadoc
27
+ options = project.doc.options
28
+ options[:windowtitle] = (project.comment || project.name) unless options[:windowtitle]
29
+ end
30
+ end
31
+ end
32
+
33
+ # A convenient task for creating Javadocs from the project's compile task. Minimizes all
34
+ # the hard work to calling #from and #using.
35
+ #
36
+ # For example:
37
+ # doc.from(projects('myapp:foo', 'myapp:bar')).using(:windowtitle=>'My App')
38
+ # Or, short and sweet:
39
+ # desc 'My App'
40
+ # define 'myapp' do
41
+ # . . .
42
+ # doc projects('myapp:foo', 'myapp:bar')
43
+ # end
44
+ class Javadoc < Base
45
+
46
+ specify :language => :java, :source_ext => 'java'
47
+
48
+ def generate(sources, target, options = {})
49
+ cmd_args = [ '-d', target, trace?(:javadoc) ? '-verbose' : '-quiet' ]
50
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
51
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
52
+ each do |key, value|
53
+ case value
54
+ when true, nil
55
+ cmd_args << "-#{key}"
56
+ when false
57
+ cmd_args << "-no#{key}"
58
+ when Hash
59
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
60
+ else
61
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
62
+ end
63
+ end
64
+ [:sourcepath, :classpath].each do |option|
65
+ Array(options[option]).flatten.tap do |paths|
66
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
67
+ end
68
+ end
69
+ cmd_args += sources.flatten.uniq
70
+ unless Buildr.application.options.dryrun
71
+ info "Generating Javadoc for #{project.name}"
72
+ trace (['javadoc'] + cmd_args).join(' ')
73
+ Java.load
74
+ Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
75
+ fail 'Failed to generate Javadocs, see errors above'
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ class Project
82
+ include JavadocDefaults
83
+ end
84
+ end
85
+
86
+ Buildr::Doc.engines << Buildr::Doc::Javadoc
@@ -0,0 +1,69 @@
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
+ module Buildr
17
+ module Compiler
18
+
19
+ class Ecj < Javac
20
+
21
+ OPTIONS = Buildr::Compiler::Javac::OPTIONS
22
+
23
+ specify :language=>:java, :sources => 'java', :source_ext => 'java',
24
+ :target=>'classes', :target_ext=>'class', :packaging=>:jar
25
+
26
+ def compile(sources, target, dependencies) #:nodoc:
27
+ check_options options, OPTIONS
28
+ cmd_args = []
29
+ # tools.jar contains the Java compiler.
30
+ dependencies << Java.tools_jar if Java.tools_jar
31
+ cmd_args << '-classpath' << ('"' + dependencies.join(File::PATH_SEPARATOR) + '"') unless dependencies.empty?
32
+ source_paths = sources.select { |source| File.directory?(source) }
33
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
34
+ cmd_args << '-d' << File.expand_path(target)
35
+ cmd_args += ecj_args
36
+ cmd_args += files_from_sources(sources)
37
+ unless Buildr.application.options.dryrun
38
+ trace((%w[javac -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
39
+ Java.load
40
+ Java.org.eclipse.jdt.internal.compiler.batch.Main.compile(cmd_args.join(" ")) or
41
+ fail 'Failed to compile, see errors above'
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ # See arg list here: http://publib.boulder.ibm.com/infocenter/rsahelp/v7r0m0/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
48
+ def ecj_args #:nodoc:
49
+ args = []
50
+ args << '-warn:none' unless options[:warnings]
51
+ args << '-verbose' if trace?(:ecj)
52
+ args << '-g' if options[:debug]
53
+ args << '-deprecation' if options[:deprecation]
54
+ args << '-source' << options[:source].to_s if options[:source]
55
+ args << '-target' << options[:target].to_s if options[:target]
56
+ case options[:lint]
57
+ when Array then args << "-Xlint:#{options[:lint].join(',')}"
58
+ when String then args << "-Xlint:#{options[:lint]}"
59
+ when true then args << '-Xlint'
60
+ end
61
+ args + Array(options[:other])
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ Java.classpath << "org.eclipse.jdt.core.compiler:ecj:jar:3.5.1"
68
+ # Adding ecj before javac
69
+ Buildr::Compiler.compilers.unshift Buildr::Compiler::Ecj
@@ -0,0 +1,244 @@
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'
18
+
19
+
20
+ module Buildr
21
+
22
+ # Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
23
+ # Require explicitly using <code>require "buildr/emma"</code>.
24
+ #
25
+ # You can generate emma reports for a single project
26
+ # using the project name as prefix:
27
+ #
28
+ # project_name:emma:html
29
+ #
30
+ # You can also specify which classes to include/exclude from instrumentation by
31
+ # passing a class name regexp to the <code>emma.include</code> or
32
+ # <code>emma.exclude</code> methods.
33
+ #
34
+ # define 'someModule' do
35
+ # emma.include 'some.package.*'
36
+ # emma.exclude 'some.foo.util.SimpleUtil'
37
+ # end
38
+ module Emma
39
+
40
+ VERSION = '2.0.5312'
41
+
42
+ class << self
43
+
44
+ def version
45
+ Buildr.settings.build['emma'] || VERSION
46
+ end
47
+
48
+ def dependencies
49
+ @dependencies ||= ["emma:emma_ant:jar:#{version}", "emma:emma:jar:#{version}"]
50
+ end
51
+
52
+ def report_to format=nil
53
+ File.expand_path('reports/emma')
54
+ end
55
+
56
+ def data_file()
57
+ File.join(report_to, 'coverage.es')
58
+ end
59
+
60
+ def ant
61
+
62
+ Buildr.ant 'emma' do |ant|
63
+ ant.taskdef :resource=>'emma_ant.properties',
64
+ :classpath=>Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
65
+ ant.emma :verbosity=>(trace?(:emma) ? 'verbose' : 'warning') do
66
+ yield ant
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ class EmmaConfig # :nodoc:
73
+
74
+ def initialize(project)
75
+ @project = project
76
+ end
77
+
78
+ attr_reader :project
79
+ private :project
80
+
81
+ attr_writer :metadata_file, :coverage_file, :instrumented_dir, :report_dir
82
+
83
+ def coverage_file
84
+ @coverage_file ||= File.join(report_dir, 'coverage.ec')
85
+ end
86
+
87
+ def metadata_file
88
+ @metadata_file ||= File.join(report_dir, 'coverage.em')
89
+ end
90
+
91
+ def instrumented_dir
92
+ @instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
93
+ end
94
+
95
+ def report_dir
96
+ @report_dir ||= project.path_to(:reports, :emma)
97
+ end
98
+
99
+ def report_to format
100
+ report_dir
101
+ end
102
+
103
+ # :call-seq:
104
+ # project.emma.include(*classPatterns)
105
+ #
106
+ def include(*classPatterns)
107
+ includes.push(*classPatterns)
108
+ self
109
+ end
110
+
111
+ def includes
112
+ @includeClasses ||= []
113
+ end
114
+
115
+ # :call-seq:
116
+ # project.emma.exclude(*classPatterns)
117
+ #
118
+ def exclude(*classPatterns)
119
+ excludes.push(*classPatterns)
120
+ self
121
+ end
122
+
123
+ def excludes
124
+ @excludeClasses ||= []
125
+ end
126
+
127
+ def sources
128
+ project.compile.sources
129
+ end
130
+ end
131
+
132
+ module EmmaExtension # :nodoc:
133
+ include Buildr::Extension
134
+
135
+ def emma
136
+ @emma_config ||= EmmaConfig.new(self)
137
+ end
138
+
139
+ after_define do |project|
140
+ emma = project.emma
141
+
142
+ namespace 'emma' do
143
+ unless project.compile.target.nil?
144
+ # Instrumented bytecode goes in a different directory. This task creates before running the test
145
+ # cases and monitors for changes in the generate bytecode.
146
+ instrumented = project.file(emma.instrumented_dir => project.compile.target) do |task|
147
+ unless project.compile.sources.empty?
148
+ info "Instrumenting classes with emma metadata file #{emma.metadata_file}"
149
+ Emma.ant do |ant|
150
+ ant.instr :instrpath=>project.compile.target.to_s, :destdir=>task.to_s, :metadatafile=>emma.metadata_file do
151
+ ant.filter :includes=>emma.includes.join(', ') unless emma.includes.empty?
152
+ ant.filter :excludes=>emma.excludes.join(', ') unless emma.excludes.empty?
153
+ end
154
+ end
155
+ touch task.to_s
156
+ end
157
+ end
158
+
159
+ task 'instrument' => instrumented
160
+
161
+ # We now have two target directories with bytecode.
162
+ project.test.dependencies.unshift emma.instrumented_dir
163
+ project.test.with Emma.dependencies
164
+ project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
165
+
166
+ [:xml, :html].each do |format|
167
+ task format => ['instrument', 'test'] do
168
+ missing_required_files = [emma.metadata_file, emma.coverage_file].reject { |f| File.exist?(f) }
169
+ if missing_required_files.empty?
170
+ info "Creating test coverage reports in #{emma.report_dir}"
171
+ mkdir_p emma.report_dir
172
+ Emma.ant do |ant|
173
+ ant.report do
174
+ ant.infileset :file=>emma.metadata_file
175
+ ant.infileset :file=>emma.coverage_file
176
+ ant.send format, :outfile=>File.join(emma.report_to(format),"coverage.#{format}")
177
+ ant.sourcepath do
178
+ emma.sources.flatten.each do |src|
179
+ ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
180
+ end
181
+ end
182
+ end
183
+ end
184
+ else
185
+ info "No test coverage report for #{project}. Missing: #{missing_required_files.join(', ')}"
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+
192
+ project.clean do
193
+ rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir]
194
+ end
195
+
196
+ end
197
+
198
+ end
199
+
200
+ class Buildr::Project
201
+ include EmmaExtension
202
+ end
203
+
204
+ namespace "emma" do
205
+
206
+ Project.local_task('instrument') { |name| "Instrumenting #{name}" }
207
+
208
+ [:xml, :html].each do |format|
209
+ desc "Run the test cases and produce code coverage reports in #{format}"
210
+ task format => ['instrument', 'test'] do
211
+ info "Creating test coverage reports in #{format}"
212
+ mkdir_p report_to(format)
213
+ Emma.ant do |ant|
214
+ ant.merge :outfile=>data_file do
215
+ Buildr.projects.each do |project|
216
+ [project.emma.metadata_file, project.emma.coverage_file].each do |data_file|
217
+ ant.fileset :file=>data_file if File.exist?(data_file)
218
+ end
219
+ end
220
+ end
221
+ ant.report do
222
+ ant.infileset :file=>data_file
223
+ ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
224
+ ant.sourcepath do
225
+ Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
226
+ ant.dirset :dir=>src if File.exist?(src)
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
232
+ end
233
+
234
+ task :clean do
235
+ rm_rf [report_to, data_file]
236
+ end
237
+ end
238
+
239
+ task :clean do
240
+ task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
241
+ end
242
+
243
+ end
244
+ end