Question

In the following gradle script using the ear plugin, how do I get file-war to not include the version number when it builds the ear? Currently, it ends up building the ear but has the version number appended to file-war.war (e.g. file-war-13.war).

apply plugin: 'ear'

dependencies {
    compile "company:file-war:+"
    compile project(':MyWeb')
    deploy project(path: ':MyWeb', configuration: 'archives')
    deploy "company:file-war:+"
}

ear {
    deploymentDescriptor {
        webModule("MyWeb.war", "/")
    }
}
Was it helpful?

Solution

I finally figured this out. Since ear extends from jar, you can just use the rename method which allows you to provide a different name for any included resource.

apply plugin: 'ear'

dependencies {
    compile "company:file-war:+"
    compile project(':MyWeb')
    deploy project(path: ':MyWeb', configuration: 'archives')
    deploy "company:file-war:+"
}

ear {
    deploymentDescriptor {
        webModule("MyWeb.war", "/")
        webModule("MyNewName.war", "/context")
    }

    rename { f ->
       if (f.contains('file-war')) {
          return "MyNewName.war"
       }
    }
}

OTHER TIPS

Ivestigate DSL reference for war plugin.

This should work for instance:

war {
    version = ''       
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top