summaryrefslogtreecommitdiff
path: root/platform/android/java/app/config.gradle
blob: 7d5d238100129492711234b33de0bc5d39a4aba1 (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
ext.versions = [
    androidGradlePlugin: '3.5.3',
    compileSdk         : 29,
    minSdk             : 18,
    targetSdk          : 29,
    buildTools         : '29.0.3',
    supportCoreUtils   : '1.0.0',
    kotlinVersion      : '1.3.61',
    v4Support          : '1.0.0'

]

ext.libraries = [
    androidGradlePlugin: "com.android.tools.build:gradle:$versions.androidGradlePlugin",
    supportCoreUtils   : "androidx.legacy:legacy-support-core-utils:$versions.supportCoreUtils",
    kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion",
    kotlinStdLib       : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlinVersion",
    v4Support          : "androidx.legacy:legacy-support-v4:$versions.v4Support"
]

ext.getExportPackageName = { ->
    // Retrieve the app id from the project property set by the Godot build command.
    String appId = project.hasProperty("export_package_name") ? project.property("export_package_name") : ""
    // Check if the app id is valid, otherwise use the default.
    if (appId == null || appId.isEmpty()) {
        appId = "com.godot.game"
    }
    return appId
}

ext.getExportVersionCode = { ->
    String versionCode = project.hasProperty("export_version_code") ? project.property("export_version_code") : ""
    if (versionCode == null || versionCode.isEmpty()) {
        versionCode = "1"
    }
    return Integer.parseInt(versionCode)
}

ext.getExportVersionName = { ->
    String versionName = project.hasProperty("export_version_name") ? project.property("export_version_name") : ""
    if (versionName == null || versionName.isEmpty()) {
        versionName = "1.0"
    }
    return versionName
}

final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|"

/**
 * Parse the project properties for the 'plugins_maven_repos' property and return the list
 * of maven repos.
 */
ext.getGodotPluginsMavenRepos = { ->
    Set<String> mavenRepos = []

    // Retrieve the list of maven repos.
    if (project.hasProperty("plugins_maven_repos")) {
        String mavenReposProperty = project.property("plugins_maven_repos")
        if (mavenReposProperty != null && !mavenReposProperty.trim().isEmpty()) {
            for (String mavenRepoUrl : mavenReposProperty.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
                mavenRepos += mavenRepoUrl.trim()
            }
        }
    }

    return mavenRepos
}

/**
 * Parse the project properties for the 'plugins_remote_binaries' property and return
 * it for inclusion in the build dependencies.
 */
ext.getGodotPluginsRemoteBinaries = { ->
    Set<String> remoteDeps = []

    // Retrieve the list of remote plugins binaries.
    if (project.hasProperty("plugins_remote_binaries")) {
        String remoteDepsList = project.property("plugins_remote_binaries")
        if (remoteDepsList != null && !remoteDepsList.trim().isEmpty()) {
            for (String dep: remoteDepsList.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
                remoteDeps += dep.trim()
            }
        }
    }
    return remoteDeps
}

/**
 * Parse the project properties for the 'plugins_local_binaries' property and return
 * their binaries for inclusion in the build dependencies.
 */
ext.getGodotPluginsLocalBinaries = { ->
    Set<String> binDeps = []

    // Retrieve the list of local plugins binaries.
    if (project.hasProperty("plugins_local_binaries")) {
        String pluginsList = project.property("plugins_local_binaries")
        if (pluginsList != null && !pluginsList.trim().isEmpty()) {
            for (String plugin : pluginsList.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
                binDeps += plugin.trim()
            }
        }
    }

    return binDeps
}