buildr 1.4.1-x86-mswin32 → 1.4.2-x86-mswin32

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 (97) hide show
  1. data/CHANGELOG +68 -11
  2. data/_buildr +2 -0
  3. data/addon/buildr/hibernate.rb +8 -5
  4. data/addon/buildr/jetty.rb +1 -1
  5. data/addon/buildr/openjpa.rb +0 -2
  6. data/addon/buildr/xmlbeans.rb +1 -1
  7. data/buildr.gemspec +13 -9
  8. data/doc/_layouts/default.html +3 -1
  9. data/doc/contributing.textile +10 -2
  10. data/doc/css/default.css +6 -6
  11. data/doc/download.textile +7 -7
  12. data/doc/languages.textile +2 -2
  13. data/doc/more_stuff.textile +41 -33
  14. data/doc/packaging.textile +6 -3
  15. data/doc/releasing.textile +116 -0
  16. data/doc/scripts/install-linux.sh +7 -6
  17. data/doc/testing.textile +14 -0
  18. data/lib/buildr.rb +2 -2
  19. data/lib/buildr/core.rb +0 -6
  20. data/lib/buildr/core/application.rb +25 -2
  21. data/lib/buildr/core/build.rb +66 -15
  22. data/lib/buildr/core/compile.rb +10 -1
  23. data/lib/buildr/core/filter.rb +1 -1
  24. data/lib/buildr/core/progressbar.rb +8 -3
  25. data/lib/buildr/core/test.rb +57 -6
  26. data/lib/buildr/core/transports.rb +18 -13
  27. data/lib/buildr/core/util.rb +19 -3
  28. data/lib/buildr/groovy/compiler.rb +2 -2
  29. data/lib/buildr/ide/eclipse.rb +32 -12
  30. data/lib/buildr/java/ant.rb +3 -3
  31. data/lib/buildr/java/bdd.rb +1 -2
  32. data/lib/buildr/java/cobertura.rb +10 -9
  33. data/lib/buildr/java/commands.rb +22 -21
  34. data/lib/buildr/java/compiler.rb +2 -2
  35. data/lib/buildr/java/doc.rb +1 -1
  36. data/lib/buildr/java/ecj.rb +71 -0
  37. data/lib/buildr/java/emma.rb +1 -1
  38. data/lib/buildr/java/external.rb +9 -9
  39. data/lib/buildr/java/jruby.rb +5 -0
  40. data/lib/buildr/java/packaging.rb +4 -3
  41. data/lib/buildr/java/rjb.rb +4 -6
  42. data/lib/buildr/java/tests.rb +9 -4
  43. data/lib/buildr/packaging/archive.rb +7 -3
  44. data/lib/buildr/packaging/artifact.rb +153 -38
  45. data/lib/buildr/packaging/gems.rb +2 -3
  46. data/lib/buildr/packaging/package.rb +19 -12
  47. data/lib/buildr/packaging/tar.rb +1 -1
  48. data/lib/buildr/packaging/ziptask.rb +1 -1
  49. data/lib/buildr/scala/bdd.rb +7 -3
  50. data/lib/buildr/scala/compiler.rb +2 -2
  51. data/lib/buildr/scala/doc.rb +3 -3
  52. data/lib/buildr/scala/tests.rb +7 -3
  53. data/lib/buildr/version.rb +18 -0
  54. data/rakelib/all-in-one.rake +1 -1
  55. data/rakelib/doc.rake +13 -3
  56. data/rakelib/metrics.rake +39 -0
  57. data/spec/core/application_spec.rb +13 -12
  58. data/spec/core/build_spec.rb +166 -7
  59. data/spec/core/cc_spec.rb +1 -1
  60. data/spec/core/checks_spec.rb +1 -1
  61. data/spec/core/common_spec.rb +10 -1
  62. data/spec/core/compile_spec.rb +1 -1
  63. data/spec/core/extension_spec.rb +1 -1
  64. data/spec/core/generate_spec.rb +1 -1
  65. data/spec/core/project_spec.rb +1 -1
  66. data/spec/core/test_spec.rb +124 -11
  67. data/spec/core/transport_spec.rb +10 -3
  68. data/spec/core/util_spec.rb +18 -2
  69. data/spec/groovy/bdd_spec.rb +1 -1
  70. data/spec/groovy/compiler_spec.rb +3 -3
  71. data/spec/ide/eclipse_spec.rb +63 -1
  72. data/spec/ide/idea7x_spec.rb +1 -1
  73. data/spec/java/ant_spec.rb +1 -1
  74. data/spec/java/bdd_spec.rb +1 -1
  75. data/spec/java/cobertura_spec.rb +29 -2
  76. data/spec/java/commands_spec.rb +61 -2
  77. data/spec/java/compiler_spec.rb +3 -3
  78. data/spec/java/ecj_spec.rb +115 -0
  79. data/spec/java/emma_spec.rb +1 -1
  80. data/spec/java/external_spec.rb +10 -8
  81. data/spec/java/java_spec.rb +14 -6
  82. data/spec/java/packaging_spec.rb +41 -15
  83. data/spec/java/test_coverage_helper.rb +1 -1
  84. data/spec/java/tests_spec.rb +1 -1
  85. data/spec/packaging/archive_spec.rb +12 -1
  86. data/spec/packaging/artifact_namespace_spec.rb +1 -1
  87. data/spec/packaging/artifact_spec.rb +197 -7
  88. data/spec/packaging/packaging_spec.rb +12 -12
  89. data/spec/sandbox.rb +8 -3
  90. data/spec/scala/bdd_spec.rb +3 -3
  91. data/spec/scala/compiler_spec.rb +7 -7
  92. data/spec/scala/scala.rb +3 -3
  93. data/spec/scala/tests_spec.rb +3 -3
  94. data/spec/spec_helpers.rb +11 -1
  95. data/spec/version_requirement_spec.rb +1 -1
  96. metadata +220 -85
  97. data/rakelib/jekylltask.rb +0 -120
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
18
 
