generated from m4gr3d/GDExtension-Android-Plugin-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
138 lines (112 loc) · 3.99 KB
/
build.gradle.kts
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import com.android.build.gradle.internal.tasks.factory.dependsOn
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
// TODO: Update value to your plugin's name.
val pluginName = "ARCoreGDExtension"
// TODO: Update value to match your plugin's package name.
val pluginPackageName = "org.godotengine.plugin.android.gdextension.arcore"
/**
* Flag used to specify whether the `plugin.gdextension` config file has libraries for platforms
* other than Android and can be used by the Godot Editor
*
* TODO: Update the flag value based on your plugin's configuration
*/
val gdextensionSupportsNonAndroidPlatforms = false
android {
namespace = pluginPackageName
compileSdk = 33
buildFeatures {
buildConfig = true
}
defaultConfig {
minSdk = 21
externalNativeBuild {
cmake {
cppFlags("")
}
}
ndk {
abiFilters.add("arm64-v8a")
}
manifestPlaceholders["godotPluginName"] = pluginName
manifestPlaceholders["godotPluginPackageName"] = pluginPackageName
buildConfigField("String", "GODOT_PLUGIN_NAME", "\"${pluginName}\"")
setProperty("archivesBaseName", pluginName)
}
externalNativeBuild {
cmake {
path("CMakeLists.txt")
version = "3.22.1"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
// TODO: Update the godot dep when 4.2 is stable
implementation("org.godotengine:godot:4.2.0.dev-SNAPSHOT")
}
// BUILD TASKS DEFINITION
val cleanAssetsAddons by tasks.registering(Copy::class) {
delete("src/main/assets/addons")
}
val copyExportScriptsTemplate by tasks.registering(Copy::class) {
description = "Copies the export scripts templates to the plugin's addons directory"
dependsOn(cleanAssetsAddons)
from("export_scripts_template")
into("src/main/assets/addons/$pluginName")
}
val copyDebugAARToAddons by tasks.registering(Copy::class) {
description = "Copies the generated debug AAR binary to the plugin's addons directory"
from("build/outputs/aar")
include("$pluginName-debug.aar")
into("src/main/assets/addons/$pluginName/.bin/debug")
}
val copyReleaseAARToAddons by tasks.registering(Copy::class) {
description = "Copies the generated release AAR binary to the plugin's addons directory"
from("build/outputs/aar")
include("$pluginName-release.aar")
into("src/main/assets/addons/$pluginName/.bin/release")
}
val copyDebugSharedLibs by tasks.registering(Copy::class) {
description = "Copies the generated debug .so shared library to the plugin's addons directory"
from("build/intermediates/cmake/debug/obj")
into("src/main/assets/addons/$pluginName/.bin/debug")
}
val copyReleaseSharedLibs by tasks.registering(Copy::class) {
description = "Copies the generated release .so shared library to the plugin's addons directory"
from("build/intermediates/cmake/release/obj")
into("src/main/assets/addons/$pluginName/.bin/release")
}
val cleanDemoAddons by tasks.registering(Delete::class) {
delete("demo/addons/$pluginName")
}
val copyAddonsToDemo by tasks.registering(Copy::class) {
description = "Copies the plugin's output artifact to the output directory"
dependsOn(cleanDemoAddons)
dependsOn(copyDebugAARToAddons)
dependsOn(copyReleaseAARToAddons)
dependsOn(copyDebugSharedLibs)
dependsOn(copyReleaseSharedLibs)
from("src/main/assets/addons/$pluginName")
if (!gdextensionSupportsNonAndroidPlatforms) {
exclude("plugin.gdextension")
}
into("demo/addons/$pluginName")
}
tasks.named("preBuild").dependsOn(copyExportScriptsTemplate)
tasks.named("assemble").configure {
dependsOn(copyExportScriptsTemplate)
finalizedBy(copyAddonsToDemo)
}
tasks.named<Delete>("clean").apply {
dependsOn(cleanDemoAddons)
dependsOn(cleanAssetsAddons)
}