EAR Deployment Descriptor and Security Role


if found in the api documentation that the securityRole attribute in the deploymentDescriptor of the ear configuration may get a EarSecurityRole object to allow to set a description to the security role. The examples show only the string version where the role name is set (e.g.

securityRole 'admin'


How can I add the description element to the security role?

I tried this:

securityRole {
  name 'admin'
 description 'Administrative User'

but it does not work because securityRole expects a String or EarSecurityRole implementation.

As you can see from the API documentation, there is no Closure (or Action) based method for creating or configuring an EarSecurityRole, so you’ll need to do so programmatically.

Since DefaultEarSecurityRole is internal, your best bet is probably to provide your own EarSecurityRole implementation. Easy in Groovy!

Try this:

ear {
    deploymentDescriptor {
            getRoleName: {'foo'},
             getDescription: {'bar'}
        ] as org.gradle.plugins.ear.descriptor.EarSecurityRole)

Not exactly convenient. The ‘ear’ plugin as it stands does not meet up to the standards that we apply to newer plugins: patches to improve this would be welcome.

Thank you. I played around with the ear plugin and have a patch available that includes this feature. Just a few lines of code. How can I contribute this code to gradle? It is available as github fork and I could create a pull request, or does somebody have to create an issue for this?