buildr 1.3.3-java → 1.3.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/CHANGELOG +76 -0
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +17 -34
  5. data/_buildr +3 -12
  6. data/{doc/print.toc.yaml → _jbuildr} +14 -14
  7. data/addon/buildr/cobertura.rb +5 -219
  8. data/addon/buildr/drb.rb +281 -0
  9. data/addon/buildr/emma.rb +5 -221
  10. data/addon/buildr/nailgun.rb +93 -689
  11. data/bin/buildr +0 -9
  12. data/buildr.buildfile +4 -4
  13. data/buildr.gemspec +27 -21
  14. data/doc/_layouts/default.html +82 -0
  15. data/doc/_layouts/preface.html +22 -0
  16. data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
  17. data/doc/{pages/building.textile → building.textile} +89 -47
  18. data/doc/{pages/contributing.textile → contributing.textile} +53 -45
  19. data/doc/css/default.css +6 -5
  20. data/doc/css/print.css +17 -24
  21. data/doc/css/syntax.css +7 -36
  22. data/doc/download.textile +68 -0
  23. data/doc/{pages/extending.textile → extending.textile} +45 -24
  24. data/doc/{pages/getting_started.textile → getting_started.textile} +158 -88
  25. data/doc/images/asf-logo.gif +0 -0
  26. data/doc/images/note.png +0 -0
  27. data/doc/index.textile +47 -0
  28. data/doc/{pages/languages.textile → languages.textile} +108 -54
  29. data/doc/mailing_lists.textile +25 -0
  30. data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
  31. data/doc/{pages/packaging.textile → packaging.textile} +181 -96
  32. data/doc/preface.textile +28 -0
  33. data/doc/{pages/projects.textile → projects.textile} +55 -40
  34. data/doc/scripts/buildr-git.rb +364 -264
  35. data/doc/scripts/gitflow.rb +296 -0
  36. data/doc/scripts/install-jruby.sh +2 -2
  37. data/doc/scripts/install-linux.sh +6 -6
  38. data/doc/scripts/install-osx.sh +2 -2
  39. data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
  40. data/doc/{pages/testing.textile → testing.textile} +77 -41
  41. data/lib/buildr.rb +5 -5
  42. data/lib/buildr/core.rb +2 -0
  43. data/lib/buildr/core/application.rb +321 -151
  44. data/lib/buildr/core/build.rb +298 -167
  45. data/lib/buildr/core/checks.rb +4 -132
  46. data/lib/buildr/core/common.rb +1 -5
  47. data/lib/buildr/core/compile.rb +3 -9
  48. data/lib/buildr/core/environment.rb +12 -3
  49. data/lib/buildr/core/filter.rb +20 -18
  50. data/lib/buildr/core/generate.rb +36 -36
  51. data/lib/buildr/core/help.rb +2 -1
  52. data/lib/buildr/core/osx.rb +46 -0
  53. data/lib/buildr/core/progressbar.rb +1 -1
  54. data/lib/buildr/core/project.rb +7 -34
  55. data/lib/buildr/core/test.rb +12 -6
  56. data/lib/buildr/core/transports.rb +13 -11
  57. data/lib/buildr/core/util.rb +14 -23
  58. data/lib/buildr/groovy/bdd.rb +3 -2
  59. data/lib/buildr/groovy/compiler.rb +1 -1
  60. data/lib/buildr/ide/eclipse.rb +31 -21
  61. data/lib/buildr/ide/idea.rb +3 -2
  62. data/lib/buildr/ide/idea7x.rb +6 -4
  63. data/lib/buildr/java/ant.rb +3 -1
  64. data/lib/buildr/java/bdd.rb +9 -7
  65. data/lib/buildr/java/cobertura.rb +243 -0
  66. data/lib/buildr/java/compiler.rb +5 -4
  67. data/lib/buildr/java/emma.rb +244 -0
  68. data/lib/buildr/java/packaging.rb +11 -8
  69. data/lib/buildr/java/pom.rb +0 -4
  70. data/lib/buildr/java/rjb.rb +1 -1
  71. data/lib/buildr/java/test_result.rb +5 -7
  72. data/lib/buildr/java/tests.rb +17 -11
  73. data/lib/buildr/packaging.rb +5 -2
  74. data/lib/buildr/packaging/archive.rb +488 -0
  75. data/lib/buildr/packaging/artifact.rb +48 -29
  76. data/lib/buildr/packaging/artifact_namespace.rb +6 -6
  77. data/lib/buildr/packaging/gems.rb +4 -4
  78. data/lib/buildr/packaging/package.rb +3 -2
  79. data/lib/buildr/packaging/tar.rb +85 -3
  80. data/lib/buildr/packaging/version_requirement.rb +172 -0
  81. data/lib/buildr/packaging/zip.rb +24 -682
  82. data/lib/buildr/packaging/ziptask.rb +313 -0
  83. data/lib/buildr/scala.rb +5 -0
  84. data/lib/buildr/scala/bdd.rb +100 -0
  85. data/lib/buildr/scala/compiler.rb +45 -4
  86. data/lib/buildr/scala/tests.rb +12 -59
  87. data/rakelib/checks.rake +57 -0
  88. data/rakelib/doc.rake +58 -68
  89. data/rakelib/jekylltask.rb +110 -0
  90. data/rakelib/package.rake +35 -37
  91. data/rakelib/release.rake +119 -35
  92. data/rakelib/rspec.rake +29 -39
  93. data/rakelib/setup.rake +21 -59
  94. data/rakelib/stage.rake +184 -26
  95. data/spec/addon/drb_spec.rb +328 -0
  96. data/spec/core/application_spec.rb +32 -25
  97. data/spec/core/build_spec.rb +336 -126
  98. data/spec/core/checks_spec.rb +292 -310
  99. data/spec/core/common_spec.rb +8 -2
  100. data/spec/core/compile_spec.rb +17 -1
  101. data/spec/core/generate_spec.rb +3 -3
  102. data/spec/core/project_spec.rb +18 -10
  103. data/spec/core/test_spec.rb +8 -1
  104. data/spec/core/transport_spec.rb +40 -3
  105. data/spec/core/util_spec.rb +67 -0
  106. data/spec/ide/eclipse_spec.rb +96 -28
  107. data/spec/ide/idea7x_spec.rb +84 -0
  108. data/spec/java/ant.rb +5 -0
  109. data/spec/java/bdd_spec.rb +12 -3
  110. data/spec/{addon → java}/cobertura_spec.rb +6 -6
  111. data/spec/{addon → java}/emma_spec.rb +5 -6
  112. data/spec/java/java_spec.rb +12 -2
  113. data/spec/java/packaging_spec.rb +31 -2
  114. data/spec/{addon → java}/test_coverage_spec.rb +3 -3
  115. data/spec/java/tests_spec.rb +5 -0
  116. data/spec/packaging/archive_spec.rb +11 -1
  117. data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
  118. data/spec/packaging/artifact_spec.rb +44 -3
  119. data/spec/packaging/packaging_spec.rb +1 -1
  120. data/spec/sandbox.rb +17 -14
  121. data/spec/scala/bdd_spec.rb +150 -0
  122. data/spec/scala/compiler_spec.rb +27 -0
  123. data/spec/scala/scala.rb +38 -0
  124. data/spec/scala/tests_spec.rb +78 -33
  125. data/spec/spec_helpers.rb +29 -5
  126. data/spec/version_requirement_spec.rb +6 -0
  127. metadata +176 -172
  128. data/DISCLAIMER +0 -7
  129. data/doc/images/apache-incubator-logo.png +0 -0
  130. data/doc/pages/download.textile +0 -51
  131. data/doc/pages/index.textile +0 -42
  132. data/doc/pages/mailing_lists.textile +0 -17
  133. data/doc/pages/recipes.textile +0 -103
  134. data/doc/pages/troubleshooting.textile +0 -103
  135. data/doc/pages/whats_new.textile +0 -323
  136. data/doc/print.haml +0 -51
  137. data/doc/site.haml +0 -56
  138. data/doc/site.toc.yaml +0 -47
  139. data/etc/git-svn-authors +0 -16
  140. data/lib/buildr/core/application_cli.rb +0 -139
  141. data/rakelib/apache.rake +0 -191
  142. data/rakelib/changelog.rake +0 -57
  143. data/rakelib/rubyforge.rake +0 -53
  144. data/rakelib/scm.rake +0 -49
