ythy / blog

Give everything a shot
7 stars 0 forks source link

Gradle #297

Open ythy opened 4 years ago

ythy commented 4 years ago

External dependencies for the build script

If your build script needs to use external libraries, you can add them to the script’s classpath in the build script itself. You do this using the buildscript() method, passing in a block which declares the build script classpath.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
    }
}

You declare the build script classpath by adding dependencies to the classpath configuration

What are dependency configurations

link Every dependency declared for a Gradle project applies to a specific scope. For example some dependencies should be used for compiling source code whereas others only need to be available at runtime. Gradle represents the scope of a dependency with the help of a Configuration. Every configuration can be identified by a unique name.

For example, if I want to express that my application app depends on library lib, we need at least one configuration:

configurations {
    // declare a "configuration" named "someConfiguration"
    someConfiguration
}
dependencies {
    // add a project dependency to the "someConfiguration" configuration
    someConfiguration project(":lib")
}
ythy commented 4 years ago

plugins

java

link

The Java plugin adds Java compilation along with testing and bundling capabilities to a project. It serves as the basis for many of the other JVM language Gradle plugins