Subversion Repositories AndroidProjects

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1688 chris 1
android {
1707 chris 2
    buildToolsVersion "19.1.0"
1688 chris 3
    compileSdkVersion 19
4
    sourceSets {
5
        main {
6
            manifest.srcFile 'AndroidManifest.xml'
7
            java.srcDirs = ['src']
8
            resources.srcDirs = ['src']
9
            aidl.srcDirs = ['src']
10
            renderscript.srcDirs = ['src']
11
            res.srcDirs = ['res']
12
            assets.srcDirs = ['assets']
13
        }
14
 
15
        instrumentTest.setRoot('tests')
16
    }
17
}
18
 
19
// needed to add JNI shared libraries to APK when compiling on CLI
20
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
21
    pkgTask.jniFolders = new HashSet<File>()
22
    pkgTask.jniFolders.add(new File(projectDir, 'libs'))
23
}
24
 
25
// called every time gradle gets executed, takes the native dependencies of
26
// the natives configuration, and extracts them to the proper libs/ folders
27
// so they get packed with the APK.
28
task copyAndroidNatives() {
29
    file("libs/armeabi/").mkdirs();
30
    file("libs/armeabi-v7a/").mkdirs();
31
    file("libs/x86/").mkdirs();
32
 
33
    configurations.natives.files.each { jar ->
34
        def outputDir = null
35
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
36
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
37
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
38
        if(outputDir != null) {
39
            copy {
40
                from zipTree(jar)
41
                into outputDir
42
                include "*.so"
43
            }
44
        }
45
    }
46
}
47
 
48
task run(type: Exec) {
49
    def adb = "$System.env.ANDROID_HOME/platform-tools/adb"
50
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.gebauz.watergame.android/com.gebauz.watergame.android.AndroidLauncher'
51
}
52
 
53
// sets up the Android Eclipse project, using the old Ant based build.
54
eclipse {
55
    // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
56
    // ignores any nodes added in classpath.file.withXml
57
    sourceSets {
58
        main {
59
            java.srcDirs "src", 'gen'
60
        }
61
    }
62
 
63
    jdt {
64
        sourceCompatibility = 1.6
65
        targetCompatibility = 1.6
66
    }
67
 
68
    classpath {
69
        plusConfigurations += project.configurations.compile
70
        containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
71
    }
72
 
73
    project {
74
        name = appName + "-android"
75
        natures 'com.android.ide.eclipse.adt.AndroidNature'
76
        buildCommands.clear();
77
        buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
78
        buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
79
        buildCommand "org.eclipse.jdt.core.javabuilder"
80
        buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
81
    }
82
}
83
 
84
// sets up the Android Idea project, using the old Ant based build.
85
idea {
86
    module {
87
        sourceDirs += file("src");
88
        scopes = [ COMPILE: [plus:[project.configurations.compile]]]
89
 
90
        iml {
91
            withXml {
92
                def node = it.asNode()
93
                def builder = NodeBuilder.newInstance();
94
                builder.current = node;
95
                builder.component(name: "FacetManager") {
96
                    facet(type: "android", name: "Android") {
97
                        configuration {
98
                            option(name: "UPDATE_PROPERTY_FILES", value:"true")
99
                        }
100
                    }
101
                }
102
            }
103
        }
104
    }
105
}