19
19
 
20
20
  module Idea7xHelper
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
18
 
19
19
 
20
20
  describe Buildr::Ant do
@@ -13,7 +13,7 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require File.join(File.dirname(__FILE__), '../spec_helpers')
16
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
17
17
 
18
18
  describe Buildr::RSpec do
19
19
 
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), 'test_coverage_helper')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test_coverage_helper'))
18
18
  Sandbox.require_optional_extension 'buildr/java/cobertura'
19
19
  artifacts(Buildr::Cobertura::dependencies).map(&:invoke)
20
20
 
@@ -53,6 +53,11 @@ describe Buildr::Cobertura do
53
53
  define('foo') { define('bar') }
54
54
  task('foo:bar:cobertura:instrument').invoke
55
55
  end
56
+
57
+ it 'should not generate html if projects have no sources' do
58
+ define('foo') { define('bar') }
59
+ task('cobertura:html').invoke
60
+ end
56
61
  end
57
62
 
58
63
  describe 'instrumentation' do
@@ -80,6 +85,28 @@ describe Buildr::Cobertura do
80
85
  end
81
86
  end
82
87
 
83
- # TODO add specs for cobertura:check...somehow
88
+ describe 'check' do
89
+ before do
90
+ write 'src/main/java/Foo.java', 'public class Foo { public static boolean returnTrue() {return true;}}'
91
+ write 'src/test/java/FooTest.java', <<-JAVA
92
+ import static junit.framework.Assert.assertTrue;
93
+ import org.junit.Test;
94
+
95
+ public class FooTest {
96
+
97
+ @Test
98
+ public void testReturnTrue() {
99
+ assertTrue(Foo.returnTrue());
100
+ }
101
+ }
102
+ JAVA
103
+ end
104
+
105
+ it 'should not raise errors during execution' do
106
+ define('foo') { cobertura.include 'Foo' }
107
+ lambda {task("foo:cobertura:check").invoke}.should_not raise_error
108
+ end
109
+
110
+ end
84
111
  end
85
112
  end
@@ -13,7 +13,7 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require File.join(File.dirname(__FILE__), '../spec_helpers')
16
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
17
17
 
18
18
 
19
19
  describe Java::Commands do
@@ -30,5 +30,64 @@ BUILD
30
30
  lambda { Java::Commands.java("org.apache.tools.ant.Main", :classpath => Buildr::Ant.dependencies) }.should_not show_info(/java/)
31
31
  lambda { Java::Commands.java("org.apache.tools.ant.Main", :classpath => Buildr::Ant.dependencies, :verbose => true) }.should show_info(/java/)
32
32
  end
