1
+ import net.darkhax.curseforgegradle.TaskPublishCurseForge
2
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
+ plugins {
5
+ id(" fabric-loom" )
6
+ kotlin(" jvm" )
7
+ id(" com.modrinth.minotaur" )
8
+ id(" net.darkhax.curseforgegradle" )
9
+ id(" co.uzzu.dotenv.gradle" )
10
+ }
11
+ base.archivesName = project.extra[" archives_base_name" ] as String
12
+ version = project.extra[" mod_version" ] as String
13
+ group = project.extra[" maven_group" ] as String
14
+ dependencies {
15
+ minecraft(" com.mojang" , " minecraft" , project.extra[" minecraft_version" ] as String )
16
+ mappings(" net.fabricmc" , " yarn" , project.extra[" yarn_mappings" ] as String , null , " v2" )
17
+ modImplementation(" net.fabricmc" , " fabric-loader" , project.extra[" loader_version" ] as String )
18
+ modImplementation(" net.fabricmc.fabric-api" , " fabric-api" , project.extra[" fabric_version" ] as String )
19
+ modImplementation(" net.fabricmc" , " fabric-language-kotlin" , project.extra[" fabric_language_kotlin_version" ] as String )
20
+ }
21
+ tasks {
22
+ val javaVersion = JavaVersion .toVersion((project.extra[" java_version" ] as String ).toInt())
23
+ withType<JavaCompile >().configureEach {
24
+ options.encoding = " UTF-8"
25
+ sourceCompatibility = javaVersion.toString()
26
+ targetCompatibility = javaVersion.toString()
27
+ options.release = javaVersion.toString().toInt()
28
+ }
29
+ withType<JavaExec >().configureEach { defaultCharacterEncoding = " UTF-8" }
30
+ withType<Javadoc >().configureEach { options.encoding = " UTF-8" }
31
+ withType<Test >().configureEach { defaultCharacterEncoding = " UTF-8" }
32
+ withType<KotlinCompile >().configureEach {
33
+ compilerOptions {
34
+ extraWarnings = true
35
+ jvmTarget = JvmTarget .valueOf(" JVM_$javaVersion " )
36
+ }
37
+ }
38
+ jar { from(" LICENSE" ) { rename { " ${it} _${base.archivesName.get()} " } } }
39
+ processResources {
40
+ filesMatching(" fabric.mod.json" ) { expand(mutableMapOf (" version" to project.extra[" mod_version" ] as String , " fabricloader" to project.extra[" loader_version" ] as String , " fabric_api" to project.extra[" fabric_version" ] as String , " fabric_language_kotlin" to project.extra[" fabric_language_kotlin_version" ] as String , " minecraft" to project.extra[" minecraft_version" ] as String , " java" to project.extra[" java_version" ] as String )) }
41
+ filesMatching(" *.mixins.json" ) { expand(mutableMapOf (" java" to project.extra[" java_version" ] as String )) }
42
+ }
43
+ java {
44
+ toolchain.languageVersion = JavaLanguageVersion .of(javaVersion.toString())
45
+ sourceCompatibility = javaVersion
46
+ targetCompatibility = javaVersion
47
+ withSourcesJar()
48
+ }
49
+ register<TaskPublishCurseForge >(" publishCurseForge" ) {
50
+ disableVersionDetection()
51
+ apiToken = env.fetch(" CURSEFORGE_TOKEN" , " " )
52
+ val file = upload(" Replace this with the CurseForge project ID as an Integer" , remapJar)
53
+ file.displayName = " [${project.extra[" minecraft_version" ] as String } ] Mod Name"
54
+ file.addEnvironment(" Client" , " Server" )
55
+ file.changelog = " "
56
+ file.releaseType = " release"
57
+ file.addModLoader(" Fabric" )
58
+ file.addGameVersion(project.extra[" minecraft_version" ] as String )
59
+ }
60
+ }
61
+ modrinth {
62
+ token.set(env.fetch(" MODRINTH_TOKEN" , " " ))
63
+ projectId.set(" Replace this with the slug to the Modrinth mod page" )
64
+ uploadFile.set(tasks.remapJar)
65
+ gameVersions.addAll(project.extra[" minecraft_version" ] as String )
66
+ versionName.set(" [${project.extra[" minecraft_version" ] as String } ] Mod Name" )
67
+ dependencies { required.project(" fabric-api" , " fabric-language-kotlin" ) }
68
+ }
0 commit comments