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
@@ -182,7 +182,7 @@ module Buildr #:nodoc:
182
182
  end
183
183
  @pom
184
184
  end
185
- end
185
+ end if package.classifier.nil?
186
186
 
187
187
  file(Buildr.repositories.locate(package)=>package) { package.install }
188
188
 
@@ -190,7 +190,8 @@ module Buildr #:nodoc:
190
190
  # register it as an artifact. The later is required so if we look up the spec
191
191
  # we find the package in the project's target directory, instead of finding it
192
192
  # in the local repository and attempting to install it.
193
- Artifact.register package, package.pom
193
+ Artifact.register package
194
+ Artifact.register package.pom if package.classifier.nil?
194
195
  end
195
196
 
196
197
  task('install') { package.install if package.respond_to?(:install) }
@@ -72,40 +72,75 @@ module Buildr #:nodoc:
72
72
  end
73
73
  end
74
74
 
75
- private
75
+ private
76
76
 
77
- def create_from(file_map)
77
+ def create_from(file_map, transform_map)
78
78
  if gzip
79
79
  StringIO.new.tap do |io|
80
- create_tar io, file_map
80
+ create_tar io, file_map, transform_map
81
81
  io.seek 0
82
82
  Zlib::GzipWriter.open(name) { |gzip| gzip.write io.read }
83
83
  end
84
84
  else
85
- File.open(name, 'wb') { |file| create_tar file, file_map }
85
+ File.open(name, 'wb') { |file| create_tar file, file_map, transform_map }
86
86
  end
87
87
  end
88
88
 
89
- def create_tar(out, file_map)
89
+ def create_tar(out, file_map, transform_map)
90
90
  Archive::Tar::Minitar::Writer.open(out) do |tar|
91
91
  options = { :mode=>mode || '0755', :mtime=>Time.now }
92
92
 
93
- file_map.each do |path, content|
94
- if content.respond_to?(:call)
95
- tar.add_file(path, content.respond_to?(:mode) ? options.merge(:mode => content.mode) : options) { |os, _| content.call os }
96
- elsif content.nil?
97
- elsif File.directory?(content.to_s)
98
- stat = File.stat(content.to_s)
93
+ file_map.each do |path, contents|
94
+ to_transform = []
95
+ transform = transform_map.key?(path)
96
+ if contents.nil?
97
+ elsif File.directory?(contents.to_s)
98
+ stat = File.stat(contents.to_s)
99
99
  tar.mkdir(path, options.merge(:mode=>stat.mode, :mtime=>stat.mtime, :uid=>stat.uid, :gid=>stat.gid))
100
100
  else
101
- File.open content.to_s, 'rb' do |is|
102
- tar.add_file path, options.merge(:mode=>is.stat.mode, :mtime=>is.stat.mtime, :uid=>is.stat.uid, :gid=>is.stat.gid) do |os, opts|
103
- while data = is.read(4096)
104
- os.write(data)
101
+ contents = [contents].flatten
102
+
103
+ combined_options = options
104
+ if File.exists?(contents.first.to_s)
105
+ stat = File.stat(contents.first.to_s)
106
+ combined_options = options.merge(:mode=> stat.mode, :mtime=> stat.mtime, :uid=>stat.uid, :gid=> stat.gid)
107
+ elsif contents.first.respond_to?(:mode)
108
+ combined_options = combined_options.merge(:mode => contents.first.mode)
109
+ end
110
+
111
+
112
+ tar.add_file path, combined_options do |os, opts|
113
+ [contents].flatten.each do |content|
114
+ if content.respond_to?(:call)
115
+ if transform
116
+ output = StringIO.new
117
+ content.call output
118
+ to_transform << output.string
119
+ else
120
+ content.call os
121
+ end
122
+ else
123
+ File.open content.to_s, 'rb' do |is|
124
+ if transform
125
+ output = StringIO.new
126
+ while data = is.read(4096)
127
+ output << data
128
+ end
129
+ to_transform << output.string
130
+ else
131
+ while data = is.read(4096)
132
+ os.write(data)
133
+ end
134
+ end
135
+ end
105
136
  end
106
137
  end
138
+ if transform_map.key?(path)
139
+ os.write(transform_map[path].call(to_transform))
140
+ end
107
141
  end
108
142
  end
143
+
109
144
  end
110
145
  end
111
146
  end
@@ -128,7 +163,7 @@ module Buildr #:nodoc:
128
163
  def contain?(*patterns)
129
164
  content = read_content_from_tar
