美文网首页
project 目录build.gradle -> build

project 目录build.gradle -> build

作者: 妖怪青同学 | 来源:发表于2019-03-11 11:52 被阅读0次
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
    
        ext {
            kotlin_version = '1.3.21' // kotlin版本号
            support_version = '28.0.0' // support包版本
            compileSdkVersion = 28 // SDK编译版本
            buildToolsVersion = "28.0.3"
            targetSdkVersion = 26 // SDK目标版本
            minSdkVersion = 19 // 最低支持的SDK版本
            versionCode = 12345 // 应用版本CODE
            versionName = '1.0.0' // 应用版本名
        
        }
    
        repositories {
            maven { url 'https://maven.fabric.io/public' }
            google()
            jcenter()
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.2.0'
            classpath 'io.fabric.tools:gradle:1.27.1'
            //greenDao
            classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    

    The "buildscript" configuration section is for gradle itself (i.e. changes to how gradle is able to perform the build). So this section will usually include the Android Gradle plugin.

    The "allprojects" section is for the modules being built by Gradle.

    Oftentimes the repository section is the same for both, since both will get their dependencies from jcenter usually (or maybe maven central). But the "dependencies" section will be different.

    Usually the "dependencies" section for "allprojects" is empty since the dependencies for each module are unique and will be in the "build.gradle" file within each of the modules. However, if all of the modules shared the same dependencies then they could be listed here.

    TL;DR: buildscript helps find plugins, allprojects applies to all projects

    buildscript 用于帮助找gradle使用的插件 ,是构建用到的

    声明gardle脚本自身所需要使用的资源,包括依赖项、maven仓库地址、第三方插件等。你可以在里面手动添加一些三方插件、库的引用,这样你就可以在脚本中使用它们了。因为是引用,所以gradle在执行脚本时,会优先执行buildscript代码块中的内容。

    allprojects 是多项目构建用到的(所有Module共同用到),是代码中用到的

    相关文章

      网友评论

          本文标题:project 目录build.gradle -> build

          本文链接:https://www.haomeiwen.com/subject/udmvpqtx.html