Author: donaldp
Date: Tue Apr 30 10:16:08 2013
New Revision: 1477531
URL: http://svn.apache.org/r1477531
Log:
BUILDR-648 Add new package(:test_jar) packaging type. Submitted by Mike
Pettypiece.
Added:
buildr/trunk/lib/buildr/packaging/test_jar.rb
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/lib/buildr.rb
buildr/trunk/spec/java/packaging_spec.rb
Modified: buildr/trunk/CHANGELOG
URL:
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1477531&r1=1477530&r2=1477531&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Tue Apr 30 10:16:08 2013
@@ -1,4 +1,6 @@
1.4.12 (Pending)
+* Added: BUILDR-648 Add new package(:test_jar) packaging type.
+ Submitted by Mike Pettypiece.
* Fixed: BUILDR-666 ZipFile.open modifies file regardless of usage.
Reported by Pepijn Van Eeckhoudt, fix by Alex Boisvert.
* Change: Moved to using TravisCI to test the Linux variants.
Modified: buildr/trunk/lib/buildr.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr.rb?rev=1477531&r1=1477530&r2=1477531&view=diff
==============================================================================
--- buildr/trunk/lib/buildr.rb (original)
+++ buildr/trunk/lib/buildr.rb Tue Apr 30 10:16:08 2013
@@ -69,6 +69,7 @@ require 'buildr/packaging/ziptask'
require 'buildr/packaging/tar'
require 'buildr/packaging/gems'
require 'buildr/packaging/zip'
+require 'buildr/packaging/test_jar'
require RUBY_PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
require 'buildr/java/ant'
require 'buildr/java/compiler'
Added: buildr/trunk/lib/buildr/packaging/test_jar.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/test_jar.rb?rev=1477531&view=auto
==============================================================================
--- buildr/trunk/lib/buildr/packaging/test_jar.rb (added)
+++ buildr/trunk/lib/buildr/packaging/test_jar.rb Tue Apr 30 10:16:08 2013
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+module Buildr #:nodoc:
+ module PackageAsTestJar
+ def package_as_test_jar_spec(spec) #:nodoc:
+ spec.merge(:type => :jar, :classifier => 'test-jar')
+ end
+
+ def package_as_test_jar(file_name) #:nodoc:
+ ZipTask.define_task(file_name).tap do |zip|
+ zip.include :from => [test.compile.target,
test.resources.target].compact
+ end
+ end
+ end
+end
+
+class Buildr::Project
+ include Buildr::PackageAsTestJar
+end
Modified: buildr/trunk/spec/java/packaging_spec.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/spec/java/packaging_spec.rb?rev=1477531&r1=1477530&r2=1477531&view=diff
==============================================================================
--- buildr/trunk/spec/java/packaging_spec.rb (original)
+++ buildr/trunk/spec/java/packaging_spec.rb Tue Apr 30 10:16:08 2013
@@ -1204,6 +1204,41 @@ describe Packaging, 'javadoc' do
end
end
+describe Packaging, 'test_jar' do
+ it_should_behave_like 'packaging'
+ before { @packaging, @package_type = :test_jar, :jar }
+
+ it 'should create package of type :jar and classifier \'test-jar\'' do
+ define 'foo', :version=>'1.0' do
+ package(:test_jar).type.should eql(:jar)
+ package(:test_jar).classifier.should eql('test-jar')
+ package(:test_jar).name.should match(/foo-1.0-test-jar.jar$/)
+ end
+ end
+
+ it 'should contain test source and resource files' do
+ write 'src/test/java/Test.java', 'public class Test {}'
+ write 'src/test/resources/test.properties', 'foo=bar'
+ define('foo', :version=>'1.0') { package(:test_jar) }
+ project('foo').task('package').invoke
+ project('foo').packages.first.should contain('Test.class')
+ project('foo').packages.first.should contain('test.properties')
+ end
+
+ it 'should create test jar if resources exists (but not sources)' do
+ write 'src/test/resources/test.properties', 'foo=bar'
+ define('foo', :version=>'1.0') { package(:test_jar) }
+ project('foo').package(:test_jar).invoke
+ project('foo').packages.first.should contain('test.properties')
+ end
+
+ it 'should be a ZipTask' do
+ define 'foo', :version=>'1.0' do
+ package(:test_jar).should be_kind_of(ZipTask)
+ end
+ end
+end
+
shared_examples_for 'package_with_' do
def prepare(options = {})