New generation component tool Gradle

(1) Things you must know

  • Different versions of idea have different levels of support for the gradle version. The idea version is better than 2019.
  • The SpringBoot version also has requirements for the gradle version

(Two) understanding of groovy basics

(Three) closure

(4) Build script analysis

Description: A project represents a component being built (such as a jar file). When the build starts, Gradle will instantiate an org.gradle.api.Project class based on build.gradle, and make it implicitly available through the project variable

(5) Gradle builds multi-module projects

(6) Methods to resolve version dependency conflicts

// 有版本冲突时启动失败
configurations.all {
    resolutionStrategy {
        failOnVersionConflict()
    }
}

// 定义变量统一版本方法  ext为Project的隐式方法 可以在其中定义变量
ext {
    //Dependencies
    supportLibraryVersion = '25.3.1'
    okHttpVersion = '3.8.0'
    domainTestDependencies = [
            appcompatv7: "com.android.support:appcompat-v7:${supportLibraryVersion}",
            okHttp     : "com.squareup.okhttp3:okhttp:${okHttpVersion}"
    ]
}


// 排除对应的版本
implementation ('com.carlos.test:Test:1.0.0') {
    exclude group: "io.reactivex.rxjava2",module: "rxjava"
    // exclude group: "io.reactivex.rxjava2:rxjava:2.1.11"
}
implementation 'io.reactivex.rxjava2:rxjava:2.1.13'



// 强制使用一个版本
configurations.all {
    resolutionStrategy {
        force 'io.reactivex.rxjava2:rxjava:2.1.13'
    }
}

(7) Dependent warehouse in Repository

// repositories() 方法,参数是{}代码块
repositories {

    // 执行顺序从上往下
    // 指定私服
    maven {
        url "192.168.*.*/maven/public"
    }
    mavenCentral()
}

 

Guess you like

Origin blog.csdn.net/qq_41750725/article/details/109143594