Author: boisvert
Date: Wed Dec 1 21:29:09 2010
New Revision: 1041177
URL: http://svn.apache.org/viewvc?rev=1041177&view=rev
Log:
BUILDR-125 Add support for <security-role> in application.xml of EAR packaging
(Mikael Amborn)
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/doc/packaging.textile
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=1041177&r1=1041176&r2=1041177&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Dec 1 21:29:09 2010
@@ -1,4 +1,6 @@
1.4.5 (Pending)
+* Added: BUILDR-125 Add support for <security-role> in application.xml of
+ EAR packaging (Mikael Amborn)
* Added: BUILDR-550 Add support for groovydoc
* Added: BUILDR-521: System tray notifications for Linux systems
(via libnotify/notify-send)
Modified: buildr/trunk/doc/packaging.textile
URL:
http://svn.apache.org/viewvc/buildr/trunk/doc/packaging.textile?rev=1041177&r1=1041176&r2=1041177&view=diff
==============================================================================
--- buildr/trunk/doc/packaging.textile (original)
+++ buildr/trunk/doc/packaging.textile Wed Dec 1 21:29:09 2010
@@ -328,6 +328,15 @@ package(:ear).add project('coolWebServic
If you need to disable the context root (e.g. for Portlets), set
@context_root@ to @fa...@.
+It is also possible to add @security-role@ tags to the @application.xml@ file
by appending a hash with @:id@, @:description@ and @:name@ to the
@security_role@ array, like so:
+
+{% highlight ruby %}
+package(:ear).security_roles << {:id=>'SecurityRole_123',
+ :description=>'Read only user', :name=>'coolUser'}
+package(:ear).security_roles << {:id=>'SecurityRole_456',
+ :description=>'Super user', :name=>'superCoolUser'}
+{% endhighlight %}
+
h2(#tar). Packaging Tars and GZipped Tars
Modified: buildr/trunk/lib/buildr/java/packaging.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/packaging.rb?rev=1041177&r1=1041176&r2=1041177&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/packaging.rb (original)
+++ buildr/trunk/lib/buildr/java/packaging.rb Wed Dec 1 21:29:09 2010
@@ -395,11 +395,13 @@ module Buildr
attr_accessor :description
# Map from component type to path inside the EAR.
attr_accessor :dirs
+ # Security roles entry for application.xml
+ attr_accessor :security_roles
def initialize(*args)
super
@dirs = Hash.new { |h, k| k.to_s }
- @libs, @components = [], []
+ @libs, @components, @security_roles = [], [], []
prepare do
@components.each do |component|
path(component[:path]).include(component[:clone] ||
component[:artifact])
@@ -531,7 +533,7 @@ module Buildr
"http://java.sun.com/j2ee/dtds/application_1_2.dtd"
xml.application do
xml.tag! 'display-name', display_name
- desc = self.description || @project.comment
+ desc = self.description || @project.comment
xml.tag! 'description', desc if desc
@components.each do |comp|
basename = comp[:artifact].to_s.pathmap('%f')
@@ -552,6 +554,12 @@ module Buildr
xml.jar uri
end
end
+ @security_roles.each do |role|
+ xml.tag! 'security-role', :id=>role[:id] do
+ xml.description role[:description]
+ xml.tag! 'role-name', role[:name]
+ end
+ end
end
buffer
end
Modified: buildr/trunk/spec/java/packaging_spec.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/spec/java/packaging_spec.rb?rev=1041177&r1=1041176&r2=1041177&view=diff
==============================================================================
--- buildr/trunk/spec/java/packaging_spec.rb (original)
+++ buildr/trunk/spec/java/packaging_spec.rb Wed Dec 1 21:29:09 2010
@@ -800,6 +800,17 @@ describe Packaging, 'ear' do
inspect_application_xml { |xml|
xml.get_text('/application/description').should == 'MyDescription' }
end
+ it 'should add security-roles to application.xml if given' do
+ define 'foo', :version=>'1.0' do
+ package(:ear).security_roles << {:id=>'sr1',
+ :description=>'System Administrator',
:name=>'systemadministrator'}
+ end
+ inspect_application_xml do |xml|
+
xml.get_text("/application/security-ro...@id='sr1']/description").to_s.should
eql('System Administrator')
+
xml.get_text("/application/security-ro...@id='sr1']/role-name").to_s.should
eql('systemadministrator')
+ end
+ end
+
it 'should map WARs to /war directory' do
define 'foo', :version=>'1.0' do
package(:ear) << package(:war)