How to build war without duplicates .class files and excluding java file using gradle

In my project we are using gradle for builld war. This project follows MVC structure we have used spring technologies , now we had a three layers Controller, Service, DAO layers but with the support of spring injecion we can inject DAO layer into Service Layer and Service Layer into Controller ( View Layer ) but can we restrict to inject dao layer into controller layer and service layer into dao layer if we try to do so while building war gradle should failed to build.

 sourceSets {
    gen {
        java {
            srcDir 'app/GeneratedSource'
        }
    }

    dao {
        java {
            srcDir 'app/JavaSource'
            exclude 'gov/fd/vc/svc/**'
        }
        compileClasspath += gen.output
    }

    svc {
        java {
            srcDir 'app/JavaSource'
            exclude 'gov/fd/vc/dao/**'
        }
        compileClasspath += gen.output
        compileClasspath += dao.output
    }

     main {
        java {
            srcDir 'web/JavaSource'
        }
        resources {
            srcDir 'app/GeneratedSource'
            srcDir 'app/JavaSource'
            srcDir 'web/JavaSource'
        }
        compileClasspath += svc.output
    }
}

configurations {
    genCompile.extendsFrom compile
    daoCompile.extendsFrom compile
    svcCompile.extendsFrom compile
}

I have modified sourceSet as above however i achieved it but while creating war it is including all .java files and creating duplicate .class files how to solve this if the i use below sourceSet it is working but i cannot achieve my target as above code does.

sourceSets {
main {
java {
srcDir 'app/GeneratedSource’
srcDir 'app/JavaSource’
srcDir ‘web/JavaSource’
}
resources {
srcDir 'app/GeneratedSource’
srcDir 'app/JavaSource’
srcDir ‘web/JavaSource’
}
}
}

with the above code there problem with war build.