-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
209 lines (171 loc) · 7.03 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
209 lines (171 loc) · 7.03 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import com.unciv.build.BuildConfig.appVersion
import java.util.Properties
buildscript {
repositories {
// Chinese mirrors for quicker loading for chinese devs - uncomment if you're chinese
// maven{ url = uri("https://maven.aliyun.com/repository/central") }
// maven{ url = uri("https://maven.aliyun.com/repository/google") }
// maven{ url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
mavenCentral()
google() // needed for com.android.tools.build:gradle
maven { url = uri("https://central.sonatype.com/repository/maven-snapshots/") }
gradlePluginPortal()
}
dependencies {
classpath(libs.kotlinPlugin)
classpath(libs.agp)
}
}
// Fixes the error "Please initialize at least one Kotlin target in 'Unciv (:)'"
kotlin {
jvm()
java {
// required for building Unciv with a Java version higher than 24 (e.g. Java 25)
sourceCompatibility = JavaVersion.VERSION_21
}
}
// Plugins used for serialization of JSON for networking
plugins {
val kotlinVersion: String = libs.versions.kotlin.get()
kotlin("multiplatform") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
alias(libs.plugins.detekt)
alias(libs.plugins.purity)
}
// Kludge to get the correct string notation for a gdx native (':' _after_ version seems beyond toml)
fun gdxNatives(platform: String) = "${libs.gdx.platform.get()}:natives-$platform"
// from here on you can't simply use `libs` anymore, see https://github.com/gradle/gradle/issues/18237#issuecomment-928079890
allprojects {
// repositories { // for local purity
// mavenLocal()
// }
val purityId = rootProject.libs.plugins.purity.get().pluginId
apply(plugin = purityId)
configure<yairm210.purity.PurityConfiguration> {
wellKnownPureFunctions = setOf(
"io.ktor.http.Url", //constructor
)
wellKnownReadonlyFunctions = setOf(
"com.badlogic.gdx.math.Vector2.len",
"com.badlogic.gdx.math.Vector2.cpy",
"com.badlogic.gdx.math.Vector2.hashCode",
"com.badlogic.gdx.graphics.Color.cpy",
"com.badlogic.gdx.graphics.Color.toString",
"com.badlogic.gdx.files.FileHandle.child",
"com.badlogic.gdx.files.FileHandle.list",
"com.badlogic.gdx.files.FileHandle.exists",
"com.badlogic.gdx.files.FileHandle.isDirectory",
"com.badlogic.gdx.files.FileHandle.isFile",
"com.badlogic.gdx.files.FileHandle.name",
"com.badlogic.gdx.utils.IntArray.get",
"io.ktor.http.Url.segments",
"io.ktor.http.Url.parameters",
"io.ktor.http.Parameters.get",
"java.util.BitSet.clone",
)
wellKnownPureClasses = setOf(
)
wellKnownInternalStateClasses = setOf(
"com.badlogic.gdx.math.Vector2",
)
warnOnPossibleAnnotations = false
}
apply(plugin = "eclipse")
apply(plugin = "idea")
version = appVersion
repositories {
// Chinese mirrors for quicker loading for chinese devs - uncomment if you're chinese
// maven{ url = uri("https://maven.aliyun.com/repository/central") }
// maven{ url = uri("https://maven.aliyun.com/repository/google") }
mavenCentral()
google()
// Needed only in case a version with a "-SNAPSHOT" qualifier is requested
maven { url = uri("https://central.sonatype.com/repository/maven-snapshots/") }
// Activate only when Central is down, or you need a super-fresh release (typically a matter of hours at most)
// maven { url = uri("https://central.sonatype.com/repository/maven-releases/") }
maven { url = uri("https://jitpack.io") } // for java-discord-rpc
}
}
project(":desktop") {
apply(plugin = "kotlin")
dependencies {
"implementation"(project(":core"))
"implementation"(rootProject.libs.coroutines.core)
"implementation"(rootProject.libs.gdx.backend.desktop)
"implementation"(gdxNatives("desktop"))
"implementation"(rootProject.libs.gdx.tools) {
exclude("com.badlogicgames.gdx", "gdx-backend-lwjgl")
}
// Needed to display "Playing Unciv" in Discord
"implementation"(rootProject.libs.discord)
// Needed for Windows turn notifiers
"api"(rootProject.libs.bundles.jna)
}
}
// For server-side
project(":server") {
apply(plugin = "kotlin")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
dependencies {
// For server-side
"api"(rootProject.libs.bundles.ktor.server)
"implementation"(rootProject.libs.logback)
"implementation"(rootProject.libs.clikt)
// clikt somehow needs this
"api"(rootProject.libs.bundles.jna)
}
}
private fun getSdkPath(): String? {
// See #13566 - Android Studio has moved its primary method to store where to find its SDK
val localProperties = project.file("local.properties")
return if (localProperties.exists()) {
val properties = Properties()
localProperties.inputStream().use { properties.load(it) }
properties.getProperty("sdk.dir") ?: System.getenv("ANDROID_HOME")
} else {
System.getenv("ANDROID_HOME")
}
}
if (getSdkPath() != null) {
project(":android") {
apply(plugin = "com.android.application")
val natives by configurations.creating
dependencies {
"implementation"(project(":core"))
// Not sure why I had to add this in for the upgrade to 1.12.1 to work, we can probably remove this later since it's contained in core
"implementation"(rootProject.libs.gdx)
"implementation"(rootProject.libs.gdx.backend.android)
"implementation"(rootProject.libs.coroutines.android)
natives(gdxNatives("armeabi-v7a"))
natives(gdxNatives("arm64-v8a"))
natives(gdxNatives("x86"))
natives(gdxNatives("x86_64"))
}
}
}
project(":core") {
apply(plugin = "kotlin")
// Serialization features (especially JSON for multiplayer apiV2)
apply(plugin = "kotlinx-serialization")
dependencies {
"implementation"(rootProject.libs.gdx)
"implementation"(rootProject.libs.coroutines.core)
"implementation"(rootProject.libs.kotlin.reflect)
"implementation"(rootProject.libs.purity.annotations)
"api"(rootProject.libs.bundles.ktor.client)
}
// Taken from https://github.com/TomGrill/gdx-testing
project(":tests") {
apply(plugin = "java")
apply(plugin = "kotlin")
dependencies {
"implementation"(project(":core"))
"implementation"(rootProject.libs.coroutines.core)
"implementation"(rootProject.libs.kotlin.reflect)
"implementation"(rootProject.libs.gdx)
"implementation"(rootProject.libs.gdx.backend.headless)
"implementation"(rootProject.libs.gdx.backend.desktop)
"implementation"(gdxNatives("desktop"))
}
}
}