|
| 1 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 2 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 3 | + |
| 4 | +plugins { |
| 5 | + kotlin("jvm") version "2.2.20" |
| 6 | + id("fabric-loom") version "1.11-SNAPSHOT" |
| 7 | + id("maven-publish") |
| 8 | +} |
| 9 | + |
| 10 | +version = project.property("mod_version") as String |
| 11 | +group = project.property("maven_group") as String |
| 12 | + |
| 13 | +base { |
| 14 | + archivesName.set(project.property("archives_base_name") as String) |
| 15 | +} |
| 16 | + |
| 17 | +val targetJavaVersion = 21 |
| 18 | +java { |
| 19 | + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) |
| 20 | + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task |
| 21 | + // if it is present. |
| 22 | + // If you remove this line, sources will not be generated. |
| 23 | + withSourcesJar() |
| 24 | +} |
| 25 | + |
| 26 | +loom { |
| 27 | + splitEnvironmentSourceSets() |
| 28 | + |
| 29 | + mods { |
| 30 | + register("simplefabricscoreboard") { |
| 31 | + sourceSet("main") |
| 32 | + sourceSet("client") |
| 33 | + } |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +fabricApi { |
| 38 | + configureDataGeneration { |
| 39 | + client = true |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +repositories { |
| 44 | + // Add repositories to retrieve artifacts from in here. |
| 45 | + // You should only use this when depending on other mods because |
| 46 | + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. |
| 47 | + // See https://docs.gradle.org/current/userguide/declaring_repositories.html |
| 48 | + // for more information about repositories. |
| 49 | +} |
| 50 | + |
| 51 | +dependencies { |
| 52 | + // To change the versions see the gradle.properties file |
| 53 | + minecraft("com.mojang:minecraft:${project.property("minecraft_version")}") |
| 54 | + mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2") |
| 55 | + modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}") |
| 56 | + modImplementation("net.fabricmc:fabric-language-kotlin:${project.property("kotlin_loader_version")}") |
| 57 | + |
| 58 | + modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}") |
| 59 | +} |
| 60 | + |
| 61 | +tasks.processResources { |
| 62 | + inputs.property("version", project.version) |
| 63 | + inputs.property("minecraft_version", project.property("minecraft_version")) |
| 64 | + inputs.property("loader_version", project.property("loader_version")) |
| 65 | + filteringCharset = "UTF-8" |
| 66 | + |
| 67 | + filesMatching("fabric.mod.json") { |
| 68 | + expand( |
| 69 | + "version" to project.version, |
| 70 | + "minecraft_version" to project.property("minecraft_version"), |
| 71 | + "loader_version" to project.property("loader_version"), |
| 72 | + "kotlin_loader_version" to project.property("kotlin_loader_version") |
| 73 | + ) |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +tasks.withType<JavaCompile>().configureEach { |
| 78 | + // ensure that the encoding is set to UTF-8, no matter what the system default is |
| 79 | + // this fixes some edge cases with special characters not displaying correctly |
| 80 | + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html |
| 81 | + // If Javadoc is generated, this must be specified in that task too. |
| 82 | + options.encoding = "UTF-8" |
| 83 | + options.release.set(targetJavaVersion) |
| 84 | +} |
| 85 | + |
| 86 | +tasks.withType<KotlinCompile>().configureEach { |
| 87 | + compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString())) |
| 88 | +} |
| 89 | + |
| 90 | +tasks.jar { |
| 91 | + from("LICENSE") { |
| 92 | + rename { "${it}_${project.base.archivesName}" } |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +// configure the maven publication |
| 97 | +publishing { |
| 98 | + publications { |
| 99 | + create<MavenPublication>("mavenJava") { |
| 100 | + from(components["java"]) |
| 101 | + |
| 102 | + groupId = group.toString() |
| 103 | + artifactId = "simplefabricscoreboard" // <-- dein Artefaktname |
| 104 | + version = version.toString() |
| 105 | + |
| 106 | + pom { |
| 107 | + name.set("Simple Fabric Scoreboard") |
| 108 | + description.set("Eine Beispiel-Bibliothek mit Gradle Kotlin DSL und Maven Publish") |
| 109 | + url.set("https://github.com/hotkeyyy/simplefabricscoreboard") |
| 110 | + |
| 111 | + licenses { |
| 112 | + license { |
| 113 | + name.set("MIT License") |
| 114 | + url.set("https://opensource.org/licenses/MIT") |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + developers { |
| 119 | + developer { |
| 120 | + id.set("hotkeyyy") |
| 121 | + name.set("Hotkeyyy") |
| 122 | + email.set("hotkeyyyde@gmail.com") |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + scm { |
| 127 | + connection.set("scm:git:git://github.com/hotkeyyy/simplefabricscoreboard.git") |
| 128 | + developerConnection.set("scm:git:ssh://github.com/hotkeyyy/simplefabricscoreboard.git") |
| 129 | + url.set("https://github.com/hotkeyyy/simplefabricscoreboard") |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + repositories { |
| 136 | + // 🧪 Lokales Repository (z. B. zum Testen) |
| 137 | + mavenLocal() |
| 138 | + |
| 139 | + // 📦 GitHub Packages (optional) |
| 140 | +// maven { |
| 141 | +// name = "GitHubPackages" |
| 142 | +// url = uri("https://maven.pkg.github.com/deinname/meine-bibliothek") |
| 143 | +// |
| 144 | +// credentials { |
| 145 | +// username = findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") |
| 146 | +// password = findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") |
| 147 | +// } |
| 148 | +// } |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | + |
0 commit comments