Multi module build with multiple source sets

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Multi module build with multiple source sets

This post has NOT been accepted by the mailing list yet.
We are in the process of migrating a large legacy application to a new application platform.

We have existing gradle scripts in place for the modules, however these scripts have not, so far, supported webservice build, only compile and test. Our new application platform has some constraints, in particular @Webservice annotated classes must be singular per deployed war. Since the legacy application has many cross-module dependencies this is a problem, and I'd rather not create a multitude of tiny additional modules for each webservice.

I was looking at using SourceSets to split out the webservice annotated classes within a module and allow them to be picked out individually for the webservice build. So for example:


ModuleB (depends upon ModuleA)

I'd like to be able to create a ModuleA.war that contains classes from both ModuleA/src and ModuleA/webservice/src
and a ModuleB.war that contains classes from ModuleB/src, ModuleB/webservice/src and ModuleA/src.

I've tried customizing our build scripts using SourceSets and adjustments to the new war section that was added, here's the snippet:

                                srcDir 'webservice/src'


war {
    from sourceSets.webservice.output
    webInf { from 'WebContent' } // adds a file-set to the WEB-INF dir.
    exclude ( '**/*.class' )//prevents unnecessary duplication

Any pointers or alternative suggestions much appreciated.