|
| 1 | +import net.fabricmc.loom.task.RemapJarTask |
| 2 | + |
| 3 | +plugins { |
| 4 | + id ("fabric-loom") |
| 5 | + id ("maven-publish") |
| 6 | + id ("java-library") |
| 7 | +} |
| 8 | + |
| 9 | +java { |
| 10 | + sourceCompatibility = JavaVersion.VERSION_17 |
| 11 | + targetCompatibility = JavaVersion.VERSION_17 |
| 12 | +} |
| 13 | + |
| 14 | +base { |
| 15 | + archivesName = "iCommon-Fabric" |
| 16 | + version = "1.21.9" |
| 17 | + group = "com.javazilla.mods" |
| 18 | +} |
| 19 | + |
| 20 | +dependencies { |
| 21 | + annotationProcessor("com.pkware.jabel:jabel-javac-plugin:1.0.1-1") |
| 22 | + compileOnly("com.pkware.jabel:jabel-javac-plugin:1.0.1-1") |
| 23 | + |
| 24 | + implementation(project(mapOf("path" to ":iCommon-API"))) |
| 25 | + implementation(project(mapOf("path" to ":iCommon-API"))) |
| 26 | + |
| 27 | + // 1.21.8 |
| 28 | + minecraft("com.mojang:minecraft:1.21.9") |
| 29 | + mappings("net.fabricmc:yarn:1.21.9+build.1") |
| 30 | + modImplementation("net.fabricmc:fabric-loader:" + project.property("loader_version")) |
| 31 | +} |
| 32 | + |
| 33 | +sourceSets { |
| 34 | + main { |
| 35 | + java { |
| 36 | + srcDir("src/main/java") |
| 37 | + } |
| 38 | + resources { |
| 39 | + srcDir("${rootProject.projectDir}/iCommon-API/src/main/resources") |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +// 1.20.5 now requires JDK 21 |
| 45 | +tasks.withType<JavaCompile>().configureEach { |
| 46 | + sourceCompatibility = JavaVersion.VERSION_21.toString() // for the IDE support |
| 47 | + options.release.set(16) |
| 48 | + |
| 49 | + javaCompiler.set( |
| 50 | + javaToolchains.compilerFor { |
| 51 | + languageVersion.set(JavaLanguageVersion.of(21)) |
| 52 | + } |
| 53 | + ) |
| 54 | +} |
| 55 | + |
| 56 | +//tasks.getByName("compileJava") { |
| 57 | + //sourceCompatibility = 16 |
| 58 | + //options.release = 8 |
| 59 | +//} |
| 60 | + |
| 61 | + |
| 62 | +tasks.withType<Jar> { duplicatesStrategy = DuplicatesStrategy.INHERIT } |
| 63 | + |
| 64 | +tasks.getByName<ProcessResources>("processResources") { |
| 65 | + duplicatesStrategy = DuplicatesStrategy.INCLUDE |
| 66 | + filesMatching("fabric.mod.json") { |
| 67 | + expand( |
| 68 | + mutableMapOf( |
| 69 | + "version" to "1.1" |
| 70 | + ) |
| 71 | + ) |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +val remapJar = tasks.getByName<RemapJarTask>("remapJar") |
| 76 | + |
| 77 | +publishing { |
| 78 | + publications { |
| 79 | + create<MavenPublication>("mavenJava") { |
| 80 | + groupId = project.group.toString() |
| 81 | + artifactId = project.name.lowercase() |
| 82 | + version = project.version.toString() |
| 83 | + |
| 84 | + pom { |
| 85 | + name.set(project.name.lowercase()) |
| 86 | + description.set("A concise description of my library") |
| 87 | + url.set("http://www.example.com/") |
| 88 | + } |
| 89 | + |
| 90 | + artifact(remapJar) |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + repositories { |
| 95 | + val mavenUsername: String? by project |
| 96 | + val mavenPassword: String? by project |
| 97 | + mavenPassword?.let { |
| 98 | + maven(url = "https://repo.codemc.io/repository/maven-releases/") { |
| 99 | + credentials { |
| 100 | + username = mavenUsername |
| 101 | + password = mavenPassword |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments