android : 一个gradle 可以依赖另一个gradle进行编译

78 阅读1分钟

研究cocos import android 项目编译

app moudle下的gradle


buildscript {

    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


// 注意这一行,它使用了另外一个项目的中gradle文件
apply from: NATIVE_DIR +"/build.gradle"

额外依赖

  • /native/engine/android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

做一下对比,二者区别在于以下部分

allprojects {
    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

所以,我做一下中和:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


// 直接引用 ,摆脱依赖外界的gradle配置
allprojects {
    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}



// 移除
//apply from: NATIVE_DIR +"/build.gradle"