gradle android plugin

gradle android plugin

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    //最顶层的build文件是用来驱动构建的
    //一般不会修改这个文件

    buildscript { // 构建声明
        repositories { //仓库来源
            jcenter() //仓库名字
        }
        dependencies { //依赖插件
            classpath 'com.android.tools.build:gradle:1.0.0-rc1'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    //下面是设置所有项目应用仓库为jcenter
    allprojects { 
        repositories {
            jcenter()
        }
    }
    //最后更新是studio rc2
    //插件版本最新是1.0.0-rc1

具体到项目或者模块的build

    //这是具体到项目或者模块的构建驱动文件

    //android构建插件
    apply plugin: 'com.android.application'

    //android的一些基本设置
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.1"

        defaultConfig {
            applicationId "com.example.ben.myapplication"
            minSdkVersion 15
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
        }

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.2'
    }


    //最后更新是studio rc2
    //插件版本最新是1.0.0-rc1

每行配置的说明

task

只是标记

  • assemble
  • check
  • build
  • clean

tips: gradle task –all

你可能感兴趣的:(gradle android plugin)