summaryrefslogtreecommitdiff
path: root/misc/ide/jetbrains/build.gradle
blob: ffcd12cd151f85143b44ac886efe3b617ef23635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

apply plugin: 'com.android.library'

dependencies {
    implementation "com.android.support:support-core-utils:28.0.0"
}

def pathToRootDir = "../../../"
// Note: Only keep the abis you support to speed up the gradle 'assemble' task.
def supportedAbis = ["armv6", "armv7", "arm64v8", "x86", "x86_64"]

android {

    lintOptions {
        abortOnError false
        disable "MissingTranslation", 'UnusedResources'
    }

    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    useLibrary 'org.apache.http.legacy'

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 28
    }

    sourceSets {
        main {
            manifest.srcFile "AndroidManifest.xml"
            java.srcDirs = ["${pathToRootDir}platform/android/java/src"]
            res.srcDirs = ["${pathToRootDir}platform/android/java/res"]
            aidl.srcDirs = ["${pathToRootDir}platform/android/java/aidl"]
            assets.srcDirs = ["${pathToRootDir}platform/android/java/assets"]
        }
        debug.jniLibs.srcDirs = ["${pathToRootDir}platform/android/java/libs/debug"]
        release.jniLibs.srcDirs = ["${pathToRootDir}platform/android/java/libs/release"]
    }

    libraryVariants.all { variant ->
        variant.outputs.all { output ->
            output.outputFileName = "godot-lib.${variant.name}.aar"
        }

        def buildType = variant.buildType.name.capitalize()

        def taskPrefix = ""
        if (project.path != ":") {
            taskPrefix = project.path + ":"
        }

        // Disable the externalNativeBuild* task as it would cause build failures since the cmake build
        // files is only setup for editing support.
        gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType

        // Create tasks to generate the Godot native libraries.
        def taskName = "compileGodotNativeLibs" + buildType
        def releaseTarget = "release"
        if (buildType == "Debug") {
            releaseTarget += "_debug"
        }

        def abiTaskNames = []
        // Creating gradle tasks to generate the native libraries for the supported abis.
        supportedAbis.each { abi ->
            def abiTaskName = taskName + abi.capitalize()
            abiTaskNames += abiTaskName
            tasks.create(name: abiTaskName, type: Exec) {
                executable "scons"
                args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${abi}"
            }
        }

        // Creating gradle task to run all of the previously generated tasks.
        tasks.create(name: taskName, type: GradleBuild) {
            tasks = abiTaskNames
        }

        // Schedule the tasks so the generated libs are present before the aar file is packaged.
        tasks["merge${buildType}JniLibFolders"].dependsOn taskName
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}