1. 程式人生 > >gradle引用外部的庫模組

gradle引用外部的庫模組

有些通用的功能會抽到df_lib_gradle模組中,方便以後的JAVA程式碼公用。

比如我現在的工程要引用上上級目錄下的df_lib_gradle/lib_core模組

在本工程setting.gradle目錄下引入lib_core模組。

include ':gdx-pay', ':lib_core'
include ':gdx-pay-client'
//include ':gdx-pay-android'
//include ':gdx-pay-android-openiab'
//include ':gdx-pay-android-ouya'
//include ':gdx-pay-android-amazon'
//include ':gdx-pay-android-googleplay'
include ':gdx-pay-desktop-apple'
//include ':gdx-pay-gwt-googlewallet'
//include ':gdx-pay-iosrobovm-apple'
include ':gdx-pay-iosmoe-apple'
//include ':gdx-pay-server'
include ':gdx-pay-tests'
//include ':gdx-pay-tests-android'
//include ':gdx-pay-tests-iosrobovm'
include ':gdx-pay-tests-iosmoe'

rootProject.name = "gdx-pay-root"

include ':com.badlogic.gdx.pay.tests'

include 'df_lib_gradle'
project(':df_lib_gradle').projectDir = new File(settingsDir, "../../df_lib_gradle")

include 'lib_core'
project(':lib_core').projectDir = new File(settingsDir, "../../df_lib_gradle/lib_core")


在本工程主目錄下build.gradle中加入lib_core模組

apply plugin: "java"

sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'GBK'


buildscript {
    repositories {
//        mavenLocal()

        maven { url "http://maven.aliyun.com/nexus/content/groups/public"}
        maven { url "http://repository.jboss.org/nexus/content/groups/public/"}
        maven { url "https://repository.jboss.org/nexus/content/repositories/releases/"}
        maven { url "http://repo2.maven.org/maven2/"}
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
//        jcenter()
//        mavenCentral()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:2.1.3'
//        classpath 'org.multi-os-engine:moe-gradle:1.2.0'
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'org.multi-os-engine:moe-gradle:1.2.3'
    }
}


allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "dy_cike_cikechuanshuo_init_init"
//        gdxVersion = '1.9.4'
//        gdxVersion = '1.9.5-SNAPSHOT'
        gdxVersion = '1.9.5'
        roboVMVersion = '2.3.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'

//        wulong: gdxpay 經查證,gradle庫裡只有0.10.4-SNAPSHOT版本
//        gdxPayVersion = '0.10.3'
        gdxPayVersion = '0.10.4-SNAPSHOT'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "http://repo2.maven.org/maven2/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}


project(":desktop") {
    apply plugin: "java"

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
//        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
//        compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
//        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile fileTree(dir: '../core/libs', include: '*.jar')
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
//wulong: gdx頻繁更新,為了加快下載庫的速度,遮蔽掉部分不用的庫
//        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
//        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
//        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
//        compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
//        compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
//        compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"

//        wulong: gdxpay
        compile "com.badlogicgames.gdxpay:gdx-pay-android:$gdxPayVersion"
        compile "com.badlogicgames.gdxpay:gdx-pay-android-googleplay:${gdxPayVersion}@aar"
    }
}

project(":core") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
//        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
//        compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
//        compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
//        compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
        compile fileTree(dir: 'libs', include: '*.jar')
//        todo: wulong
        compile project(':lib_core')
//        wulong: gdxpay
        compile "com.badlogicgames.gdxpay:gdx-pay-client:$gdxPayVersion"
    }
}

project(":ios-moe") {
    apply plugin: "moe"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
//        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
//        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"

//        wulong: gdxpay
        compile "com.badlogicgames.gdxpay:gdx-pay-iosmoe-apple:$gdxPayVersion"
    }
}


tasks.eclipse.doLast {
    delete ".project"
}