Class | Buildr::Packaging::Java::EarTask |
In: |
lib/buildr/java/packaging.rb
(CVS)
|
Parent: | JarTask |
Extend the JarTask to create an EAR file.
The following component types are supported by the EARTask:
spring, etc) common to the ear components
The EarTask uses the "Mechanism 2: Bundled Optional Classes" as described on [2]. All specified libraries are added to the EAR archive and the Class-Path manifiest entry is modified for each EAR component. Special care is taken with WebApplications, as they can contain libraries on their WEB-INF/lib directory, libraries already included in a war file are not referenced by the Class-Path entry of the war in order to avoid class collisions
EarTask supports all the same options as JarTask, in additon to these two options:
By default each component type is mapped to a directory with the same name, for example, EJBs are stored in the /ejb path. To customize: package(:ear).map[:war] = 'web-applications' package(:ear).map[:lib] = nil # store shared libraries on root of archive
EAR components are added by means of the EarTask#add, EarTask#<<, EarTask#push methods Component type is determined from the artifact‘s type.
package(:ear) << project('coolWebService').package(:war)
The << method is just an alias for push, with the later you can add multiple components at the same time. For example..
package(:ear).push 'org.springframework:spring:jar:2.6', projects('reflectUtils', 'springUtils'), project('coolerWebService').package(:war)
The add method takes a single component with an optional hash. You can use it to override some component attributes.
You can override the component type for a particular artifact. The following example shows how you can tell the EarTask to treat a JAR file as an EJB:
# will add an ejb entry for the-cool-ejb-2.5.jar in application.xml package(:ear).add 'org.coolguys:the-cool-ejb:jar:2.5', :type=>:ejb # A better syntax for this is: package(:ear).add :ejb=>'org.coolguys:the-cool-ejb:jar:2.5'
By default, every JAR package is assumed to be a library component, so you need to specify the type when including an EJB (:ejb) or Application Client JAR (:jar).
For WebApplications (:war)s, you can customize the context-root that appears in application.xml. The following example also specifies a different directory inside the EAR where to store the webapp.
package(:ear).add project(:remoteService).package(:war), :path=>'web-services', :context_root=>'/Some/URL/Path'
SUPPORTED_TYPES | = | [:war, :ejb, :jar, :rar, :lib] |
path_to | -> | _ |
description | [RW] | The description entry for application.xml |
dirs | [RW] | Map from component type to path inside the EAR. |
display_name | [RW] | The display-name entry for application.xml |
security_roles | [RW] | Security roles entry for application.xml |