buildr 1.2.10 → 1.3.0

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 (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -1,11 +1,28 @@
1
- require "java/java"
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
+
2
19
 
3
20
  module Buildr
4
21
  # Provides ANTLR grammar generation tasks. Require explicitly using <code>require "buildr/antlr"</code>.
5
22
  module ANTLR
6
23
  REQUIRES = [ "org.antlr:antlr:jar:3.0", "antlr:antlr:jar:2.7.7", "org.antlr:stringtemplate:jar:3.0" ]
7
24
 
8
- Java.wrapper.classpath << REQUIRES
25
+ Java.classpath << REQUIRES
9
26
 
10
27
  class << self
11
28
  def antlr(*args)
@@ -19,13 +36,9 @@ module Buildr
19
36
  mkdir_p options[:token]
20
37
  args = ["-lib", options[:token]] + args
21
38
  end
22
- Java.wrapper do |wrapper|
23
- antlr_class = wrapper.import("org.antlr.Tool")
24
- antlr_tool = antlr_class.new_with_sig("[Ljava.lang.String;", args)
25
- antlr_tool.process
26
- #wrapper.import("org.antlr.Tool").main(args) == 0 or
27
- # fail "Failed to run ANTLR, see errors above."
28
- end
39
+ Java.load
40
+ #Java.org.antlr.Tool.new_with_sig("[Ljava.lang.String;", args).process
41
+ Java.org.antlr.Tool.new(args.to_java(Java.java.lang.String)).process
29
42
  end
30
43
  end
31
44
 
@@ -37,7 +50,7 @@ module Buildr
37
50
  else
38
51
  in_package = []; token = nil
39
52
  end
40
- file(path_to(:target, "generated/antlr")=>args.flatten) do |task|
53
+ file(path_to(:target, :generated, :antlr)=>args.flatten) do |task|
41
54
  args = {:output=>File.join(task.name, in_package)}
42
55
  args.merge!({:token=>File.join(task.name, token)}) if token
43
56
  ANTLR.antlr task.prerequisites, args
@@ -0,0 +1,232 @@
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>cobertura:html</code> and <code>cobertura:xml</code> tasks.
23
+ # Require explicitly using <code>require "buildr/cobertura"</code>.
24
+ #
25
+ # You can generate cobertura reports for a single project
26
+ # using the project name as prefix:
27
+ #
28
+ # project_name:cobertura:html
29
+ #
30
+ # You can also specify which classes to include/exclude from instrumentation by
31
+ # passing a class name regexp to the <code>cobertura.include</code> or
32
+ # <code>cobertura.exclude</code> methods.
33
+ #
34
+ # define 'someModule' do
35
+ # cobertura.include 'some.package.*'
36
+ # cobertura.include /some.(foo|bar).*/
37
+ # cobertura.exclude 'some.foo.util.SimpleUtil'
38
+ # cobertura.exclude /*.Const(ants)?/i
39
+ # end
40
+ module Cobertura
41
+
42
+ class << self
43
+
44
+ REQUIRES = ["net.sourceforge.cobertura:cobertura:jar:1.9", "log4j:log4j:jar:1.2.9",
45
+ "asm:asm:jar:2.2.1", "asm:asm-tree:jar:2.2.1", "oro:oro:jar:2.0.8"]
46
+
47
+ def requires()
48
+ @requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
49
+ end
50
+
51
+ def report_to(file = nil)
52
+ File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
53
+ end
54
+
55
+ def data_file()
56
+ File.expand_path("reports/cobertura.ser")
57
+ end
58
+
59
+ end
60
+
61
+ class CoberturaConfig # :nodoc:
62
+
63
+ def initialize(project)
64
+ @project = project
65
+ end
66
+
67
+ attr_reader :project
68
+ private :project
69
+
70
+ attr_writer :data_file, :instrumented_dir, :report_dir
71
+
72
+ def data_file
73
+ @data_file ||= project.path_to(:reports, 'cobertura.ser')
74
+ end
75
+
76
+ def instrumented_dir
77
+ @instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
78
+ end
79
+
80
+ def report_dir
81
+ @report_dir ||= project.path_to(:reports, :cobertura)
82
+ end
83
+
84
+ def report_to(file = nil)
85
+ File.expand_path(File.join(*[report_dir, file.to_s].compact))
86
+ end
87
+
88
+ # :call-seq:
89
+ # project.cobertura.include(*classPatterns)
90
+ #
91
+ def include(*classPatterns)
92
+ includes.push(*classPatterns.map { |p| String === p ? Regexp.new(p) : p })
93
+ self
94
+ end
95
+
96
+ def includes
97
+ @includeClasses ||= []
98
+ end
99
+
100
+ # :call-seq:
101
+ # project.cobertura.exclude(*classPatterns)
102
+ #
103
+ def exclude(*classPatterns)
104
+ excludes.push(*classPatterns.map { |p| String === p ? Regexp.new(p) : p })
105
+ self
106
+ end
107
+
108
+ def excludes
109
+ @excludeClasses ||= []
110
+ end
111
+
112
+ def sources
113
+ project.compile.sources
114
+ end
115
+ end
116
+
117
+ module CoberturaExtension # :nodoc:
118
+ include Buildr::Extension
119
+
120
+ def cobertura
121
+ @cobertura_config ||= CoberturaConfig.new(self)
122
+ end
123
+
124
+ after_define do |project|
125
+ cobertura = project.cobertura
126
+
127
+ namespace 'cobertura' do
128
+ # Instrumented bytecode goes in a different directory. This task creates before running the test
129
+ # cases and monitors for changes in the generate bytecode.
130
+ instrumented = project.file(cobertura.instrumented_dir => file(project.compile.target)) do |task|
131
+ mkdir_p task.to_s, :verbose => false
132
+ unless project.compile.sources.empty?
133
+ puts "Instrumenting classes with cobertura data file #{cobertura.data_file}"
134
+ Buildr.ant "cobertura" do |ant|
135
+ ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
136
+ ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>cobertura.data_file do
137
+ includes, excludes = cobertura.includes, cobertura.excludes
138
+
139
+ classes_dir = project.compile.target.to_s
140
+ if includes.empty? && excludes.empty?
141
+ ant.fileset :dir => classes_dir do
142
+ ant.include :name => "**/*.class"
143
+ end
144
+ else
145
+ includes = [//] if includes.empty?
146
+ Dir.glob(File.join(classes_dir, "**/*.class")) do |cls|
147
+ cls_name = cls.gsub(/#{classes_dir}\/?|\.class$/, '').gsub('/', '.')
148
+ if includes.any? { |p| p === cls_name } && !excludes.any? { |p| p === cls_name }
149
+ ant.fileset :file => cls
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
156
+ touch task.to_s, :verbose=>false
157
+ end
158
+
159
+ task 'instrument' => instrumented
160
+ [:xml, :html].each do |format|
161
+ task format => ['instrument', 'test'] do
162
+ puts "Creating test coverage reports in #{cobertura.report_to(format)}"
163
+ Buildr.ant "cobertura" do |ant|
164
+ ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
165
+ ant.send "cobertura-report", :format=>format,
166
+ :destdir=>cobertura.report_to(format), :datafile=>cobertura.data_file do
167
+ cobertura.sources.flatten.each do |src|
168
+ ant.fileset(:dir=>src.to_s) if File.exist?(src.to_s)
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+
175
+ end
176
+
177
+ # We now have two target directories with bytecode. It would make sense to remove compile.target
178
+ # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
179
+ # we need both directories and instrumented must come first.
180
+ project.test.dependencies.unshift cobertura.instrumented_dir
181
+ project.test.with Cobertura.requires
182
+ project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = cobertura.data_file
183
+
184
+ project.clean do
185
+ rm_rf [cobertura.report_to, cobertura.data_file, cobertura.instrumented_dir], :verbose=>false
186
+ end
187
+
188
+ end
189
+
190
+ end
191
+
192
+ class Buildr::Project
193
+ include CoberturaExtension
194
+ end
195
+
196
+ namespace "cobertura" do
197
+
198
+ task "instrument" do
199
+ Buildr.projects.each do |project|
200
+ project.cobertura.data_file = data_file
201
+ project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = data_file
202
+ project.task('cobertura:instrument').invoke
203
+ end
204
+ end
205
+
206
+ [:xml, :html].each do |format|
207
+ report_target = report_to(format)
208
+ desc "Run the test cases and produce code coverage reports in #{report_target}"
209
+ task format => ["instrument", "test"] do
210
+ puts "Creating test coverage reports in #{report_target}"
211
+ Buildr.ant "cobertura" do |ant|
212
+ ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
213
+ ant.send "cobertura-report", :destdir=>report_target, :format=>format, :datafile=>data_file do
214
+ Buildr.projects.map(&:cobertura).map(&:sources).flatten.each do |src|
215
+ ant.fileset :dir=>src.to_s if File.exist?(src.to_s)
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+
222
+ task "clean" do
223
+ rm_rf [report_to, data_file], :verbose=>false
224
+ end
225
+ end
226
+
227
+ task "clean" do
228
+ task("cobertura:clean").invoke if Dir.pwd == Rake.application.original_dir
229
+ end
230
+
231
+ end
232
+ end
@@ -1,5 +1,21 @@
1
- require "java/java"
2
- require "java/ant"
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
+
3
19
 
4
20
  module Buildr
5
21
 
@@ -101,11 +117,11 @@ module Buildr
101
117
  # hibernate_schemaexport "derby.sql" do |task, ant|
102
118
  # ant.schemaexport :properties=>"derby.properties", :output=>task.name,
103
119
  # :delimiter=>";", :drop=>"no", :create=>"yes" do
104
- # fileset(:dir=>path_to(:java_src_dir)) { include :name=>"**/*.hbm.xml" } }
120
+ # fileset(:dir=>compile.sources.first) { include :name=>"**/*.hbm.xml" } }
105
121
  # end
106
122
  # end
107
123
  def hibernate_schemaexport(args, &block)
108
- path, deps = Rake.application.resolve_args(args)
124
+ path, arg_names, deps = Rake.application.resolve_args([args])
109
125
  unless Rake::Task.task_defined?(path)
110
126
  class << file(path) ; attr_accessor :ant ; end
111
127
  file(path).enhance { |task| task.ant = Hibernate.schemaexport }
@@ -1,4 +1,21 @@
1
- require "java/java"
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
+
2
19
 
3
20
  module Buildr
4
21
  # Provides JavaCC compile tasks. Require explicitly using <code>require "buildr/javacc"</code>.
@@ -6,7 +23,7 @@ module Buildr
6
23
 
7
24
  REQUIRES = [ "net.java.dev.javacc:javacc:jar:4.0", "net.java.dev.javacc:javacc:jar:4.0" ]
8
25
 
9
- Java.wrapper.classpath << REQUIRES
26
+ Java.classpath << REQUIRES
10
27
 
11
28
  class << self
12
29
 
@@ -16,10 +33,9 @@ module Buildr
16
33
 
17
34
  args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
18
35
  args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
19
- Java.wrapper do |jw|
20
- jw.import("org.javacc.parser.Main").mainProgram(args) == 0 or
21
- fail "Failed to run JavaCC, see errors above."
22
- end
36
+ Java.load
37
+ Java.org.javacc.parser.Main.mainProgram(args.to_java(Java.java.lang.String)) == 0 or
38
+ fail "Failed to run JavaCC, see errors above."
23
39
  end
24
40
 
25
41
  def jjtree(*args)
@@ -29,10 +45,9 @@ module Buildr
29
45
  args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "**/*.jjt"] : f }.flatten
30
46
  args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
31
47
  args.unshift "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
32
- Java.wrapper do |jw|
33
- jw.import("org.javacc.jjtree.JJTree").new.main(args) == 0 or
34
- fail "Failed to run JJTree, see errors above."
35
- end
48
+ Java.load
49
+ Java.org.javacc.jjtree.JJTree.new.main(args.to_java(Java.java.lang.String)) == 0 or
50
+ fail "Failed to run JJTree, see errors above."
36
51
  end
37
52
 
38
53
  end
@@ -44,7 +59,7 @@ module Buildr
44
59
  else
45
60
  in_package = []
46
61
  end
47
- file(path_to(:target, "generated/javacc")=>args.flatten) do |task|
62
+ file(path_to(:target, :generated, :javacc)=>args.flatten) do |task|
48
63
  JavaCC.javacc task.prerequisites, :output=>File.join(task.name, in_package)
49
64
  end
50
65
  end
@@ -57,7 +72,7 @@ module Buildr
57
72
  else
58
73
  in_package = []
59
74
  end
60
- file(path_to(:target, "generated/jjtree")=>args.flatten) do |task|
75
+ file(path_to(:target, :generated, :jjtree)=>args.flatten) do |task|
61
76
  JavaCC.jjtree task.prerequisites, :output=>File.join(task.name, in_package), :build_node_files=>build_node_files
62
77
  end
63
78
  end
@@ -0,0 +1,60 @@
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
+ # Addes the <code>jdepend:swing</code>, <code>jdepend:text</code> and <code>jdepend:xml</code> tasks.
23
+ # Require explicitly using <code>require "buildr/jdepend"</code>.
24
+ module Jdepend
25
+
26
+ REQUIRES = ["jdepend:jdepend:jar:2.9.1"]
27
+
28
+ class << self
29
+
30
+ def requires()
31
+ @requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
32
+ end
33
+
34
+ def paths()
35
+ Project.projects.map(&:compile).each(&:invoke).map(&:target).
36
+ map(&:to_s).select { |path| File.exist?(path) }.map { |path| File.expand_path(path) }
37
+ end
38
+
39
+ end
40
+
41
+ namespace "jdepend" do
42
+
43
+ desc "Runs JDepend on all your projects (Swing UI)"
44
+ task "swing" do
45
+ Java::Commands.java "jdepend.swingui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
46
+ end
47
+
48
+ desc "Runs JDepend on all your projects (Text UI)"
49
+ task "text" do
50
+ Java::Commands.java "jdepend.textui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
51
+ end
52
+
53
+ desc "Runs JDepend on all your projects (XML output to jdepend.xml)"
54
+ task "xml" do
55
+ Java::Commands.java "jdepend.xmlui.JDepend", "-file", "jdepend.xml", paths, :classpath=>requires, :name=>"JDepend"
56
+ puts "Created jdepend.xml"
57
+ end
58
+ end
59
+ end
60
+ end