33
-
33
+
34
+ describe "Java::Commands.javac" do
35
+
36
+ it "should compile java" do
37
+ write "Foo.java", "public class Foo {}"
38
+ lambda { Java::Commands.javac("Foo.java") }.should change {File.exist?("Foo.class")}.to(true)
39
+ end
40
+
41
+ it 'should let the user specify an output directory' do
42
+ write "Foo.java", "public class Foo {}"
43
+ lambda { Java::Commands.javac("Foo.java", :output => "classes") }.should change {File.exist?("classes/Foo.class")}.to(true)
44
+ end
45
+
46
+ it "should let the user specify a different name" do
47
+ write "Foo.java", "public class Foo {}"
48
+ lambda { Java::Commands.javac("Foo.java", :name => "bar") }.should show_info("Compiling 1 source files in bar")
49
+ end
50
+
51
+ it "should let the user specify a source path" do
52
+ write "ext/org/Bar.java", "package org; public class Bar {}"
53
+ write "Foo.java", "import org.Bar;\n public class Foo {}"
54
+ lambda { Java::Commands.javac("Foo.java", :sourcepath => File.expand_path("ext")) }.should change {File.exist?("Foo.class")}.to(true)
55
+ end
56
+
57
+ it "should let the user specify a classpath" do
58
+ write "ext/org/Bar.java", "package org; public class Bar {}"
59
+ Java::Commands.javac("ext/org/Bar.java", :output => "lib")
60
+ write "Foo.java", "import org.Bar;\n public class Foo {}"
61
+ lambda { Java::Commands.javac("Foo.java", :classpath => File.expand_path("lib")) }.should change {File.exist?("Foo.class")}.to(true)
62
+ end
63
+ end
64
+
65
+ describe "Java::Commands.javadoc" do
66
+
67
+ it "should fail if no output is defined" do
68
+ lambda { Java::Commands.javadoc("Foo.java") }.should raise_error(/No output defined for javadoc/)
69
+ end
70
+
71
+ it "should create javadoc" do
72
+ write "Foo.java", "public class Foo {}"
73
+ lambda { Java::Commands.javadoc("Foo.java", :output => "doc") }.should change {File.exist?("doc/Foo.html")}.to(true)
74
+ end
75
+
76
+ it "should accept file tasks as arguments" do
77
+ foo = file("Foo.java") do |file|
78
+ file.enhance do
79
+ write file.to_s, "public class Foo {}"
80
+ end
81
+ end
82
+ lambda { Java::Commands.javadoc(foo, :output => "doc") }.should change {File.exist?("doc/Foo.html")}.to(true)
83
+ end
84
+
85
+ it "should accept projects as arguments" do
86
+ write "src/main/java/Foo.java", "public class Foo {}"
87
+ write "src/main/java/bar/Foobar.java", "package bar; public class Foobar {}"
88
+ define "foo" do
89
+ end
90
+ lambda { Java::Commands.javadoc(project("foo"), :output => "doc") }.should change {File.exist?("doc/Foo.html") && File.exist?("doc/bar/Foobar.html")}.to(true)
91
+ end
92
+ end
34
93
  end
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
18
 
19
19
 
20
20
  describe 'javac compiler' do
@@ -122,8 +122,8 @@ describe 'javac compiler options' do
122
122
  javac_args.should_not include('-verbose')
123
123
  end
124
124
 
125
- it 'should use -verbose argument when running with --trace option' do
126
- trace true
125
+ it 'should use -verbose argument when running with --trace=javac option' do
126
+ Buildr.application.options.trace_categories = [:javac]
127
127
  javac_args.should include('-verbose')
128
128
  end
129
129
 
