Gradle Dependency management
The Java plugin adds a number of dependency configurations to your project, as shown below. It assigns those configurations to tasks such as compileJava and test.
Table 45.5. Java plugin - dependency configurations
| Name | Extends | Used by tasks | Meaning |
|---|---|---|---|
| compile | - | - | Compile time dependencies |
| compileOnly | compile | - | Compile time only dependencies, not used at runtime |
| compileClasspath | compileOnly | compileJava | Compile classpath, used when compiling source |
| runtime | compile | - | Runtime dependencies |
| testCompile | compile | - | Additional dependencies for compiling tests |
| testCompileOnly | testCompile | - | Additional dependencies only for compiling tests, not used at runtime |
| testCompileClasspath | testCompileOnly | compileTestJava | Test compile classpath, used when compiling test sources |
| testRuntime | runtime, testCompile | test | Additional dependencies for running tests only |
| archives | - | uploadArchives | Artifacts (e.g. jars) produced by this project |
| default | runtime | - | The default configuration used by a project dependency on this project. Contains the artifacts and dependencies required by this project at runtime. |
Figure 45.2. Java plugin - dependency configurations
说明
