Duplicated content into custom WAR file

Hi,
I have a problem with a generated war, I have noticed that the content was duplicated for a few files.
Well I believe that’s caused by resources declared in my sourceSets and the tmp directory that I have used for generating my custom War:


sourceSets{
    main{
            java{
                  srcDir 'src/' 
                  }
            resources{
                         srcDir 'resource'
                        srcDir 'resource-externally'
                 }
        ....
    
    task generateWar(type: War){
      	version "$version"
      	destinationDir = file("$buildDir/dist")
    	from ("$buildDir/war")
    }

I know that the war plugin will uses the resources defined in the sourceSets and also will add my custom content generated in “$buildDir/war”. So this explain why the content is duplicated for some files.
Is there a way that forces gradle to use only “$buildDir/war” content for generating my custom war?
Thanks

The only solutions that I found useful; is weather to give up the definition of resources in sourceSets or just you have to exclude the files the causes the conflicts:


task generateWar(type: War){
          	version "$version"
          	destinationDir = file("$buildDir/dist")
        	from ("$buildDir/war"){
                         exclude("dir1")
                          ...
                }
        }

Also another mistake that I have made is pointing outputclassesDir to $buildDir/war/WEB-INF/classes and during the war task this will be duplicated because the war plugin copy the content from classes and the same content that I explicitly made it destination to the custom war plugin. So you have to keep it in the default destination “$buildDir/classes” or just exclude it from the war content list.

I dug into the war api a bit today and came up with a different solution:

war {
  classpath = '/dev/null'
}

For me this prevents duplicate files being included due to the rather opaque stock configuration.