• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1repositories {
2	mavenCentral()
3	maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
4}
5
6android {
7	buildToolsVersion "20.0.0"
8	compileSdkVersion 20
9	sourceSets {
10		main {
11			manifest.srcFile 'AndroidManifest.xml'
12			java.srcDirs = ['src']
13			aidl.srcDirs = ['src']
14			renderscript.srcDirs = ['src']
15			res.srcDirs = ['res']
16			assets.srcDirs = ['assets']
17			jniLibs.srcDirs = ['libs']
18		}
19	}
20}
21
22// sets up the Android Eclipse project, using the old Ant based build.
23eclipse {
24	// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
25	// ignores any nodes added in classpath.file.withXml
26	sourceSets {
27		main {
28			java.srcDirs "src", 'gen'
29		}
30	}
31
32	jdt {
33		sourceCompatibility = 1.6
34		targetCompatibility = 1.6
35	}
36
37	classpath {
38		plusConfigurations += [ project.configurations.compile ]
39		containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
40	}
41
42	project {
43		natures 'com.android.ide.eclipse.adt.AndroidNature'
44		buildCommands.clear();
45		buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
46		buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
47		buildCommand "org.eclipse.jdt.core.javabuilder"
48		buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
49	}
50}
51
52// sets up the Android Idea project, using the old Ant based build.
53idea {
54	module {
55		sourceDirs += file("src");
56		scopes = [ COMPILE: [plus:[project.configurations.compile]]]
57
58		iml {
59			withXml {
60				def node = it.asNode()
61				def builder = NodeBuilder.newInstance();
62				builder.current = node;
63				builder.component(name: "FacetManager") {
64					facet(type: "android", name: "Android") {
65						configuration {
66							option(name: "UPDATE_PROPERTY_FILES", value:"true")
67						}
68					}
69				}
70			}
71		}
72	}
73}
74
75// used to create obb file
76task copyAssets << {
77	def assets = fileTree('assets')
78	copy {
79		from assets
80		into "build/obbassets"
81		rename { fileName ->
82			fileName = "obbasset-" + fileName
83		}
84	}
85}
86
87task zipAssets(type: Zip) {
88	destinationDir = file("build/obb")
89	entryCompression = ZipEntryCompression.STORED
90	from "build/obbassets"
91	baseName = "main.1.com.badlogic.gdx.tests.android"
92	extension = "obb"
93}
94
95def getADBPath() {
96	def path
97	def localProperties = new File("local.properties")
98	if (localProperties.exists()) {
99		Properties properties = new Properties()
100		localProperties.withInputStream { instr ->
101			properties.load(instr)
102	}
103	def sdkDir = properties.getProperty('sdk.dir')
104	if (sdkDir) {
105	    path = sdkDir
106	} else {
107	    path = "$System.env.ANDROID_HOME"
108	}
109	} else {
110		path = "$System.env.ANDROID_HOME"
111	}
112
113	def adb = path + "/platform-tools/adb"
114	adb
115}
116
117task createOBBDir(type: Exec) {
118	def adb = getADBPath();
119	commandLine "$adb", 'shell', 'mkdir', '-p', '/mnt/sdcard/Android/obb/com.badlogic.gdx.tests.android'
120}
121task uploadOBB(type: Exec) {
122	def adb = getADBPath();
123	commandLine "$adb", 'push', 'build/obb/main.1.com.badlogic.gdx.tests.android.obb', '/mnt/sdcard/Android/obb/com.badlogic.gdx.tests.android'
124}
125
126copyAssets.dependsOn clean
127zipAssets.dependsOn copyAssets
128createOBBDir.dependsOn zipAssets
129uploadOBB.dependsOn createOBBDir
130