@@ -0,0 +1,313 @@
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/packaging/archive'
18
+
19
+
20
+ module Buildr
21
+
22
+ # The ZipTask creates a new Zip file. You can include any number of files and and directories,
23
+ # use exclusion patterns, and include files into specific directories.
24
+ #
25
+ # For example:
26
+ # zip('test.zip').tap do |task|
27
+ # task.include 'srcs'
28
+ # task.include 'README', 'LICENSE'
29
+ # end
30
+ #
31
+ # See Buildr#zip and ArchiveTask.
32
+ class ZipTask < ArchiveTask
33
+
34
+ # Compression leve for this Zip.
35
+ attr_accessor :compression_level
36
+
37
+ def initialize(*args) #:nodoc:
38
+ self.compression_level = Zlib::DEFAULT_COMPRESSION
39
+ super
40
+ end
41
+
42
+ # :call-seq:
43
+ # entry(name) => Entry
44
+ #
45
+ # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
46
+ # for example:
47
+ # package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
48
+ def entry(entry_name)
49
+ ::Zip::ZipEntry.new(name, entry_name)
50
+ end
51
+
52
+ def entries #:nodoc:
53
+ @entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
54
+ end
55
+
56
+ private
57
+
58
+ def create_from(file_map)
59
+ Zip::ZipOutputStream.open name do |zip|
60
+ seen = {}
61
+ mkpath = lambda do |dir|
62
+ unless dir == '.' || seen[dir]
63
+ mkpath.call File.dirname(dir)
64
+ zip.put_next_entry(dir + '/', compression_level)
65
+ seen[dir] = true
66
+ end
67
+ end
68
+
69
+ file_map.each do |path, content|
70
+ mkpath.call File.dirname(path)
71
+ if content.respond_to?(:call)
72
+ zip.put_next_entry(path, compression_level)
73
+ content.call zip
74
+ elsif content.nil? || File.directory?(content.to_s)
75
+ mkpath.call path
76
+ else
77
+ zip.put_next_entry(path, compression_level)
78
+ File.open content.to_s, 'rb' do |is|
79
+ while data = is.read(4096)
80
+ zip << data
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+
91
+ # :call-seq:
92
+ # zip(file) => ZipTask
93
+ #
94
+ # The ZipTask creates a new Zip file. You can include any number of files and
95
+ # and directories, use exclusion patterns, and include files into specific
96
+ # directories.
97
+ #
98
+ # For example:
99
+ # zip('test.zip').tap do |task|
100
+ # task.include 'srcs'
101
+ # task.include 'README', 'LICENSE'
102
+ # end
103
+ def zip(file)
104
+ ZipTask.define_task(file)
105
+ end
106
+
107
+
108
+ # An object for unzipping a file into a target directory. You can tell it to include
109
+ # or exclude only specific files and directories, and also to map files from particular
110
+ # paths inside the zip file into the target directory. Once ready, call #extract.
111
+ #
112
+ # Usually it is more convenient to create a file task for extracting the zip file
113
+ # (see #unzip) and pass this object as a prerequisite to other tasks.
114
+ #
115
+ # See Buildr#unzip.
116
+ class Unzip
117
+
118
+ # The zip file to extract.
119
+ attr_accessor :zip_file
120
+ # The target directory to extract to.
121
+ attr_accessor :target
122
+
123
+ # Initialize with hash argument of the form target=>zip_file.
124
+ def initialize(args)
125
+ @target, arg_names, @zip_file = Buildr.application.resolve_args([args])
126
+ @paths = {}
127
+ end
128
+
129
+ # :call-seq:
130
+ # extract
131
+ #
132
+ # Extract the zip file into the target directory.
133
+ #
134
+ # You can call this method directly. However, if you are using the #unzip method,
135
+ # it creates a file task for the target directory: use that task instead as a
136
+ # prerequisite. For example:
137
+ # build unzip(dir=>zip_file)
138
+ # Or:
139
+ # unzip(dir=>zip_file).target.invoke
140
+ def extract
141
+ # If no paths specified, then no include/exclude patterns
142
+ # specified. Nothing will happen unless we include all files.
143
+ if @paths.empty?
144
+ @paths[nil] = FromPath.new(self, nil)
145
+ end
146
+
147
+ # Otherwise, empty unzip creates target as a file when touching.
148
+ mkpath target.to_s
149
+ Zip::ZipFile.open(zip_file.to_s) do |zip|
150
+ entries = zip.collect
151
+ @paths.each do |path, patterns|
152
+ patterns.map(entries).each do |dest, entry|
153
+ next if entry.directory?
154
+ dest = File.expand_path(dest, target.to_s)
155
+ trace "Extracting #{dest}"
156
+ mkpath File.dirname(dest) rescue nil
157
+ entry.extract(dest) { true }
158
+ end
159
+ end
160
+ end
161
+ # Let other tasks know we updated the target directory.
162
+ touch target.to_s
163
+ end
164
+
165
+ # :call-seq:
166
+ # include(*files) => self
167
+ # include(*files, :path=>name) => self
168
+ #
169
+ # Include all files that match the patterns and returns self.
170
+ #
171
+ # Use include if you only want to unzip some of the files, by specifying
172
+ # them instead of using exclusion. You can use #include in combination
173
+ # with #exclude.
174
+ def include(*files)
175
+ if Hash === files.last
176
+ from_path(files.pop[:path]).include *files
177
+ else
178
+ from_path(nil).include *files
179
+ end
180
+ self
181
+ end
182
+ alias :add :include
183
+
184
+ # :call-seq:
185
+ # exclude(*files) => self
186
+ #
187
+ # Exclude all files that match the patterns and return self.
188
+ #
189
+ # Use exclude to unzip all files except those that match the pattern.
190
+ # You can use #exclude in combination with #include.
191
+ def exclude(*files)
192
+ if Hash === files.last
193
+ from_path(files.pop[:path]).exclude *files
194
+ else
195
+ from_path(nil).exclude *files
196
+ end
197
+ self
198
+ end
199
+
200
+ # :call-seq:
201
+ # from_path(name) => Path
202
+ #
203
+ # Allows you to unzip from a path. Returns an object you can use to
204
+ # specify which files to include/exclude relative to that path.
205
+ # Expands the file relative to that path.
206
+ #
207
+ # For example:
208
+ # unzip(Dir.pwd=>'test.jar').from_path('etc').include('LICENSE')
209
+ # will unzip etc/LICENSE into ./LICENSE.
210
+ #
211
+ # This is different from:
212
+ # unzip(Dir.pwd=>'test.jar').include('etc/LICENSE')
213
+ # which unzips etc/LICENSE into ./etc/LICENSE.
214
+ def from_path(name)
215
+ @paths[name] ||= FromPath.new(self, name)
216
+ end
217
+ alias :path :from_path
218
+
219
+ # :call-seq:
220
+ # root => Unzip
221
+ #
222
+ # Returns the root path, essentially the Unzip object itself. In case you are wondering
223
+ # down paths and want to go back.
224
+ def root
225
+ self
226
+ end
227
+
228
+ # Returns the path to the target directory.
229
+ def to_s
230
+ target.to_s
231
+ end
232
+
233
+ class FromPath #:nodoc:
234
+
235
+ def initialize(unzip, path)
236
+ @unzip = unzip
237
+ if path
238
+ @path = path[-1] == ?/ ? path : path + '/'
239
+ else
240
+ @path = ''
241
+ end
242
+ end
243
+
244
+ # See UnzipTask#include
245
+ def include(*files) #:doc:
246
+ @include ||= []
247
+ @include |= files
248
+ self
249
+ end
250
+
251
+ # See UnzipTask#exclude
252
+ def exclude(*files) #:doc:
253
+ @exclude ||= []
254
+ @exclude |= files
255
+ self
256
+ end
257
+
258
+ def map(entries)
259
+ includes = @include || ['*']
260
+ excludes = @exclude || []
261
+ entries.inject({}) do |map, entry|
262
+ if entry.name =~ /^#{@path}/
263
+ short = entry.name.sub(@path, '')
264
+ if includes.any? { |pat| File.fnmatch(pat, short) } &&
265
+ !excludes.any? { |pat| File.fnmatch(pat, short) }
266
+ map[short] = entry
267
+ end
268
+ end
269
+ map
270
+ end
271
+ end
272
+
273
+ # Documented in Unzip.
274
+ def root
275
+ @unzip
276
+ end
277
+
278
+ # The target directory to extract to.
279
+ def target
280
+ @unzip.target
281
+ end
282
+
283
+ end
284
+
285
+ end
286
+
287
+ # :call-seq:
288
+ # unzip(to_dir=>zip_file) => Zip
289
+ #
290
+ # Creates a task that will unzip a file into the target directory. The task name
291
+ # is the target directory, the prerequisite is the file to unzip.
292
+ #
293
+ # This method creates a file task to expand the zip file. It returns an Unzip object
294
+ # that specifies how the file will be extracted. You can include or exclude specific
295
+ # files from within the zip, and map to different paths.
296
+ #
297
+ # The Unzip object's to_s method return the path to the target directory, so you can
298
+ # use it as a prerequisite. By keeping the Unzip object separate from the file task,
299
+ # you overlay additional work on top of the file task.
300
+ #
301
+ # For example:
302
+ # unzip('all'=>'test.zip')
303
+ # unzip('src'=>'test.zip').include('README', 'LICENSE')
304
+ # unzip('libs'=>'test.zip').from_path('libs')
305
+ def unzip(args)
306
+ target, arg_names, zip_file = Buildr.application.resolve_args([args])
307
+ task = file(File.expand_path(target.to_s)=>zip_file)
308
+ Unzip.new(task=>zip_file).tap do |setup|
309
+ task.enhance { setup.extract }
310
+ end
311
+ end
312
+
313
+ end
@@ -14,6 +14,11 @@
14
14
  # the License.
