Gradle: How to exclude a particular package from a jar?

This solution is valid if you don´t want to compile these packages, but if you want to compile them and exclude from your JAR you could use

// tag::jar[]
jar {
    exclude('mi/package/excluded/**')   
    exclude('mi/package/excluded2/**')  
}
// end::jar[]

Leave a Comment