3

When i run ./gradlew dependencies i get whole dependency tree including prod/main and test.

How can i get list of only production/main dependencies in result of dependencies task

Official documentation https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html suggests how to show dependencies that would be required on a specific config, say test runtime classpath in a Java project:

`gradle -q dependencies --configuration testRuntimeClasspath`

After googling, i found command gradlew dependencies --configuration compileClasspath Will it's result contain runtime dependencies too ?

How can i get list of dependencies, excluding test dependencies in result of dependencies task?

Bharat Pahalwani
  • 1,404
  • 3
  • 25
  • 40

1 Answers1

3

If what you want are the "production" runtime dependencies, use --configuration runtimeClasspath.

Configurations in Gradle are like buckets of dependencies. The ones contributed by the Java plugin are described here.

The most interesting ones are these:

  • compileClasspath: The dependencies needed for compiling a project. Extends extends compile (deprecated), compileOnly and implementation.
  • runtimeClasspath: The dependencies needed at runtime. Extends runtime (deprecated), runtimeOnly and implementation.

As you noticed, there are also "test" versions of the above two for compiling and running unit tests.

Bjørn Vester
  • 6,851
  • 1
  • 20
  • 20