15
15
 
16
16
 
17
+ ENV['SCALA_HOME'] ||= '/opt/local/share/scala/' if File.exist?('/opt/local/share/scala/lib/scala-compiler.jar')
18
+ Buildr.repositories.remote << 'http://scala-tools.org/repo-releases'
19
+
17
20
  require 'buildr/scala/compiler'
18
21
  require 'buildr/scala/tests'
22
+ require 'buildr/scala/bdd'
23
+
19
24
  Object::Scala = Buildr::Scala
@@ -0,0 +1,100 @@
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/build'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/java/bdd'
20
+ require 'buildr/scala/tests'
21
+
22
+ module Buildr::Scala
23
+
24
+ # Specs is a Scala based BDD framework.
25
+ # To use in your project:
26
+ #
27
+ # test.using :specs
28
+ #
29
+ # This framework will search in your project for:
30
+ # src/spec/scala/**/*.scala
31
+ class Specs < Buildr::TestFramework::JavaBDD
32
+ @lang = :scala
33
+ @bdd_dir = :spec
34
+
35
+ VERSION = '1.4.3'
36
+
37
+ class << self
38
+ def version
39
+ Buildr.settings.build['scala.specs'] || VERSION
40
+ end
41
+
42
+ def dependencies
43
+ ["org.specs:specs:jar:#{version}"] + Check.dependencies +
44
+ JMock.dependencies + JUnit.dependencies
45
+ end
46
+
47
+ def applies_to?(project) #:nodoc:
48
+ !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty?
49
+ end
50
+
51
+ private
52
+ def const_missing(const)
53
+ return super unless const == :REQUIRES # TODO: remove in 1.5
54
+ Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
55
+ dependencies
56
+ end
57
+ end
58
+
59
+ def initialize(task, options) #:nodoc:
60
+ super
61
+
62
+ specs = task.project.path_to(:source, :spec, :scala)
63
+ task.compile.from specs if File.directory?(specs)
64
+
65
+ resources = task.project.path_to(:source, :spec, :resources)
66
+ task.resources.from resources if File.directory?(resources)
67
+ end
68
+
69
+ def tests(dependencies)
70
+ dependencies += [task.compile.target.to_s]
71
+ filter_classes(dependencies, :interfaces => ['org.specs.Specification'])
72
+ end
73
+
74
+ def run(specs, dependencies) #:nodoc:
75
+ dependencies += [task.compile.target.to_s] + Scalac.dependencies
76
+
77
+ cmd_options = { :properties => options[:properties],
78
+ :java_args => options[:java_args],
79
+ :classpath => dependencies}
80
+
81
+ specs.inject [] do |passed, spec|
82
+ begin
83
+ Java.load
84
+ Java::Commands.java(spec, cmd_options)
85
+ rescue => e
86
+ passed
87
+ else
88
+ passed << spec
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ # Backwards compatibility stuff. Remove in 1.5.
96
+ module Buildr
97
+ ScalaSpecs = Scala::Specs
98
+ end
99
+
100
+ Buildr::TestFramework << Buildr::Scala::Specs
@@ -18,9 +18,22 @@ require 'buildr/core/common'
18
18
  require 'buildr/core/compile'
