Using SourceSets with WAR plugin

Background: we are migrating application server and have an existing multi-module gradle compile and test suite. We would like to extend the build scripts to support webservice war builds. I have succesfully introduced the war plugin, but face a problem with multiple @webservice annotated classes.

For example, we have ModuleA and ModuleB (which depends upon ModuleA for compile), both of which are also webservices in their own right.

If I create webservice annotated classes in both modules and package using the existing main SourceSet, then the ModuleB war file will contain two @webservice classes which is not supported.

I tried creating a separate “webservice” SourceSet in both ModuleA and ModuleB - with the aim of including only the Module B webservice sourceset when assembling the ModuleB war.

Are SourceSets the best approach? We have 50+ modules, so I’d rather not create another 50 webservice specific modules each with a single class/interface in them.

Also, so far I’ve been unable to get the war plugin to include the webservice sourceset class into the assembled war. I tried:

war{
from sourcesets.webservice.output
webInf { from ‘webContent’ }
include { ‘/TestMe.class’ } //A dummy annotated class in the webservice sourceset
exclude{ '
/*.class’ } //This seems to prevent unnecessary duplication of my classes in multiple locations
}

The build runs through, but the class is not included in the generated war.

Many Thanks
Mike S