@@ -0,0 +1,115 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
17
+
18
+
19
+
20
+ describe Buildr::Compiler::Ecj do
21
+
22
+ before(:all) do
23
+ #Make ecj appear as a compiler that applies:
24
+ class Buildr::Compiler::Ecj
25
+ class << self
26
+
27
+ def applies_to?(project, task)
28
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
29
+ paths.flatten!
30
+ ext_glob = Array(source_ext).join(',')
31
+
32
+ paths.each { |path|
33
+ Find.find(path) {|found|
34
+ if (!File.directory?(found)) && found.match(/.*\.#{Array(source_ext).join('|')}/)
35
+ return true
36
+ end
37
+ } if File.exist? path
38
+ }
39
+ false
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ it "should be the default Java compiler once loaded" do
46
+ write 'src/main/java/Foo.java', 'public class Foo {}'
47
+ foo = define('foo')
48
+ foo.compile.compiler.should == :ecj
49
+ end
50
+
51
+ describe "should compile a Java project just in the same way javac does" do
52
+ javac_spec = File.read(File.join(File.dirname(__FILE__), "compiler_spec.rb"))
53
+ javac_spec = javac_spec.match(Regexp.escape("require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))\n")).post_match
54
+ javac_spec.gsub!("javac", "ecj")
55
+ javac_spec.gsub!("nowarn", "warn:none")
56
+ eval(javac_spec)
57
+ end
58
+
59
+ # Redirect the java error ouput, yielding so you can do something while it is
60
+ # and returning the content of the error buffer.
61
+ #
62
+ def redirect_java_err
63
+ pending "RJB doesn't support well instantiating a class that has several constructors" unless RUBY_PLATFORM =~ /java/
64
+ err = Java.java.io.ByteArrayOutputStream.new
65
+ original_err = Java.java.lang.System.err
66
+ begin
67
+ printStream = Java.java.io.PrintStream
68
+ print = printStream.new(err)
69
+ Java.java.lang.System.setErr(print)
70
+ yield
71
+ ensure
72
+ Java.java.lang.System.setErr(original_err)
73
+ end
74
+ err.toString
75
+ end
76
+
77
+ it "should not issue warnings for type casting when warnings are set to warn:none, by default" do
78
+ write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
79
+ foo = define("foo") {
80
+ compile.options.source = "1.5"
81
+ compile.options.target = "1.5"
82
+ }
83
+ redirect_java_err { foo.compile.invoke }.should_not match(/WARNING/)
84
+ end
85
+
86
+ it "should issue warnings for type casting when warnings are set" do
87
+ write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
88
+ foo = define("foo") {
89
+ compile.options.source = "1.5"
90
+ compile.options.target = "1.5"
91
+ compile.options.warnings = true
92
+ }
93
+ redirect_java_err { foo.compile.invoke }.should match(/WARNING/)
94
+ end
95
+
96
+ after(:all) do
97
+ #Make ecj appear as a compiler that doesn't apply:
98
+ module Buildr
99
+ module Compiler
100
+
101
+ class Ecj
102
+
103
+ class << self
104
+
105
+ def applies_to?(project, task)
106
+ false
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), 'test_coverage_helper')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test_coverage_helper'))
18
18
  Sandbox.require_optional_extension 'buildr/java/emma'
19
19
  artifacts(Buildr::Emma::dependencies).map(&:invoke)
20
20
 
@@ -14,25 +14,27 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
18
 
19
19
  COMPILERS = Buildr::Compiler.compilers.dup
20
20
  COMPILERS_WITHOUT_JAVAC = COMPILERS.dup
21
21
  COMPILERS_WITHOUT_JAVAC.delete Buildr::Compiler::Javac
22
22
 
23
23
  describe Buildr::Compiler::ExternalJavac do
24
-
24
+
25
25
  before(:all) do
26
26
  Buildr::Compiler.send :compilers=, COMPILERS_WITHOUT_JAVAC
27
27
  end
28
-
29
- describe "should compile a Java project just in the same way javac does" do
28
+
29
+ describe "should compile a Java project just in the same way javac does" do
30
30
  javac_spec = File.read(File.join(File.dirname(__FILE__), "compiler_spec.rb"))
31
- javac_spec = javac_spec.match(Regexp.escape("require File.join(File.dirname(__FILE__), '../spec_helpers')\n")).post_match
31
+ javac_spec = javac_spec.match(Regexp.escape("require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))\n")).post_match
32
32
  javac_spec.gsub!("javac", "externaljavac")
33
+ javac_spec.gsub!("--trace=externaljavac", "--trace=javac")
34
+ javac_spec.gsub!("trace_categories = [:externaljavac]", "trace_categories = [:javac]")
33
35
  eval(javac_spec)
34
36
  end
35
-
37
+
36
38
  it "should accept a :jvm option as JAVA_HOME" do
37
39
  write 'src/main/java/Foo.java', 'public class Foo {}'
38
40
  define "foo" do
@@ -44,11 +46,11 @@ describe Buildr::Compiler::ExternalJavac do
44
46
  end
45
47
  trace false
