user447607
user447607

Reputation: 5469

Why does Gradle jar of jars result in duplicate libraries?

Objective: Create Jar of Jars like Maven does.

I have this relevant snippet:

jar {
  into('lib') {
    from configurations.compile, configurations.runtime
  }
}

There must be something wrong with my conceptualization of what compile / runtime are. If I do this, I get duplicate copies of every library in the resulting jar. I'm really only trying to include everything that might go in and cover all the scopes. I want something I can easily rubber stamp for most jar situations as this is a very large build. I can get more specific for war files.

So... Why does this happen?

Upvotes: 1

Views: 752

Answers (1)

Ben Green
Ben Green

Reputation: 4121

The gradle documentation says this about the runtime configuration:

"runtime: The dependencies required by the production classes at runtime. By default, also includes the compile time dependencies."

Just by copying from the runtime configuration, you would get all of the compile dependencies aswell. You are basically telling gradle to copy the same dependencies twice.

Upvotes: 5

Related Questions