Reputation: 113
There are two modules in my project and module A depends on module B. For building this with Gradle I've used a simple code in the A's build.gradle file:
compile project(":B")
My issue is a collision of resources directories. What I want to do is to exclude certain B's module "resource" directory.
What I've tried:
compile (project(":B")) {
exclude group : 'src.main', module : 'resources'
}
What I've tried as well:
compile(project(":B")) {
exclude module: 'src'
exclude module: 'main'
exclude module: 'src/main'
exclude module: 'src.main'
}
By excluding the root of module B, I'm expecting to get failed build of whole project, but nothing happens.
P.S. Every time I'm running build, I'm cleaning compiled jars, so they are not cached.
Upvotes: 2
Views: 1864
Reputation: 1
Following worked for me.
android {
...
applicationVariants.all { variant ->
if (variant.buildType == 'release') {
variant.mergeAssetsProvider.configure {
doLast {
delete(fileTree(dir: outputDir, include: ["**/directoryToExclude/**", "**/fileToExclude.extension"]))
}
}
}
}
}
Upvotes: 0
Reputation: 27984
Gradle modules don't work like this. A java module is the compiled classes plus the resources. You can only exclude dependencies (ie whole modules or jars) using your attempted exclude method. You can't exclude a specific part (eg a directory) of a dependency
In my opinion excluding things is an anti-pattern. I suggest breaking things onto smaller pieces and joining them together (ie "include" instead of "exclude")
So I suggest you create a ":common" project which both "A" and "B" have as a dependency. All common stuff goes in common and any specific stuff goes in A or B
Upvotes: 1