130
165
  patterns.map { |pattern| Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern.to_s)) }.
131
- all? { |pattern| content =~ pattern }
166
+ all? { |pattern| content =~ pattern }
132
167
  end
133
168
 
134
169
  # :call-seq:
@@ -49,9 +49,9 @@ module Buildr #:nodoc:
49
49
  @entries ||= Zip::File.open(name) { |zip| zip.entries }
50
50
  end
51
51
 
52
- private
52
+ private
53
53
 
54
- def create_from(file_map)
54
+ def create_from(file_map, transform_map)
55
55
  Zip::OutputStream.open name do |zip|
56
56
  seen = {}
57
57
  mkpath = lambda do |dir|
@@ -65,24 +65,52 @@ module Buildr #:nodoc:
65
65
 
66
66
  paths = file_map.keys.sort
67
67
  paths.each do |path|
68
- content = file_map[path]
68
+ contents = file_map[path]
69
69
  warn "Warning: Path in zipfile #{name} contains backslash: #{path}" if path =~ /\\/
70
- mkpath.call File.dirname(path)
71
- if content.respond_to?(:call)
72
- entry = zip.put_next_entry(path, compression_level)
73
- entry.unix_perms = content.mode & 07777 if content.respond_to?(:mode)
74
- content.call zip
75
- elsif content.nil? || File.directory?(content.to_s)
76
- mkpath.call path
77
- else
78
- entry = zip.put_next_entry(path, compression_level)
79
- File.open content.to_s, 'rb' do |is|
80
- entry.unix_perms = is.stat.mode & 07777
81
- while data = is.read(4096)
82
- zip << data
70
+
71
+ entry_created = false
72
+ to_transform = []
73
+ transform = transform_map.key?(path)
74
+ [contents].flatten.each do |content|
75
+ if content.respond_to?(:call)
76
+ unless entry_created
77
+ entry = zip.put_next_entry(path, compression_level)
78
+ entry.unix_perms = content.mode & 07777 if content.respond_to?(:mode)
79
+ entry_created = true
80
+ end
81
+ if transform
82
+ output = StringIO.new
83
+ content.call output
84
+ to_transform << output.string
85
+ else
86
+ content.call zip
87
+ end
88
+ elsif content.nil? || File.directory?(content.to_s)
89
+ mkpath.call path
90
+ else
91
+ File.open content.to_s, 'rb' do |is|
92
+ unless entry_created
93
+ entry = zip.put_next_entry(path, compression_level)
94
+ entry.unix_perms = is.stat.mode & 07777
95
+ entry_created = true
96
+ end
97
+ if transform
98
+ output = StringIO.new
99
+ while data = is.read(4096)
100
+ output << data
101
+ end
102
+ to_transform << output.string
103
+ else
104
+ while data = is.read(4096)
105
+ zip << data
106
+ end
107
+ end
83
108
  end
84
109
  end
85
110
  end
111
+ if transform_map.key?(path)
112
+ zip << transform_map[path].call(to_transform)
113
+ end
86
114
  end
87
115
  end
88
116
  end
@@ -304,7 +332,7 @@ module Buildr #:nodoc:
304
332
  if entry.name =~ /^#{@path}/
305
333
  short = entry.name.sub(@path, '')
306
334
  if includes.any? { |pat| File.fnmatch(pat, short) } &&
307
- !excludes.any? { |pat| File.fnmatch(pat, short) }
335
+ !excludes.any? { |pat| File.fnmatch(pat, short) }
308
336
  map[short] = entry
309
337
  end
310
338
  end
@@ -14,5 +14,5 @@
14
14
  # the License.
15
15
 
16
16
  module Buildr #:nodoc:
17
- VERSION = '1.5.3'.freeze
17
+ VERSION = '1.5.4'.freeze
18
18
  end
@@ -55,35 +55,95 @@ package com.biz.bar;
55
55
  public class Bar {}
56
56
  SRC
57
57
 
58
- @foo = define "foo" do
59
- project.version = "2.1.3"
60
- project.group = "mygroup"
61
- manifest["Magic-Food"] = "Chocolate"
62
- manifest["Magic-Drink"] = "Wine"
58
+ @foo = define "foo" do
59
+ project.version = "2.1.3"
60
+ project.group = "mygroup"
61
+ manifest["Magic-Food"] = "Chocolate"
62
+ manifest["Magic-Drink"] = "Wine"
63
+ package(:bundle).tap do |bnd|
64
+ bnd["Export-Package"] = "com.*"
65
+ end
66
+
67
+ define "bar" do
68
+ project.version = "2.2"
63
69
  package(:bundle).tap do |bnd|