46
48
  end
47
-
49
+
48
50
  after :all do
49
51
  Buildr::Compiler.send :compilers=, COMPILERS
50
52
  end
51
-
53
+
52
54
  end
53
55
 
54
56
 
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
18
 
19
19
 
20
20
  unless RUBY_PLATFORM =~ /java/
@@ -41,10 +41,18 @@ unless RUBY_PLATFORM =~ /java/
41
41
  ENV_JAVA.replace @old_env_java
42
42
  end
43
43
  end
44
+ else
45
+ describe 'JRuby environment' do
46
+ it 'should enforce a minimum version of jruby' do
47
+ check =File.read(File.expand_path('../lib/buildr/java/jruby.rb')).match(/JRUBY_MIN_VERSION.*\n.*JRUBY_MIN_VERSION\n/).to_s
48
+ check.sub!('JRUBY_VERSION', "'0.0.0'")
49
+ lambda { eval(check) }.should raise_error(/JRuby must be at least at version /)
50
+ end
51
+ end
44
52
  end
45
53
 
46
54
 
47
- describe Java, '#tools_jar' do
55
+ describe 'Java.tools_jar' do
48
56
  before do
49
57
  @old_home = ENV['JAVA_HOME']
50
58
  end
@@ -55,7 +63,7 @@ describe Java, '#tools_jar' do
55
63
  write 'jdk/lib/tools.jar'
56
64
  ENV['JAVA_HOME'] = File.expand_path('jdk')
57
65
  end
58
-
66
+
59
67
  it 'should return the path to tools.jar' do
60
68
  Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
61
69
  end
@@ -67,7 +75,7 @@ describe Java, '#tools_jar' do
67
75
  write 'jdk/lib/tools.jar'
68
76
  ENV['JAVA_HOME'] = File.expand_path('jdk/jre')
69
77
  end
70
-
78
+
71
79
  it 'should return the path to tools.jar' do
72
80
  Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
73
81
  end
@@ -78,7 +86,7 @@ describe Java, '#tools_jar' do
78
86
  Java.instance_eval { @tools_jar = nil }
79
87
  ENV['JAVA_HOME'] = File.expand_path('jdk')
80
88
  end
81
-
89
+
82
90
  it 'should return nil' do
83
91
  Java.tools_jar.should be_nil
84
92
  end
@@ -89,7 +97,7 @@ describe Java, '#tools_jar' do
89
97
  end
90
98
  end
91
99
 
92
- describe Java, '#java' do
100
+ describe 'Java#java' do
93
101
  before do
94
102
  @old_home = ENV['JAVA_HOME']
95
103
  end
@@ -14,8 +14,8 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
18
- require File.join(File.dirname(__FILE__), '../packaging/packaging_helper')
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'packaging', 'packaging_helper'))
19
19
 
20
20
 
21
21
  describe Project, '#manifest' do
@@ -120,7 +120,7 @@ shared_examples_for 'package with manifest' do
120
120
  manifest.main['bar'].should eql('Bar')
121
121
  end
122
122
  end
123
-
123
+
124
124
  it 'should close the temporary file used for packaging the MANIFEST.MF file' do
125
125
  package_with_manifest 'Foo'=>1, :bar=>'Bar'
126
126
  package = project('foo').package(@packaging)
@@ -197,7 +197,7 @@ shared_examples_for 'package with manifest' do
197
197
  manifest.main['Meta'].should eql('data')
198
198
  end
199
199
  end
200
-
200
+
201
201
  it 'should give 644 permissions to the manifest' do
202
202
  package_with_manifest [ {}, { 'Name'=>'first', :Foo=>'first', :bar=>'second' } ]
203
203
  package ||= project('foo').package(@packaging)
@@ -440,7 +440,7 @@ describe Packaging, 'jar' do
440
440
  (entries_to_s.first == 'META-INF/MANIFEST.MF' || entries_to_s[1] == 'META-INF/MANIFEST.MF').should be_true
441
441
  end
442
442
  end
443
-
443
+
444
444
  it 'should use files from compile directory if nothing included' do
445
445
  write 'src/main/java/Test.java', 'class Test {}'
446
446
  define('foo', :version=>'1.0') { package(:jar) }
@@ -491,7 +491,7 @@ describe Packaging, 'jar' do
491
491
  define('foo', :version=>'1.0') { package(:jar).with(nil) }
