我的工程setting.gradle
include 'desktop', 'android', 'ios', 'core'
include 'lib_core'
project(':lib_core').projectDir = new File(settingsDir, "../../df_lib_x/lib_core")
include 'lib_android'
project(':lib_android').projectDir = new File(settingsDir, "../../df_lib_x/lib_android")
includeFlat 'dy_cike_xcf', 'dy_cike_cocostudio'
我的工程根目录build.gradle
buildscript {
repositories {
mavenLocal()
// mavenCentral()
maven { url "http://repo2.maven.org/maven2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "dy_cike_cikechuanshuo_init_init"
gdxVersion = '1.8.0'
roboVMVersion = '1.12.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.7.0'
}
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"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
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-x86"
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-x86"
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-x86"
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-x86"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
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.box2dlights:box2dlights:$box2DLightsVersion"
compile fileTree(dir: 'libs', include: '*.jar')
}
}
tasks.eclipse.doLast {
delete ".project"
}
我的工程core模块build.gradle
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'GBK'
sourceSets.main.java.srcDirs = ["src/"]
eclipse.project {
name = appName + "-core"
}
dependencies {
compile project(':lib_core')
}
我的工程android模块build.gradle
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'GBK'
sourceSets.main.java.srcDirs = ["src/"]
eclipse.project {
name = appName + "-core"
}
dependencies {
compile project(':lib_core')
}
我的工程desktop模块build.gradle
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'GBK'
sourceSets.main.java.srcDirs = ["src/"]
project.ext.mainClassName = "sample.DesktopApp"
project.ext.assetsDir = new File("../android/assets");
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task testApp(dependsOn: classes, type: JavaExec) {
project.ext.mainClassName = "sample.TestApp"
classpath = sourceSets.main.runtimeClasspath
main = project.mainClassName
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task testBlackEdges(dependsOn: classes, type: JavaExec) {
project.ext.mainClassName = "sample.test.blackedge.TestBlackEdgesApp"
classpath = sourceSets.main.runtimeClasspath
main = project.mainClassName
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task dist(type: Jar) {
project.ext.mainClassName = "sample.DesktopApp"
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from { configurations.compile.collect { zipTree(it) } }
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
}
}
dist.dependsOn classes
task distToolPreloadResources(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from { configurations.compile.collect { zipTree(it) } }
from files(project.assetsDir);
doLast {
def getSrcPath = {
def srcSb = new StringBuffer("")
srcSb.append(destinationDir).append(File.separator).append(archiveName)
return srcSb.toString()
}
def getDstPath = {
String parent = destinationDir.getPath();
String path = String.join(File.separator, parent, "..", "..", "..", "tool", "preload_resources.jar")
print("distToolPreloadResources dst path = " + path + "\n");
return path
}
File f = file(getSrcPath())
File to = file(getDstPath())
f.renameTo(to)
}
manifest {
attributes 'Main-Class': "dy.tools.ToolPreLoadResourcesApp"
}
}
distToolPreloadResources.dependsOn classes
task distToolSkeletonResources(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from { configurations.compile.collect { zipTree(it) } }
from files(project.assetsDir);
doLast {
def getSrcPath = {
def srcSb = new StringBuffer("")
srcSb.append(destinationDir).append(File.separator).append(archiveName)
return srcSb.toString()
}
def getDstPath = {
String parent = destinationDir.getPath();
String path = String.join(File.separator, parent, "..", "..", "..", "tool", "skeleton_resources.jar")
print("distToolSkeletonResources dst path = " + path + "\n");
return path
}
File f = file(getSrcPath())
File to = file(getDstPath())
f.renameTo(to)
}
manifest {
attributes 'Main-Class': "dy.tools.ToolSkeletonResourcesApp"
}
}
distToolSkeletonResources.dependsOn classes
eclipse {
project {
name = appName + "-desktop"
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
}
}
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [kind: 'src', path: 'assets']);
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}
df_lib_x库setting.gradle
rootProject.name = 'df_lib_x'
include 'lib_core','lib_android'
df_lib_x库根build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
df_lib_x库lib_core模块build.gradle
version 'unspecified'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
sourceSets {
main {
java.srcDir('src')
}
}
task xx() {
print("......")
}
dependencies {
compile files('libs_gdx/gdx-1.8.0.jar')
compile files('libs_andeng/andengine.jar')
}
df_lib_x库lib_android模块build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'com.android.library'
android {
lintOptions {
abortOnError false
}
}
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
compileOptions {
encoding 'GBK'
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs_andeng')
provided fileTree(include: ['*.jar'], dir: 'libs_cmcc_runtime')
provided fileTree(include: ['*.jar'], dir: 'libs_cmcc_Unity3D')
provided fileTree(include: ['*.jar'], dir: 'libs_gdx')
provided fileTree(include: ['*.jar'], dir: 'libs_other')
provided fileTree(include: ['*.jar'], dir: 'libs_xudx')
provided fileTree(include: ['*.jar'], dir: 'libs_ydmm')
compile 'com.android.support:appcompat-v7:23.2.0'
compile project(':lib_core')
}
task lib_android_x() {
print('xxxxxxx')
}
gradle-wrapper.properties写法
#Sat Sep 21 13:08:26 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip
#distributionUrl=file\:/home/andrew/program/gradle/gradle-2.10-all.zip
distributionUrl=file:///d:/program/gradle/gradle-2.10-all.zip
local.properties写法
sdk.dir=D\:/program/android/android-sdk-windows_r06.setup