70
+ bnd["Magic-Food"] = "Cheese"
64
71
  bnd["Export-Package"] = "com.*"
65
72
  end
73
+ end
74
+ end
75
+ task('package').invoke
76
+ end
66
77
 
67
- define "bar" do
68
- project.version = "2.2"
69
- package(:bundle).tap do |bnd|
70
- bnd["Magic-Food"] = "Cheese"
71
- bnd["Export-Package"] = "com.*"
72
- end
73
- end
78
+ it "version 0.0.384 does not export the version and wrong import-package" do
79
+ open_main_manifest_section do |attribs|
80
+ attribs['Bundle-Name'].should eql('foo')
81
+ attribs['Bundle-Version'].should eql('2.1.3')
82
+ attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
83
+ attribs['Export-Package'].should eql('com.biz')
84
+ attribs['Import-Package'].should eql('com.biz')
85
+ end
86
+ end
87
+ end
88
+
89
+ describe "project.bnd version 2.4.0 (assure forwward compatibility)" do
90
+ after do
91
+ STDERR.puts("forward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}")
92
+ Buildr::Bnd.version = @savedVersion
93
+ end
94
+
95
+ before do
96
+ @savedVersion = Buildr::Bnd.version
97
+ Buildr::Bnd.version = '2.4.0'
98
+ write "src/main/java/com/biz/Foo.java", <<SRC
99
+ package com.biz;
100
+ public class Foo {}
101
+ SRC
102
+
103
+ @foo = define "foo" do
104
+ project.version = "2.1.3"
105
+ project.group = "mygroup"
106
+ package(:bundle).tap do |bnd|
107
+ bnd["Export-Package"] = "com.*"
74
108
  end
75
- task('package').invoke
76
109
  end
110
+ task('package').invoke
111
+ end
77
112
 
78
- it "version 0.0.384 does not export the version and wrong import-package" do
79
- open_main_manifest_section do |attribs|
80
- attribs['Bundle-Name'].should eql('foo')
81
- attribs['Bundle-Version'].should eql('2.1.3')
82
- attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
83
- attribs['Export-Package'].should eql('com.biz')
84
- attribs['Import-Package'].should eql('com.biz')
113
+ it "produces a .bnd and a .jar in the correct location for root project" do
114
+ File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
115
+ File.should be_exist(@foo._("target/foo-2.1.3.jar"))
116
+ end
117
+ end
118
+
119
+ describe "project.bnd version 3.4.0 (assure forward compatibility)" do
120
+ after do
121
+ STDERR.puts("forward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}")
122
+ Buildr::Bnd.version = @savedVersion
123
+ end
124
+
125
+ before do
126
+ @savedVersion = Buildr::Bnd.version
127
+ Buildr::Bnd.version = '3.4.0'
128
+ write "src/main/java/com/biz/Foo.java", <<SRC
129
+ package com.biz;
130
+ public class Foo {}
131
+ SRC
132
+
133
+ @foo = define "foo" do
134
+ project.version = "2.1.3"
135
+ project.group = "mygroup"
136
+ package(:bundle).tap do |bnd|
137
+ bnd["Export-Package"] = "com.*"
85
138
  end
86
139
  end
140
+ task('package').invoke
141
+ end
142
+
143
+ it "produces a .bnd and a .jar in the correct location for root project" do
144
+ File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
145
+ File.should be_exist(@foo._("target/foo-2.1.3.jar"))
146
+ end
87
147
  end
88
148
 
89
149
  describe "package :bundle" do
