More About Dependencies PDF

Title More About Dependencies
Course Java Intermediate (ODE) 
Institution Georgian College
Pages 3
File Size 154.4 KB
File Type PDF
Total Downloads 64
Total Views 121

Summary

Model Object Scopes...


Description

More About Dependencies Dependencies in Gradle center on configurations. A (dependency-related) configuration is a dependency scope, which means it describes a usage scenario. Consider for example that you have one set of dependencies important only for testing, another set of dependencies needed for the internal functioning of some library, and yet another set of dependencies needed for internal functioning and forwarded to clients (because they show up in public method calls). All those are different scopes, or configurations. Dependency-related configurations are defined by plugins, but there is a common sense about configuration names, and internally configurations also inherit from each other, which leads to configuration name matches between different plugins. Table 3-2 list the configurations you’ll often encounter in Java-related projects.

Once you identify the configurations you need, you specify a list in the dependencies { } section of your build.gradle file: dependencies { implementation 'org.apache.commons:commons-math3:3.6.1' // This is the same: implementation group:'org.apache.commons', name:'commons-math3', version:'3.6.1' // You can combine: implementation 'org.apache.commons:commons-math3:3.6.1', 'org.apache.commons:commons-lang3:3.10'

// or like that: implementation( [ group:'org.apache.commons', name:'commons-math3', version:'3.6.1' ], [ group:'org.apache.commons', name:'commons-lang3', version:'3.10' ] ) // or like that: implementation 'org.apache.commons:commons-math3:3.6.1' implementation 'org.apache.commons:commons-lang3:3.10' testImplementation 'junit:junit:4.12' } Normally any indirect dependency, which comes from dependencies of dependencies, gets resolved automatically. Such dependencies are called transitive dependencies. So if you declare a dependency on some library A, which in turn depends on libraries B and C, Gradle will take care of including B and C in the build, without needing to explicitly declare the dependencies on B and C in build.gradle. If you want to prevent Gradle from including transitive dependencies, you can mark them using transitive = false:...


Similar Free PDFs