19
19
  require 'buildr/packaging'
20
20
 
21
-
22
21
  module Buildr::Scala
22
+
23
+ class << self
24
+ def version_str
25
+ # Scala version string normally looks like "version 2.7.3.final"
26
+ Java.scala.util.Properties.versionString.sub 'version ', ''
27
+ end
23
28
 
29
+ def version
30
+ # any consecutive sequence of numbers followed by dots
31
+ match = version_str.match(/\d+\.\d[\d\.]*/) or
32
+ fail "Unable to parse Scala version: #{version_str} "
33
+ match[0].sub(/.$/, "") # remove trailing dot, if any
34
+ end
35
+ end
36
+
24
37
  # Scalac compiler:
25
38
  # compile.using(:scalac)
26
39
  # Used by default if .scala files are found in the src/main/scala directory (or src/test/scala)
@@ -46,12 +59,24 @@ module Buildr::Scala
46
59
  def use_fsc
47
60
  ENV["USE_FSC"] =~ /^(yes|on|true)$/i
48
61
  end
62
+
63
+ def applies_to?(project, task) #:nodoc:
64
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
65
+ paths.flatten!
66
+
67
+ # Just select if we find .scala files
68
+ paths.any? { |path| !Dir["#{path}/**/*.scala"].empty? }
69
+ end
49
70
  end