@@ -0,0 +1,274 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+ # need to test both with and without KOTLIN_HOME
20
+ share_as :KotlincCompiler do
21
+
22
+ it 'should identify itself from source directories' do
23
+ write 'src/main/kotlin/com/example/Test.kt', "package com.example\n class Test { }"
24
+ define('foo').compile.compiler.should eql(:kotlinc)
25
+ end
26
+
27
+ it 'should report the language as :kotlin' do
28
+ define('foo').compile.using(:kotlinc).language.should eql(:kotlin)
29
+ end
30
+
31
+ it 'should set the target directory to target/classes' do
32
+ define 'foo' do
33
+ lambda { compile.using(:kotlinc) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
34
+ end
35
+ end
36
+
37
+ it 'should not override existing target directory' do
38
+ define 'foo' do
39
+ compile.into('classes')
40
+ lambda { compile.using(:kotlinc) }.should_not change { compile.target }
41
+ end
42
+ end
43
+
44
+ it 'should not change existing list of sources' do
45
+ define 'foo' do
46
+ compile.from('sources')
47
+ lambda { compile.using(:kotlinc) }.should_not change { compile.sources }
48
+ end
49
+ end
50
+
51
+ it 'should include as classpath dependency' do
52
+ write 'src/dependency/Dependency.kt', 'class Dependency {}'
53
+ define 'dependency', :version=>'1.0' do
54
+ compile.from('src/dependency').into('target/dependency')
55
+ package(:jar)
56
+ end
57
+ write 'src/test/DependencyTest.kt', "class DependencyTest { val d = Dependency() }"
58
+ lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
59
+ file('target/classes/DependencyTest.class').should exist
60
+ end
61
+
62
+ def define_test1_project
63
+ write 'src/main/kotlin/com/example/Test1.kt', "// file name: Test1.kt\npackage com.example\nclass Test1 {}"
64
+ define 'test1', :version=>'1.0' do
65
+ package(:jar)
66
+ end
67
+ end
68
+
69
+ it 'should compile a simple .kt file into a .class file' do
70
+ define_test1_project
71
+ task('test1:compile').invoke
72
+ file('target/classes/com/example/Test1.class').should exist
73
+ end
74
+
75
+ it 'should package .class into a .jar file' do
76
+ define_test1_project
77
+ task('test1:package').invoke
78
+ file('target/test1-1.0.jar').should exist
79
+ Zip::File.open(project('test1').package(:jar).to_s) do |zip|
80
+ zip.exist?('com/example/Test1.class').should be_true
81
+ end
82
+ end
83
+
84
+ it 'should compile kotlin class depending on java class in same project' do
85
+ write 'src/main/java/com/example/Foo.java', 'package com.example; public class Foo {}'
86
+ write 'src/main/kotlin/com/example/Bar.kt', "package com.example\n class Bar() : Foo() {}"
87
+ define 'test1', :version=>'1.0' do
88
+ package(:jar)
89
+ end
90
+ task('test1:package').invoke
91
+ file('target/test1-1.0.jar').should exist
92
+ Zip::File.open(project('test1').package(:jar).to_s) do |zip|
93
+ zip.exist?('com/example/Foo.class').should be_true
94
+ zip.exist?('com/example/Bar.class').should be_true
95
+ end
96
+ end
97
+
98
+ it 'should compile java class depending on kotlin class in same project' do
99
+ write 'src/main/kotlin/com/example/Foo.kt', 'package com.example; open class Foo'
100
+ write 'src/main/java/com/example/Bar.java', 'package com.example; public class Bar extends Foo {}'
101
+ define 'test1', :version=>'1.0' do
102
+ package(:jar)
103
+ end
104
+ task('test1:package').invoke
105
+ file('target/test1-1.0.jar').should exist
106
+ Zip::File.open(project('test1').package(:jar).to_s) do |zip|
107
+ zip.exist?('com/example/Foo.class').should be_true
108
+ zip.exist?('com/example/Bar.class').should be_true
109
+ end
110
+ end
111
+ end
112
+
113
+ share_as :KotlincCompiler_CommonOptions do
114
+
115
+ it 'should set warnings option to false by default' do
116
+ compile_task.options.warnings.should be_false
117
+ end
118
+
119
+ it 'should set warnings option to true when running with --verbose option' do
120
+ verbose true
121
+ compile_task.options.warnings.should be_true
122
+ end
123
+
124
+ it 'should use -nowarn argument when warnings is false' do
125
+ compile_task.using(:warnings=>false)
126
+ kotlinc_args.suppressWarnings.should be_true
127
+ end
128
+
129
+ it 'should not use -nowarn argument when warnings is true' do
130
+ compile_task.using(:warnings=>true)
131
+ kotlinc_args.suppressWarnings.should be_false
132
+ end
133
+
134
+ it 'should not use -verbose argument by default' do
135
+ oldDebug = Buildr.options.debug
136
+ Buildr.options.debug = false
137
+ begin
138
+ kotlinc_args.verbose.should eql(false)
139
+ ensure
140
+ Buildr.options.debug = oldDebug
141
+ end
142
+ end
143
+
144
+ it 'should use -verbose argument when running with --trace=kotlinc option' do
145
+ Buildr.application.options.trace_categories = [:kotlinc]
146
+ kotlinc_args.verbose.should eql(true)
147
+ end
148
+
149
+ it 'should set debug option to true by default' do
150
+ compile_task.options.debug.should be_true
151
+ end
152
+
153
+ it 'should set debug option to false based on Buildr.options' do
154
+ Buildr.options.debug = false
155
+ compile_task.options.debug.should be_false
156
+ end
157
+
158
+ it 'should set debug option to false based on debug environment variable' do
159
+ ENV['debug'] = 'no'
160
+ compile_task.options.debug.should be_false
161
+ end
162
+
163
+ it 'should set debug option to false based on DEBUG environment variable' do
164
+ ENV['DEBUG'] = 'no'
165
+ compile_task.options.debug.should be_false
166
+ end
167
+
168
+ it 'should set deprecation option to false by default' do
169
+ compile_task.options.deprecation.should be_false
170
+ end
171
+
172
+ it 'should set optimise option to false by default' do
173
+ compile_task.options.optimize.should be_false
174
+ end
175
+
176
+ it 'should use -optimise argument when deprecation is true' do
177
+ compile_task.using(:optimize=>true)
178
+ kotlinc_args.noOptimize.should be_false
179
+ end
180
+
181
+ it 'should not use -optimise argument when deprecation is false' do
182
+ compile_task.using(:optimize=>false)
183
+ kotlinc_args.noOptimize.should be_true
184
+ end
185
+
186
+ it 'should set noStdlib option to true by default' do
187
+ compile_task.options.noStdlib.should be_true
188
+ kotlinc_args.noStdlib.should be_true
189
+ end
190
+
191
+ it 'should not set target option by default' do
192
+ compile_task.options.target.should be_nil
193
+ kotlinc_args.jvmTarget.should be_nil
194
+ end
195
+
196
+ it 'should use -target:xxx argument if target option set' do
197
+ compile_task.using(:target=>'1.5')
198
+ kotlinc_args.jvmTarget.should eql('1.5')
199
+ end
200
+
201
+ it 'should not set other option by default' do
202
+ compile_task.options.other.should be_nil
203
+ end
204
+
205
+ it 'should complain about options it doesn\'t know' do
206
+ write 'source/Test.kt', 'class Test {}'
207
+ compile_task.using(:unknown=>'option')
208
+ lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
209
+ end
210
+
211
+ it 'should inherit options from parent' do
212
+ define 'foo' do
213
+ compile.using(:noStdlib=>false, :warnings=>true, :target=>'1.8')
214
+ define 'bar' do
215
+ compile.using(:kotlinc)
216
+ compile.options.noStdlib.should be_false
217
+ compile.options.warnings.should be_true
218
+ compile.options.target.should eql('1.8')
219
+ end
220
+ end
221
+ end
222
+
223
+ after do
224
+ Buildr.options.debug = nil
225
+ ENV.delete "debug"
226
+ ENV.delete "DEBUG"
227
+ end
228
+ end
229
+
230
+ if Java.java.lang.System.getProperty("java.runtime.version") >= "1.8"
231
+ # Only run this test if the test environment has KOTLIN_HOME specified.
232
+ # Allows the Test Suite to run on TravisCI
233
+ if ENV['KOTLIN_HOME']
234
+ describe 'kotlin compiler (installed in KOTLIN_HOME)' do
235
+ it 'requires present KOTLIN_HOME' do
236
+ ENV['KOTLIN_HOME'].should_not be_nil
237
+ end
238
+
239
+ def compile_task
240
+ @compile_task ||= define('foo').compile.using(:kotlinc)
241
+ end
242
+
243
+ it_should_behave_like KotlincCompiler
244
+ it_should_behave_like KotlincCompiler_CommonOptions
245
+ end
246
+ end
247
+
248
+ describe 'kotlin compiler (downloaded from repository)' do
249
+ old_home = ENV['KOTLIN_HOME']
250
+
251
+ before :all do
252
+ ENV['KOTLIN_HOME'] = nil
253
+ end
254
+
255
+ it 'requires absent KOTLIN_HOME' do
256
+ ENV['KOTLIN_HOME'].should be_nil
257
+ end
258
+
259
+ def compile_task
260
+ @compile_task ||= define('foo').compile.using(:kotlinc)
261
+ end
262
+
263
+ def kotlinc_args
264
+ compile_task.instance_eval { @compiler }.send(:kotlinc_args)
265
+ end
266
+
267
+ it_should_behave_like KotlincCompiler
268
+ it_should_behave_like KotlincCompiler_CommonOptions
269
+
270
+ after :all do
271
+ ENV['KOTLIN_HOME'] = old_home
272
+ end
273
+ end
274
+ end