IBM / cics-bundle-gradle

The plugin to build and deploy CICS bundles in a Gradle build.
Eclipse Public License 2.0
7 stars 20 forks source link

Provide support for explicitly configured bundle parts #14

Closed ledina closed 4 years ago

ledina commented 4 years ago

Allow name override for WAR and EAR (not supported for OSGi). Clarification: You can override the name of an OSGi bundle but not the symbolicName. Should be able to specify jvmServer to override the defaultJvmServer value.

tom-foyle commented 4 years ago

Proposed solution: Add a new extension sub-block override, which goes inside the existing cicsBundle extension, to override the name, jvmserver, and file extension (i.e. bundle part type) of a particular bundle part. Specify which bundle part to override by supplying it's artifact filename.

dependencies {
    cicsBundle(group: 'org.codehaus.cargo', name: 'simple-bundle', version: '1.7.7', ext: 'jar')
    cicsBundle(group: 'org.codehaus.cargo', name: 'simple-war', version: '1.7.7', ext: 'war')
}

cicsBundle {
    // Override name and jvmserver of simple-bundle-1.7.7.
    override {
        filename = 'simple-bundle-1.7.7.jar'
        name = 'new-name'
        jvmserver = 'NEWJVMS'
    }
    // Override file extension of simple-war-1.7.7 so it is processed as an ear instead.
    override {
        filename = 'simple-war-1.7.7.war'
        extension = 'ear'
    }
}

The above config will produce:

new-name.jar
new-name.osgibundle (<osgibundle jvmserver="NEWJVMS" symbolicname="org.codehaus.cargo.simple-bundle" version="1.7.7"/>)
simple-war-1.7.7.ear
simple-war-1.7.7.earbundle
tom-foyle commented 4 years ago

Proposed solution 2: Adapt the extension so that the extra config can go inline with the dependency declaration. This feels more natural and means that the user doesn't need to know what the resolved filename will be.

Two types of notations can be used. Either specify the bundlePart config using a closure:

// Override name and jvmserver of simple-bundle-1.7.7.
dependencies {
    bundleParts {
        bundlePart {
            dependency = cicsBundle(group: 'org.codehaus.cargo', name: 'simple-bundle', version: '1.7.7', ext: 'jar')
            name = 'new-name'
            jvmserver = 'NEWJVMS'
        }
    }
}

Or on a single line using a method which takes a map as the argument:

// Override file extension of simple-war-1.7.7 so it is processed as an ear instead.
dependencies {
    bundleParts.bundlePart(dependency: cicsBundle('org.codehaus.cargo:simple-war:1.7.7@war'), extension: 'ear')
}
tom-foyle commented 4 years ago

Proposed solution 3: Use strong types like cicsBundleWar rather than bundlePart. Use DSL methods to allow bundle parts to be specified at the top level inside the dependencies block so they no longer need to be nested under a bundleParts parent extension.

dependencies {
    // Normal dependency with no overrides.
    cicsBundle 'org.codehaus.cargo:simple-ear:1.7.7@ear'
    // Override name and jvmserver of simple-bundle-1.7.7.
    cicsBundleOsgi {
        dependency = cicsBundle(group: 'org.codehaus.cargo', name: 'simple-bundle', version: '1.7.7', ext: 'jar')
        name = 'new-name'
        jvmserver = 'NEWJVMS'
    }
    // Override file extension of simple-war-1.7.7 so it is processed as an ear instead.
    cicsBundleEar(dependency: cicsBundle('org.codehaus.cargo:simple-war:1.7.7@war'))
}
ledina commented 4 years ago

Resolved by #63