71
+
72
+ Javac = Buildr::Compiler::Javac
50
73
 
51
- OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other]
74
+ OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other, :javac]
75
+
52
76
  Java.classpath << dependencies
53
77
 
54
- specify :language=>:scala, :target=>'classes', :target_ext=>'class', :packaging=>:jar
78
+ specify :language=>:scala, :sources => [:scala, :java], :source_ext => [:scala, :java],
79
+ :target=>'classes', :target_ext=>'class', :packaging=>:jar
55
80
 
56
81
  def initialize(project, options) #:nodoc:
57
82
  super
@@ -59,6 +84,9 @@ module Buildr::Scala
59
84
  options[:warnings] = verbose if options[:warnings].nil?
60
85
  options[:deprecation] ||= false
61
86
  options[:optimise] ||= false
87
+ options[:javac] ||= {}
88
+
89
+ @java = Javac.new(project, options[:javac])
62
90
  end
63
91
 
64
92
  def compile(sources, target, dependencies) #:nodoc:
@@ -83,10 +111,23 @@ module Buildr::Scala
83
111
  Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
84
112
  fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
85
113
  end
114
+
115
+ if java_applies? sources
116
+ trace 'Compiling mixed Java/Scala sources'
117
+
118
+ deps = dependencies + [ File.expand_path('lib/scala-library.jar', Scalac.scala_home),
119
+ File.expand_path(target) ]
120
+ @java.compile(sources, target, deps)
121
+ end
86
122
  end
87
123
  end
88
124
 
89
125
  private
126
+
127
+ def java_applies?(sources)
128
+ not sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.java"] : source }.
129
+ flatten.reject { |file| File.directory?(file) }.map { |file| File.expand_path(file) }.uniq.empty?
130
+ end
90
131
 
91
132
  # Returns Scalac command line arguments from the set of options.
92
133
  def scalac_args #:nodoc:
@@ -106,4 +147,4 @@ end
106
147
 
107
148
  # Scala compiler comes first, ahead of Javac, this allows it to pick
108
149
  # projects that mix Scala and Java code by spotting Scala code first.
109
- Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac
150
+ Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac