Exclude class from compile classpath

Hi,

I have tried the solutions from Stackoverflow and other Gradle forum post but couldn’t make it work out. My problem is as follows:

Project
–Module: dev (depends on prod)
–Module: prod

However, “dev” contains some duplicate class which should be loaded instead of those from “prod” module. ie,
prod: a.java, b.java…
dev: a.java, c.java…

I want my “dev” compile classpath replace “a.java(a.class)” from “prod”. I tried and was thinking of following solutions:

In “dev”'s build.gradle file:

  1. compile(project(’:production’)){
    exclude “not sure what to do here”
    }

  2. def excludedFiles = configurations.compile.resolvedConfiguration.resolvedArtifacts.findAll {
    def moduleId = it.moduleVersion.id
    //could it be done this way?
    }

// Remove the files from the classpath
sourceSets {
main {
compileClasspath -= files(excludedFiles)
}
}
3.
compile(project(’:prod’, {
sourceSets {
main {
java
{
exclude ‘**/a.java’
}
}
}
}
)) //doesn’t work either

Hope my write up is clear enough for any solutions. I appreciate your time to read this.