buildr 1.5.3-x86-mswin32 → 1.5.4-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +25 -1
  3. data/addon/buildr/bnd.rb +8 -2
  4. data/addon/buildr/findbugs.rb +2 -2
  5. data/addon/buildr/gpg.rb +7 -1
  6. data/addon/buildr/gwt.rb +41 -1
  7. data/addon/buildr/jacoco.rb +18 -18
  8. data/addon/buildr/jetty.rb +14 -5
  9. data/addon/buildr/jetty6.rb +243 -0
  10. data/addon/buildr/org/apache/buildr/Jetty6Wrapper$1.class +0 -0
  11. data/addon/buildr/org/apache/buildr/Jetty6Wrapper$BuildrHandler.class +0 -0
  12. data/addon/buildr/org/apache/buildr/Jetty6Wrapper.class +0 -0
  13. data/addon/buildr/org/apache/buildr/Jetty6Wrapper.java +144 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  15. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper.java +13 -13
  17. data/buildr.buildfile +7 -1
  18. data/doc/contributing.textile +0 -19
  19. data/doc/download.textile +18 -6
  20. data/doc/index.textile +20 -12
  21. data/doc/languages.textile +23 -1
  22. data/doc/packaging.textile +21 -0
  23. data/lib/buildr/ide/idea.rb +4 -2
  24. data/lib/buildr/java/commands.rb +1 -1
  25. data/lib/buildr/kotlin.rb +17 -0
  26. data/lib/buildr/kotlin/compiler.rb +282 -0
  27. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector$1.class +0 -0
  28. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector.class +0 -0
  29. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector.java +46 -0
  30. data/lib/buildr/packaging/archive.rb +47 -11
  31. data/lib/buildr/packaging/package.rb +3 -2
  32. data/lib/buildr/packaging/tar.rb +51 -16
  33. data/lib/buildr/packaging/ziptask.rb +45 -17
  34. data/lib/buildr/version.rb +1 -1
  35. data/spec/addon/bnd_spec.rb +80 -20
  36. data/spec/kotlin/compiler_spec.rb +274 -0
  37. data/spec/packaging/archive_spec.rb +30 -0
  38. data/spec/sandbox.rb +1 -0
  39. metadata +13 -3
  40. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
