Problem copying a war project and it's dependencies to another folder

Hello.

I’m struggling hard to accomplish a simple task, copy a war project archive and it’s runtime dependencies.

Here is build.gradle of the packaging module:

configurations {
  dist
}
  dependencies {
  dist project(':my-war-project')
}
  task dist(type: Copy, dependsOn: configurations.dist) {
  from {
    configurations.dist
  }
  into "$buildDir/dist"
}

This dist task almost works fine, it copies the project archive and the dependencies that I don’t want to include in it’s lib folder (witch is very common in OSGI projects), except when it produces a jar from my war project, resulting in my-war-project.jar instead of my-war-project.war in the destination folder.

I also tried using

dependencies {
  dist project(path: ':my-war-project', configuration: 'archives')
}

This correctly copies ‘my-war-project.war’ to the destination folder, but now transitive dependencies don’t get copied.

The former approach was supposed to be working correctly…

Any ideas in how to fix this undesired behavior?