Skip to content

Commit

Permalink
fix: small improvements to gradle buildscript
Browse files Browse the repository at this point in the history
this notably fixes all deprecation warnings, and just reorganizes the file to be more
"up-to-date" and define stuff the recommended way (most stuff is taken from fabric's mod template)

also removes the unused maven publishing plugin :D
  • Loading branch information
uku3lig committed May 15, 2024
1 parent d4c89c7 commit 8c9dbb8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 48 deletions.
74 changes: 27 additions & 47 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,73 +1,53 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id 'fabric-loom' version '1.6-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = "${project.mod_id}-fabric"
version = "${project.minecraft_version}-${project.mod_version}"
group = project.maven_group

repositories {
maven { url "https://maven.terraformersmc.com" }
maven { url "https://maven.terraformersmc.com" }
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
}

processResources {
inputs.property "version", project.version
inputs.property "version", project.version
filteringCharset "UTF-8"

filesMatching("fabric.mod.json") {
expand "version": project.version
}
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 21

base {
archivesName = "${project.mod_id}-fabric"
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
withSourcesJar()
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down

0 comments on commit 8c9dbb8

Please sign in to comment.