@@ -0,0 +1,17 @@
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/kotlin/compiler'
@@ -0,0 +1,282 @@
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
+ # The Kotlin Module
17
+ module Buildr::Kotlin
18
+ DEFAULT_VERSION = '1.1.3-2'
19
+
20
+ class << self
21
+
22
+ def installed_version
23
+ unless @installed_version
24
+ @installed_version = if Kotlinc.installed?
25
+ begin
26
+ # try to read the value from the build.txt file
27
+ version_str = File.read(File.expand_path('build.txt', Kotlinc.kotlin_home))
28
+
29
+ if version_str
30
+ md = version_str.match(/\d+\.\d[\d\.]*/) or
31
+ fail "Unable to parse Kotlin version: #{version_str}"
32
+
33
+ md[0].sub(/.$/, "") # remove trailing dot, if any
34
+ end
35
+ rescue => e
36
+ warn "Unable to parse library.properties in $KOTLIN_HOME/build.txt: #{e}"
37
+ nil
38
+ end
39
+ end
40
+ end
41
+
42
+ @installed_version
43
+ end
44
+
45
+ def version
46
+ Buildr.settings.build['kotlin.version'] || installed_version || DEFAULT_VERSION
47
+ end
48
+
49
+ # check if version matches any of the given prefixes
50
+ def version?(*v)
51
+ v.any? { |v| version.index(v.to_s) == 0 }
52
+ end
53
+
54
+ end
55
+
56
+ # Kotlin compiler:
57
+ # compile.using(:kotlin)
58
+ # Used by default if .kt files are found in the src/main/kotlin directory (or src/test/kotlin)
59
+ # and sets the target directory to target/classes (or target/test/classes).
60
+ # Accepts the following options:
61
+ # * :warnings -- Issue warnings when compiling. True when running in verbose mode.
62
+ # * :debug -- Generates bytecode with debugging information. Set from the debug
63
+ # environment variable/global option.
64
+ # * :optimize -- Optimize the byte code generation. False by default.
65
+ # * :target -- Bytecode compatibility.
66
+ # * :noStdlib -- Include the Kotlin runtime. False by default.
67
+ # * :javac -- Arguments for javac compiler.
68
+ class Kotlinc < Buildr::Compiler::Base
69
+
70
+ class << self
71
+ def kotlin_home
72
+ env_home = ENV['KOTLIN_HOME']
73
+
74
+ @home ||= if !env_home.nil? && File.exists?(env_home + '/lib/kotlin-compiler.jar')
75
+ env_home
76
+ else
77
+ nil
78
+ end
79
+ end
80
+
81
+ def installed?
82
+ !kotlin_home.nil?
83
+ end
84
+
85
+ def use_installed?
86
+ if installed? && Buildr.settings.build['kotlin.version']
87
+ Buildr.settings.build['kotlin.version'] == Kotlin.installed_version
88
+ else
89
+ Buildr.settings.build['kotlin.version'].nil? && installed?
90
+ end
91
+ end
92
+
93
+ def dependencies
94
+ kotlin_dependencies = if use_installed?
95
+ %w(kotlin-stdlib kotlin-compiler).map { |s| File.expand_path("lib/#{s}.jar", kotlin_home) }
96
+ else
97
+ REQUIRES.artifacts.map(&:to_s)
98
+ end
99
+ # Add Java utilities (eg KotlinMessageCollector)
100
+ kotlin_dependencies |= [ File.join(File.dirname(__FILE__)) ]
101
+ (kotlin_dependencies).compact
102
+ end
103
+
104
+ def applies_to?(project, task) #:nodoc:
105
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
106
+ paths.flatten!
107
+
108
+ # Just select if we find .kt files
109
+ paths.any? { |path| !Dir["#{path}/**/*.kt"].empty? }
110
+ end
111
+ end
112
+
113
+ # The kotlin compiler jars are added to classpath at load time,
114
+ # if you want to customize artifact versions, you must set them on the
115
+ #
116
+ # artifact_ns['Buildr::Compiler::Kotlinc'].library = '1.1.3-2'
117
+ #
118
+ # namespace before this file is required. This is of course, only
119
+ # if KOTLIN_HOME is not set or invalid.
120
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
121
+ version = Buildr.settings.build['kotlin.version'] || DEFAULT_VERSION
122
+ ns.compiler! 'org.jetbrains.kotlin:kotlin-compiler:jar:>=' + version
123
+ end
124
+
125
+ Javac = Buildr::Compiler::Javac
126
+
127
+ OPTIONS = [:warnings, :optimize, :target, :debug, :noStdlib, :javac]
128
+
129
+ # Lazy evaluation to allow change in buildfile
130
+ Java.classpath << lambda { dependencies }
131
+
132
+ specify :language=>:kotlin, :sources => [:kotlin, :java], :source_ext => [:kt, :java],
133
+ :target=>'classes', :target_ext=>'class', :packaging=>:jar
134
+
135
+ def initialize(project, options) #:nodoc:
136
+ super
137
+ # use common options also for javac
138
+
139
+ options[:javac] ||= Buildr::Compiler::Javac::OPTIONS.inject({}) do |hash, option|
140
+ hash[option] = options[option]
141
+ hash
142
+ end
143
+
144
+ options[:debug] = Buildr.options.debug || trace?(:kotlinc) if options[:debug].nil?
145
+ options[:warnings] = verbose if options[:warnings].nil?
146
+ options[:optimize] = false if options[:optimize].nil?
147
+ options[:noStdlib] = true if options[:noStdlib].nil?
148
+ @java = Javac.new(project, options[:javac])
149
+ end
150
+
151
+
152
+
153
+ def compile(sources, target, dependencies) #:nodoc:
154
+ check_options(options, OPTIONS)
155
+
156
+ java_sources = java_sources(sources)
157
+
158
+ unless Buildr.application.options.dryrun
159
+ messageCollector = Java.org.apache.buildr.KotlinMessageCollector.new
160
+
161
+ Java.load
162
+ begin
163
+ compiler = Java.org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.new
164
+ compilerArguments = kotlinc_args
165
+ compilerArguments.destination = File.expand_path(target)
166
+ compilerArguments.classpath = dependencies.join(File::PATH_SEPARATOR)
167
+ sources.each do |source|
168
+ compilerArguments.freeArgs.add(File.expand_path(source))
169
+ end
170
+ services = Buildr::Util.java_platform? ? Java.org.jetbrains.kotlin.config.Services::EMPTY : Java.org.jetbrains.kotlin.config.Services.EMPTY
171
+ compiler.exec(messageCollector, services, compilerArguments)
172
+ rescue => e
173
+ fail "Kotlin compiler crashed:\n#{e.inspect}"
174
+ end
175
+
176
+ unless java_sources.empty?
177
+ trace 'Compiling mixed Java/Kotlin sources'
178
+
179
+ deps = dependencies + Kotlinc.dependencies + [ File.expand_path(target) ]
180
+ @java.compile(java_sources, target, deps)
181
+ end
182
+ end
183
+ end
184
+
185
+ protected
186
+
187
+ # :nodoc: see Compiler:Base
188
+ def compile_map(sources, target)
189
+ target_ext = self.class.target_ext
190
+ ext_glob = Array(self.class.source_ext).join(',')
191
+ sources.flatten.map{|f| File.expand_path(f)}.inject({}) do |map, source|
192
+ sources = if File.directory?(source)
193
+ FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }
194
+ else
195
+ [source]
196
+ end
197
+
198
+ sources.each do |source|
199
+ # try to extract package name from .java or .kt files
200
+ if %w(.java .kt).include? File.extname(source)
201
+ name = File.basename(source).split(".")[0]
202
+ package = findFirst(source, /^\s*package\s+([^\s;]+)\s*;?\s*/)
203
+ packages = count(source, /^\s*package\s+([^\s;]+)\s*;?\s*/)
204
+ found = findFirst(source, /((class)|(object))\s+(#{name})Kt/)
205
+
206
+ # if there's only one package statement and we know the target name, then we can depend
207
+ # directly on a specific file, otherwise, we depend on the general target
208
+ if (found && packages == 1)
209
+ map[source] = package ? File.join(target, package[1].gsub('.', '/'), name.ext(target_ext)) : target
210
+ else
211
+ map[source] = target
212
+ end
213
+
214
+ elsif
215
+ map[source] = target
216
+ end
217
+ end
218
+
219
+ map.each do |key,value|
220
+ map[key] = first_file unless map[key]
221
+ end
222
+
223
+ map
224
+ end
225
+ end
226
+
227
+ private
228
+
229
+ def count(file, pattern)
230
+ count = 0
231
+ File.open(file, 'r') do |infile|
232
+ while (line = infile.gets)
233
+ count += 1 if line.match(pattern)
234
+ end
235
+ end
236
+ count
237
+ end
238
+
239
+ def java_sources(sources)
240
+ sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.java"] : source } .
241
+ flatten.reject { |file| File.directory?(file) || File.extname(file) != '.java' }.map { |file| File.expand_path(file) }.uniq
242
+ end
243
+
244
+ # Returns Kotlinc arguments from the set of options.
245
+ def kotlinc_args #:nodoc:
246
+ compilerArguments = Java.org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.new
247
+ compilerArguments.verbose = options[:debug]
248
+ compilerArguments.suppressWarnings = !options[:warnings]
249
+ compilerArguments.noStdlib = options[:noStdlib]
250
+ compilerArguments.noOptimize = !options[:optimize]
251
+ compilerArguments.reportOutputFiles = compilerArguments.verbose
252
+ compilerArguments.jvmTarget = options[:target] unless options[:target].nil?
253
+ compilerArguments
254
+ end
255
+ end
256
+
257
+ module ProjectExtension
258
+ def kotlinc_options
259
+ @kotlinc ||= KotlincOptions.new(self)
260
+ end
261
+ end
262
+
263
+ class KotlincOptions
264
+ attr_writer :incremental
265
+
266
+ def initialize(project)
267
+ @project = project
268
+ end
269
+
270
+ def incremental
271
+ @incremental || (@project.parent ? @project.parent.kotlinc_options.incremental : nil)
272
+ end
273
+ end
274
+ end
275
+
276
+ # Kotlin compiler comes first, ahead of Javac, this allows it to pick
277
+ # projects that mix Kotlin and Java code by spotting Kotlin code first.
278
+ Buildr::Compiler.compilers.unshift Buildr::Kotlin::Kotlinc
279
+
280
+ class Buildr::Project #:nodoc:
281
+ include Buildr::Kotlin::ProjectExtension
282
+ end
@@ -0,0 +1,46 @@
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 org.jetbrains.kotlin.cli.common.messages.MessageCollector;
21
+ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;
22
+ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation;
23
+
24
+
25
+ public class KotlinMessageCollector implements MessageCollector {
26
+
27
+ public void report(CompilerMessageSeverity severity, String message, CompilerMessageLocation location) {
28
+ switch(severity) {
29
+ case ERROR:
30
+ case EXCEPTION:
31
+ System.err.println((location != null ? (location.toString() + " ") : "") + message);
32
+ break;
33
+ default:
34
+ System.out.println((location != null ? (location.toString() + " ") : "") + message);
35
+ break;
36
+ }
37
+ }
38
+
39
+ public boolean hasErrors() {
40
+ return false;
41
+ }
42
+
43
+ public void clear() {
44
+ // not implemented
45
+ }
46
+ }
@@ -112,9 +112,9 @@ module Buildr #:nodoc:
112
112
  expanders = files.collect do |file|
113
113
  @sources << proc { file.to_s }
114
114
  expander = ZipExpander.new(file)
115
- @actions << proc do |file_map|
115
+ @actions << proc do |file_map, transform_map|
116
116
  file.invoke() if file.is_a?(Rake::Task)
117
- expander.expand(file_map, path)
117
+ expander.expand(file_map, transform_map, path)
118
118
  end
119
119
  expander
120
120
  end
@@ -133,8 +133,8 @@ module Buildr #:nodoc:
133
133
  @sources.map{ |source| source.call }.flatten
134
134
  end
135
135
 
136
- def add_files(file_map) #:nodoc:
137
- @actions.each { |action| action.call(file_map) }
136
+ def add_files(file_map, transform_map) #:nodoc:
137
+ @actions.each { |action| action.call(file_map, transform_map) }
138
138
  end
139
139
 
140
140
  # :call-seq:
@@ -267,6 +267,16 @@ module Buildr #:nodoc:
267
267
  @expanders.each { |expander| expander.exclude(*files) }
268
268
  self
269
269
  end
270
+
271
+ def concatenate(*files)
272
+ @expanders.each { |expander| expander.concatenate(*files) }
273
+ self
274
+ end
275
+
276
+ def transform(*files, &block)
277
+ @expanders.each { |expander| expander.transform(*files, &block) }
278
+ self
279
+ end
270
280
  end
271
281
 
272
282
 
@@ -277,6 +287,8 @@ module Buildr #:nodoc:
277
287
  @zip_file = zip_file.to_s
278
288
  @includes = []
279
289
  @excludes = []
290
+ @concatenates = []
291
+ @transforms = {}
280
292
  end
281
293
 
282
294
  def include(*files)
@@ -289,8 +301,18 @@ module Buildr #:nodoc:
289
301
  @excludes |= files
290
302
  self
291
303
  end
304
+
305
+ def concatenate(*files)
306
+ @concatenates |= files
307
+ self
308
+ end
309
+
310
+ def transform(*files, &block)
311
+ @transforms[[files].flatten] = block
312
+ self
313
+ end
292
314
 
293
- def expand(file_map, path)
315
+ def expand(file_map, transform_map, path)
294
316
  @includes = ['*'] if @includes.empty?
295
317
  Zip::File.open(@zip_file) do |source|
296
318
  source.entries.reject { |entry| entry.directory? }.each do |entry|
@@ -298,7 +320,19 @@ module Buildr #:nodoc:
298
320
  !@excludes.any? { |pattern| File.fnmatch(pattern, entry.name) }
299
321
  dest = path =~ /^\/?$/ ? entry.name : Util.relative_path(path + "/" + entry.name)
300
322
  trace "Adding #{dest}"
301
- file_map[dest] = ZipEntryData.new(source, entry)
323
+ if @concatenates.any? { |pattern| File.fnmatch(pattern, entry.name) }
324
+ file_map[dest] << ZipEntryData.new(source, entry)
325
+ elsif @transforms.each_pair.detect do |transform, transform_block|\
326
+ if transform.any? { |pattern| File.fnmatch(pattern, entry.name) }
327
+ file_map[dest] << ZipEntryData.new(source, entry)
328
+
329
+ transform_map[dest] = transform_block
330
+ true
331
+ end
332
+ end
333
+ else
334
+ file_map[dest] = ZipEntryData.new(source, entry)
335
+ end
302
336
  end
303
337
  end
304
338
  end
@@ -327,7 +361,8 @@ module Buildr #:nodoc:
327
361
 
328
362
  # Make sure we're the last enhancements, so other enhancements can add content.
329
363
  enhance do
330
- @file_map = {}
364
+ @file_map = Hash.new {|h,k| h[k]=[]}
365
+ @transform_map = {}
331
366
  enhance do
332
367
  send 'create' if respond_to?(:create)
333
368
  # We're here because the archive file does not exist, or one of the files is newer than the archive contents;
@@ -338,9 +373,9 @@ module Buildr #:nodoc:
338
373
  begin
339
374
  @paths.each do |name, object|
340
375
  @file_map[name] = nil unless name.empty?
341
- object.add_files(@file_map)
376
+ object.add_files(@file_map, @transform_map)
342
377
  end
343
- create_from @file_map
378
+ create_from @file_map, @transform_map
344
379
  rescue
345
380
  rm name rescue nil
346
381
  raise
@@ -485,9 +520,10 @@ module Buildr #:nodoc:
485
520
  @prepares.each { |prepare| prepare.call(self) }
486
521
  @prepares.clear
487
522
 
488
- file_map = {}
523
+ file_map = Hash.new {|h,k| h[k]=[]}
524
+ transform_map = {}
489
525
  @paths.each do |name, path|
490
- path.add_files(file_map)
526
+ path.add_files(file_map, transform_map)
491
527
  end
492
528
 
493
529
  # filter out Procs (dynamic content), nils and others