492
492
  }.should raise_error
493
493
  end
494
-
494
+
495
495
  it 'should exclude resources when ordered to do so' do
496
496
  write 'src/main/resources/foo.xml', ''
497
497
  foo = define('foo', :version => '1.0') { package(:jar).exclude('foo.xml')}
@@ -500,7 +500,7 @@ describe Packaging, 'jar' do
500
500
  jar.entries.map(&:to_s).sort.should_not include('foo.xml')
501
501
  end
502
502
  end
503
-
503
+
504
504
  end
505
505
 
506
506
 
@@ -583,20 +583,44 @@ describe Packaging, 'war' do
583
583
  define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war) }
584
584
  inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar', 'WEB-INF/lib/id-2.0.jar') }
585
585
  end
586
-
586
+
587
587
  it 'should use artifacts from compile classpath if no libs specified, leaving the user specify which to exclude as files' do
588
588
  make_jars
589
589
  define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war).path('WEB-INF/lib').exclude('id-2.0.jar') }
590
590
  inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
591
591
  end
592
-
592
+
593
593
  it 'should use artifacts from compile classpath if no libs specified, leaving the user specify which to exclude as files with glob expressions' do
594
594
  make_jars
595
595
  define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war).path('WEB-INF/lib').exclude('**/id-2.0.jar') }
596
596
  inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
597
597
  end
598
+
599
+ it 'should exclude files regardless of the path where they are included, using wildcards' do
600
+ make_jars
601
+ define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war).exclude('**/id-2.0.jar') }
602
+ inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
603
+ end
598
604
 
605
+ it 'should exclude files regardless of the path where they are included, specifying target path entirely' do
606
+ make_jars
607
+ define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war).exclude('WEB-INF/lib/id-2.0.jar') }
608
+ inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
609
+ end
599
610
 
611
+ it 'should exclude files regardless of the path where they are included for war files' do
612
+ write 'src/main/java/com/example/included/Test.java', 'package com.example.included; class Test {}'
613
+ write 'src/main/java/com/example/excluded/Test.java', 'package com.example.excluded; class Test {}'
614
+ define('foo', :version=>'1.0') do
615
+ package(:war).enhance do |war|
616
+ war.exclude('WEB-INF/classes/com/example/excluded/**.class')
617
+ end
618
+ end
619
+ inspect_war do |files|
620
+ files.should include('WEB-INF/classes/com/example/included/Test.class')
621
+ files.should_not include('WEB-INF/classes/com/example/excluded/Test.class')
622
+ end
623
+ end
600
624
 
601
625
  it 'should include only specified libraries' do
602
626
  define 'foo', :version=>'1.0' do
@@ -1072,13 +1096,13 @@ end
1072
1096
 
1073
1097
  describe Packaging, 'sources' do
1074
1098
  it_should_behave_like 'packaging'
1075
- before { @packaging, @package_type = :sources, :zip }
1099
+ before { @packaging, @package_type = :sources, :jar }
1076
1100
 
1077
- it 'should create package of type :zip and classifier \'sources\'' do
1101
+ it 'should create package of type :jar and classifier \'sources\'' do
1078
1102
  define 'foo', :version=>'1.0' do
1079
- package(:sources).type.should eql(:zip)
1103
+ package(:sources).type.should eql(:jar)
1080
1104
  package(:sources).classifier.should eql('sources')
1081
- package(:sources).name.should match(/foo-1.0-sources.zip$/)
1105
+ package(:sources).name.should match(/foo-1.0-sources.jar$/)
1082
1106
  end
1083
1107
  end
1084
1108
 
@@ -1148,9 +1172,11 @@ shared_examples_for 'package_with_' do
1148
1172
  projects.select { |project| project.packages.first }.map(&:name)
1149
1173
  end
1150
1174
 
1151
- it 'should create package of type zip with classifier' do
1175
+ it 'should create package of the right packaging with classifier' do
1152
1176
  prepare
1153
- project('foo').packages.first.to_s.should =~ /foo-1.0-#{@packaging}.zip/
1177
+ ext = "zip"
1178
+ ext = "jar" if @packaging == :sources
1179
+ project('foo').packages.first.to_s.should =~ /foo-1.0-#{@packaging}.#{ext}/
1154
1180
  end
1155
1181
 
1156
1182
  it 'should create package for projects that have source files' do