commit 05c86a77fd429999580752d38b253bc0ca29af97 Author: William Bell <62452284+Ugric@users.noreply.github.com> Date: Fri Sep 26 00:58:31 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1dff0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Kotlin ### +.kotlin + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/artifacts/Buildtopia_app_main_jar.xml b/.idea/artifacts/Buildtopia_app_main_jar.xml new file mode 100644 index 0000000..38758ce --- /dev/null +++ b/.idea/artifacts/Buildtopia_app_main_jar.xml @@ -0,0 +1,32 @@ + + + $PROJECT_DIR$/out/artifacts/Buildtopia_app_main_jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml new file mode 100644 index 0000000..e6653a5 --- /dev/null +++ b/.idea/dictionaries/project.xml @@ -0,0 +1,7 @@ + + + + blocktopia + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..9d62f93 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..254a1fc --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d15a481 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ca7953 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Buildtopia + +This project uses [Gradle](https://gradle.org/). +To build and run the application, use the *Gradle* tool window by clicking the Gradle icon in the right-hand toolbar, +or run it directly from the terminal: + +* Run `./gradlew run` to build and run the application. +* Run `./gradlew build` to only build the application. +* Run `./gradlew check` to run all checks, including tests. +* Run `./gradlew clean` to clean all build outputs. + +Note the usage of the Gradle Wrapper (`./gradlew`). +This is the suggested way to use Gradle in production projects. + +[Learn more about the Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html). + +[Learn more about Gradle tasks](https://docs.gradle.org/current/userguide/command_line_interface.html#common_tasks). + +This project follows the suggested multi-module setup and consists of the `app` and `utils` subprojects. +The shared build logic was extracted to a convention plugin located in `buildSrc`. + +This project uses a version catalog (see `gradle/libs.versions.toml`) to declare and version dependencies +and both a build cache and a configuration cache (see `gradle.properties`). \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..8687fee --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + // Apply the shared build logic from a convention plugin. + // The shared code is located in `buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts`. + id("buildsrc.convention.kotlin-jvm") + + // Apply the Application plugin to add support for building an executable JVM application. + application +} + +dependencies { + // Project "app" depends on project "utils". (Project paths are separated with ":", so ":utils" refers to the top-level "utils" project.) + implementation(project(":utils")) +} + +application { + // Define the Fully Qualified Name for the application main class + // (Note that Kotlin compiles `App.kt` to a class with FQN `com.example.app.AppKt`.) + mainClass = "dev.wbell.buildtopia.app.AppKt" +} diff --git a/app/src/main/kotlin/App.kt b/app/src/main/kotlin/App.kt new file mode 100644 index 0000000..646b336 --- /dev/null +++ b/app/src/main/kotlin/App.kt @@ -0,0 +1,20 @@ +package dev.wbell.buildtopia.app + +import dev.wbell.buildtopia.utils.Printer + +//TIP To Run code, press or +// click the icon in the gutter. +fun main() { + val name = "Kotlin" + //TIP Press with your caret at the highlighted text + // to see how IntelliJ IDEA suggests fixing it. + val message = "Hello, " + name + "!" + val printer = Printer(message) + printer.printMessage() + + for (i in 1..5) { + //TIP Press to start debugging your code. We have set one breakpoint + // for you, but you can always add more by pressing . + println("i = $i") + } +} diff --git a/app/src/main/resources/META-INF/MANIFEST.MF b/app/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a802f93 --- /dev/null +++ b/app/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: dev.wbell.buildtopia.app.AppKt + diff --git a/app/src/main/resources/shaders/fragment.glsl b/app/src/main/resources/shaders/fragment.glsl new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/resources/shaders/vertex.glsl b/app/src/main/resources/shaders/vertex.glsl new file mode 100644 index 0000000..e69de29 diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..6f476b8 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + // The Kotlin DSL plugin provides a convenient way to develop convention plugins. + // Convention plugins are located in `src/main/kotlin`, with the file extension `.gradle.kts`, + // and are applied in the project's `build.gradle.kts` files as required. + `kotlin-dsl` +} + +kotlin { + jvmToolchain(21) +} + +dependencies { + // Add a dependency on the Kotlin Gradle plugin, so that convention plugins can apply it. + implementation(libs.kotlinGradlePlugin) +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..705bfb5 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,17 @@ +dependencyResolutionManagement { + + // Use Maven Central and the Gradle Plugin Portal for resolving dependencies in the shared build logic (`buildSrc`) project. + @Suppress("UnstableApiUsage") + repositories { + mavenCentral() + } + + // Reuse the version catalog from the main build. + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} + +rootProject.name = "buildSrc" \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts new file mode 100644 index 0000000..d11bbb9 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts @@ -0,0 +1,29 @@ +// The code in this file is a convention plugin - a Gradle mechanism for sharing reusable build logic. +// `buildSrc` is a Gradle-recognized directory and every plugin there will be easily available in the rest of the build. +package buildsrc.convention + +import org.gradle.api.tasks.testing.logging.TestLogEvent + +plugins { + // Apply the Kotlin JVM plugin to add support for Kotlin in JVM projects. + kotlin("jvm") +} + +kotlin { + // Use a specific Java version to make it easier to work in different environments. + jvmToolchain(21) +} + +tasks.withType().configureEach { + // Configure all test Gradle tasks to use JUnitPlatform. + useJUnitPlatform() + + // Log information about all test results, not only the failed ones. + testLogging { + events( + TestLogEvent.FAILED, + TestLogEvent.PASSED, + TestLogEvent.SKIPPED + ) + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..b06a80a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +# Enable the build cache to save time by reusing outputs produced by other successful builds. +# https://docs.gradle.org/current/userguide/build_cache.html +org.gradle.caching=true +# Enable the configuration cache to reuse the build configuration and enable parallel task execution. +# (Note that some plugins may not yet be compatible with the configuration cache.) +# https://docs.gradle.org/current/userguide/configuration_cache.html +org.gradle.configuration-cache=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..85cf925 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +# Version catalog is a central place for you to declare and version dependencies +# https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +kotlin = "2.2.10" +kotlinxDatetime = "0.6.2" +kotlinxSerializationJSON = "1.8.1" +kotlinxCoroutines = "1.10.2" + +[libraries] +kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlinxDatetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } +kotlinxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJSON" } +kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } + +# Libraries can be bundled together for easier import +[bundles] +kotlinxEcosystem = ["kotlinxDatetime", "kotlinxSerialization", "kotlinxCoroutines"] + +[plugins] +kotlinPluginSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..477cbaa --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,25 @@ +// The settings file is the entry point of every Gradle build. +// Its primary purpose is to define the subprojects. +// It is also used for some aspects of project-wide configuration, like managing plugins, dependencies, etc. +// https://docs.gradle.org/current/userguide/settings_file_basics.html + +dependencyResolutionManagement { + // Use Maven Central as the default repository (where Gradle will download dependencies) in all subprojects. + @Suppress("UnstableApiUsage") + repositories { + mavenCentral() + } +} + +plugins { + // Use the Foojay Toolchains plugin to automatically download JDKs required by subprojects. + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + +// Include the `app` and `utils` subprojects in the build. +// If there are changes in only one of the projects, Gradle will rebuild only the one that has changed. +// Learn more about structuring projects with Gradle - https://docs.gradle.org/8.7/userguide/multi_project_builds.html +include(":app") +include(":utils") + +rootProject.name = "Buildtopia" \ No newline at end of file diff --git a/utils/build.gradle.kts b/utils/build.gradle.kts new file mode 100644 index 0000000..3fb9d6d --- /dev/null +++ b/utils/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + // Apply the shared build logic from a convention plugin. + // The shared code is located in `buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts`. + id("buildsrc.convention.kotlin-jvm") + // Apply Kotlin Serialization plugin from `gradle/libs.versions.toml`. + alias(libs.plugins.kotlinPluginSerialization) +} + +dependencies { + // Apply the kotlinx bundle of dependencies from the version catalog (`gradle/libs.versions.toml`). + implementation(libs.bundles.kotlinxEcosystem) + testImplementation(kotlin("test")) +} \ No newline at end of file diff --git a/utils/src/main/kotlin/Utilities.kt b/utils/src/main/kotlin/Utilities.kt new file mode 100644 index 0000000..2c95ba0 --- /dev/null +++ b/utils/src/main/kotlin/Utilities.kt @@ -0,0 +1,17 @@ +package dev.wbell.buildtopia.utils + +import kotlinx.datetime.* +import kotlinx.serialization.Serializable +import kotlinx.coroutines.* + +@Serializable +class Printer(val message: String) { + fun printMessage() = runBlocking { + val now: Instant = Clock.System.now() + launch { + delay(1000L) + println(now.toString()) + } + println(message) + } +} \ No newline at end of file diff --git a/utils/src/test/kotlin/UtilitiesTest.kt b/utils/src/test/kotlin/UtilitiesTest.kt new file mode 100644 index 0000000..9ae29b7 --- /dev/null +++ b/utils/src/test/kotlin/UtilitiesTest.kt @@ -0,0 +1,25 @@ +package dev.wbell.buildtopia.utils + +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlinx.serialization.json.Json +import kotlinx.serialization.encodeToString +import dev.wbell.buildtopia.utils.* + +internal class PrinterTest { + + @Test + fun testMessage() { + val message = "message" + val testPrinter = Printer(message) + assertEquals(testPrinter.message, message) + } + + @Test + fun testSerialization() { + val message = "message" + val json1 = Json.encodeToString(Printer(message)) + val json2 = Json.encodeToString(Printer(message)) + assertEquals(json1, json2) + } +} \ No newline at end of file