Search code examples
gradlegrails

Grails 3 exclude class


I am developing a grails plugin and I would like to exclude a class at build time. Let's say I have a service under grails-app/services/MyService.groovy. I would like to build 2 versions of this plugin, one which contains MyService, one which doesn't. Is there a way to achieve this?


Solution

  • In your plugin descriptor you can define pluginExcludes to express items that you want excluded from the plugin. For example:

    def pluginExcludes = [
        '**/com/demo/**'
    ]
    

    You can also exclude contents from the jar file:

    // build.gradle
    jar {
        exclude "com/demo/**"
    }
    

    More info available at https://docs.grails.org/3.3.x/guide/plugins.html.