Skip to content

Commit ca59a7a

Browse files
authored
Implement project template (#1)
* Initial commit * Updated README * Updated README * Updated build.gradle script to latest * Added IntelliJ entried to .gitignore * Explain why we need the runBuild scripts
1 parent d842d3b commit ca59a7a

13 files changed

Lines changed: 492 additions & 10 deletions

File tree

.gdignore

Whitespace-only changes.

.gitignore

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1+
### Gradle ###
12
.gradle
2-
/build/
3+
build/
4+
!gradle-wrapper.jar
35

4-
# Ignore Gradle GUI config
5-
gradle-app.setting
6+
### Intellij ###
7+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
8+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
69

7-
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
8-
!gradle-wrapper.jar
10+
# User-specific stuff
11+
.idea/**/workspace.xml
12+
.idea/**/tasks.xml
13+
.idea/**/usage.statistics.xml
14+
.idea/**/dictionaries
15+
.idea/**/shelf
16+
17+
# Generated files
18+
.idea/**/contentModel.xml
919

10-
# Cache of project
11-
.gradletasknamecache
20+
# Sensitive or high-churn files
21+
.idea/**/dataSources/
22+
.idea/**/dataSources.ids
23+
.idea/**/dataSources.local.xml
24+
.idea/**/sqlDataSources.xml
25+
.idea/**/dynamic.xml
26+
.idea/**/uiDesigner.xml
27+
.idea/**/dbnavigator.xml
1228

13-
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
14-
# gradle/wrapper/gradle-wrapper.properties
29+
# Gradle
30+
.idea/**/gradle.xml
31+
.idea/**/libraries

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# godot-kotlin-project-template
1+
# godot-kotlin-project-template
2+
3+
This is the directory structure and build scripts for the standard Godot/Kotlin project.
4+
5+
## How to use
6+
The contents of this directory should be placed under your Godot project's root directory:
7+
```
8+
<Godot Project>/
9+
- project.godot
10+
- kotlin/ <- This is the directory that contains the contents of this repository
11+
```
12+
13+
Alternatively you can use the `Godot/Kotlin Editor Plugin` which will automatically setup your projects for you by downloading this repository and doing various other tasks.
14+
15+
16+
## End User notes:
17+
The `Godot/Kotlin Editor Plugin` maintains a black list of files that are not important to end user projects. Examples include: `README.md` and `LICENSE`. These will be excluded automatically during setup by the plugin.
18+
19+
If using this repository directly to setup your project, you can safely exclude those files as well if you wish.
20+
21+
## Godot/Kotlin development notes
22+
This repository should be tagged for release, as the `Godot/Kotlin Editor Plugin` will download the source bundles from here when setting up new projects.

build.gradle.kts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
val platform: String by project
2+
val armArch: String by project
3+
val iosSigningIdentity: String by project
4+
val buildType: String? by project
5+
6+
buildscript {
7+
repositories {
8+
mavenLocal()
9+
maven("https://dl.bintray.com/utopia-rise/kotlin-godot")
10+
jcenter()
11+
mavenCentral()
12+
}
13+
dependencies {
14+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61")
15+
classpath("org.godotengine.kotlin:godot-gradle-plugin:0.1.0-3.2")
16+
}
17+
}
18+
19+
repositories {
20+
mavenLocal()
21+
maven("https://dl.bintray.com/utopia-rise/kotlin-godot")
22+
maven(url = "https://dl.bintray.com/utopia-rise/kotlinx")
23+
24+
//Here we exclude jetbrains coroutines and atomicfu because they do not provide the ones for android platform
25+
//so we exclude them so that those dependencies are downloaded from our bintray, where we provide android dependencies
26+
jcenter {
27+
content {
28+
excludeModule("org.jetbrains.kotlinx", "kotlinx-coroutines-core-native")
29+
excludeModule("org.jetbrains.kotlinx", "atomicfu-native")
30+
}
31+
}
32+
mavenCentral {
33+
content {
34+
excludeModule("org.jetbrains.kotlinx", "kotlinx-coroutines-core-native")
35+
excludeModule("org.jetbrains.kotlinx", "atomicfu-native")
36+
}
37+
}
38+
}
39+
40+
plugins {
41+
id("org.jetbrains.kotlin.multiplatform") version ("1.3.61")
42+
}
43+
44+
apply(plugin = "godot-gradle-plugin")
45+
46+
configure<org.godotengine.kotlin.gradleplugin.KotlinGodotPluginExtension> {
47+
this.releaseType = if (buildType?.toLowerCase() == "release") {
48+
org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE
49+
} else {
50+
org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
51+
}
52+
this.godotProjectPath = "${project.rootDir.absolutePath}/.."
53+
this.libraryPath = "kotlin.gdnlib"
54+
this.configureTargetAction = ::configureTargetAction
55+
}
56+
57+
kotlin {
58+
sourceSets {
59+
sourceSets.create("macosMain")
60+
sourceSets.create("linuxMain")
61+
sourceSets.create("windowsMain")
62+
sourceSets.create("androidArm64Main")
63+
sourceSets.create("androidX64Main")
64+
sourceSets.create("iosArm64Main")
65+
sourceSets.create("iosX64Main")
66+
configure(listOf(
67+
sourceSets["macosMain"],
68+
sourceSets["linuxMain"],
69+
sourceSets["windowsMain"],
70+
sourceSets["androidArm64Main"],
71+
sourceSets["androidX64Main"],
72+
sourceSets["iosArm64Main"],
73+
sourceSets["iosX64Main"]
74+
)) {
75+
this.kotlin.srcDir("src/main/kotlin")
76+
}
77+
}
78+
79+
if (project.hasProperty("platform")) {
80+
when (platform) {
81+
"windows" -> listOf(targetFromPreset(presets["godotMingwX64"], "windows"))
82+
"linux" -> listOf(targetFromPreset(presets["godotLinuxX64"], "linux"))
83+
"macos" -> listOf(targetFromPreset(presets["godotMacosX64"], "macos"))
84+
"android" -> if (project.hasProperty("armArch")) {
85+
when(armArch) {
86+
"X64" -> listOf(targetFromPreset(presets["godotAndroidNativeX64"], "androidX64"))
87+
"arm64" -> listOf(targetFromPreset(presets["godotAndroidNativeArm64"], "androidArm64"))
88+
else -> listOf(targetFromPreset(presets["godotAndroidNativeArm64"], "androidArm64"))
89+
}
90+
} else listOf(targetFromPreset(presets["godotAndroidNativeArm64"], "androidArm64"))
91+
"ios" -> if (project.hasProperty("armArch")) {
92+
when (armArch) {
93+
"arm64" -> listOf(targetFromPreset(presets["godotIosArm64"], "iosArm64"))
94+
"X64" -> listOf(targetFromPreset(presets["godotIosX64"], "iosX64"))
95+
else -> listOf(targetFromPreset(presets["godotIosArm64"], "iosArm64"))
96+
}
97+
} else listOf(targetFromPreset(presets["godotIosArm64"], "iosArm64"))
98+
else -> listOf(targetFromPreset(presets["godotLinuxX64"], "linux"))
99+
}
100+
} else {
101+
listOf(
102+
targetFromPreset(presets["godotLinuxX64"], "linux"),
103+
targetFromPreset(presets["godotMacosX64"], "macos"),
104+
targetFromPreset(presets["godotMingwX64"], "windows"),
105+
targetFromPreset(presets["godotAndroidNativeArm64"], "androidArm64"),
106+
targetFromPreset(presets["godotAndroidNativeX64"], "androidX64"),
107+
targetFromPreset(presets["godotIosArm64"], "iosArm64"),
108+
targetFromPreset(presets["godotIosX64"], "iosX64")
109+
)
110+
}
111+
}
112+
113+
fun configureTargetAction(kotlinTarget: @ParameterName(name = "target") org.jetbrains.kotlin.gradle.plugin.KotlinTarget) {
114+
kotlinTarget.compilations.getByName("main") {
115+
if (this is org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation) {
116+
println("Configuring target ${this.target.name}")
117+
this.target.compilations.all {
118+
dependencies {
119+
implementation("org.godotengine.kotlin:godot-library-extension:0.1.0-3.2")
120+
implementation("org.godotengine.kotlin:annotations:0.1.0-3.2")
121+
}
122+
}
123+
if (project.hasProperty("iosSigningIdentity") && this.target.name == "iosArm64") {
124+
tasks.build {
125+
doLast {
126+
exec {
127+
commandLine = listOf("codesign", "-f", "-s", iosSigningIdentity, "build/bin/iosArm64/releaseShared/libkotlin.dylib")
128+
}
129+
exec {
130+
commandLine = listOf("install_name_tool", "-id", "@executable_path/dylibs/ios/libkotlin.dylib", "build/bin/iosArm64/releaseShared/libkotlin.dylib")
131+
}
132+
}
133+
}
134+
} else if (project.hasProperty("iosSigningIdentity") && this.target.name == "iosX64") {
135+
tasks.build {
136+
doLast {
137+
exec {
138+
commandLine = listOf("codesign", "-f", "-s", iosSigningIdentity, "build/bin/iosX64/releaseShared/libkotlin.dylib")
139+
}
140+
exec {
141+
commandLine = listOf("install_name_tool", "-id", "@executable_path/dylibs/ios/libkotlin.dylib", "build/bin/iosX64/releaseShared/libkotlin.dylib")
142+
}
143+
}
144+
}
145+
}
146+
} else {
147+
System.err.println("Not a native target! TargetName: ${kotlinTarget.name}")
148+
}
149+
}
150+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
buildType=debug

gradle/wrapper/gradle-wrapper.jar

54.3 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

0 commit comments

Comments
 (0)