Donald,
I'm puzzled by the line "cp project('foo').package(:war).to_s,
'/tmp/x.zip'". What is the purpose of the x.zip file? Just curious.
Cheers
Lacton
On Wed, Oct 23, 2013 at 1:50 AM, <[email protected]> wrote:
> Author: donaldp
> Date: Tue Oct 22 23:50:23 2013
> New Revision: 1534859
>
> URL: http://svn.apache.org/r1534859
> Log:
> BUILDR-689 - Ensure that war file includes generated assets rather than
> the "source" assets that may have been filtered.
>
> Modified:
> buildr/trunk/CHANGELOG
> buildr/trunk/lib/buildr/java/packaging.rb
> buildr/trunk/spec/java/packaging_spec.rb
>
> Modified: buildr/trunk/CHANGELOG
> URL:
> http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1534859&r1=1534858&r2=1534859&view=diff
>
> ==============================================================================
> --- buildr/trunk/CHANGELOG (original)
> +++ buildr/trunk/CHANGELOG Tue Oct 22 23:50:23 2013
> @@ -1,4 +1,7 @@
> 1.4.15 (Pending)
> +* Fixed: BUILDR-689 - Ensure that war file includes generated
> + assets rather than the "source" assets that may have
> + been filtered.
> * Fixed: BUILDR-689 - Define assets task before the project is
> defined to avoid "undefined method `project='" if the
> project attempts to generate into the same directory.
>
> Modified: buildr/trunk/lib/buildr/java/packaging.rb
> URL:
> http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/packaging.rb?rev=1534859&r1=1534858&r2=1534859&view=diff
>
> ==============================================================================
> --- buildr/trunk/lib/buildr/java/packaging.rb (original)
> +++ buildr/trunk/lib/buildr/java/packaging.rb Tue Oct 22 23:50:23 2013
> @@ -684,12 +684,9 @@ module Buildr #:nodoc:
> # Add libraries in WEB-INF lib, and classes in WEB-INF classes
> war.with :classes=>[compile.target, resources.target].compact
> war.with :libs=>compile.dependencies
> - # Add included files, or the webapp directory.
> - assets.paths.each do |asset|
> - war.tap do |war|
> - war.enhance([asset])
> - end
> - war.include asset, :as => '.'
> + war.enhance([assets])
> + if !assets.paths.empty? || File.exist?(_(:source, :main,
> :webapp))
> + war.include assets.to_s, :as => '.'
> end
> end
> end
>
> Modified: buildr/trunk/spec/java/packaging_spec.rb
> URL:
> http://svn.apache.org/viewvc/buildr/trunk/spec/java/packaging_spec.rb?rev=1534859&r1=1534858&r2=1534859&view=diff
>
> ==============================================================================
> --- buildr/trunk/spec/java/packaging_spec.rb (original)
> +++ buildr/trunk/spec/java/packaging_spec.rb Tue Oct 22 23:50:23 2013
> @@ -550,6 +550,23 @@ describe Packaging, 'war' do
> inspect_war { |files| files.should include('test.html') }
> end
>
> + it 'should allow filtering into target directory' do
> + write 'src/main/webapp/test.html', '${version}'
> + define('foo', :version => '1.0') do
> + target_webapp = file("target/webapp") do |task|
> + filter('src/main/webapp/').
> + into(task.to_s).using('version' => '999').
> + run
> + end
> + package(:war)
> + end
> + inspect_war { |files| files.should include('test.html') }
> + cp project('foo').package(:war).to_s, '/tmp/x.zip'
> + Zip::ZipFile.open(project('foo').package(:war).to_s, false) do |war|
> + war.get_input_stream('test.html').read.should eql('999')
> + end
> + end
> +
> it 'should accept files from :classes option' do
> write 'src/main/java/Test.java', 'class Test {}'
> write 'classes/test'
>
>