Execute only one task

Sorry to jump in here, but I would suggest replacing copy with either into or from. My reasoning is that apparently neither the War task class nor its parent classes have a copy(Closure c) method (I only found a copy() method that’s actually the AbstractCopyTask task action). Therefore, attempting to call copy actually calls Project.copy(Closure c), which means that the closure is actually executed when the task is configured. Because both War tasks are configured every time the build is executed, both files are always copied into the src/main/resources directory.

Changing to into requires specifying the destination path of the file inside the War, which is probably not src/main/resources. If you want to place the file in tho root of the archive, you can just use include. In both cases, the requested file isn’t copied to src/main/resources, but is directly added to the War.

In the example below both approaches are shown:

Example:

war {
    webInf { from 'src/main/resources/WEB-INF' }
    manifest {
        attributes 'Implementation-Version': versioning.info.display
    }
}

task createDemoWar(type: War, dependsOn: classes) {
    archiveName "webapi-demo-${versioning.info.display}.war"
    destinationDir = file("$buildDir/dist")
    into('path/inside/war') {
        from 'scopes'
        include 'configuration.demo.properties'
    }
}

task createDevelopmentWar(type: War, dependsOn: classes) {
    archiveName "webapi-dev-${versioning.info.display}.war"
    destinationDir = file("$buildDir/dist")
    from('scopes/') {
        include 'configuration.development.properties'
    }
}

I’m still learning Gradle, but I hope this might help a bit :slight_smile: