2024-02-16 21:34:21 +01:00
import fr.altarik.ReportDiscord
import fr.altarik.CreateTag
2024-02-08 20:36:03 +01:00
plugins {
2024-03-03 19:33:25 +01:00
id "com.modrinth.minotaur" version "2.+"
2024-02-08 20:36:03 +01:00
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}
2024-02-16 21:34:21 +01:00
Properties local = new Properties ( )
try {
local . load ( new FileInputStream ( rootProject . file ( "local.properties" ) ) )
} catch ( IOException ignored ) { }
2024-02-08 20:36:03 +01:00
version = project . mod_version
group = project . maven_group
2024-02-16 21:34:21 +01:00
String webhookId = getEnv ( "DISCORD_PUB_ID" , local . getProperty ( "discord_pub_id" ) )
String webhookToken = getEnv ( "DISCORD_PUB_TOKEN" , local . getProperty ( "discord_pub_token" ) )
String repoUrl = "https://repo.altarik.fr/#/" + ( project . version . endsWith ( 'SNAPSHOT' ) ? 'snapshots/' : 'releases/' ) + project . group . replace ( "." , "/" ) + "/" + project . rootProject . name + "/" + project . version
var reportConfig = new ReportDiscord . ReportData ( "https://discord.com/api/" , webhookId , webhookToken , project . rootProject . name , "Update " + project . version + " has been published" , repoUrl )
String giteaToken = getEnv ( "GITEA_TOKEN" , local . getProperty ( "gitea_token" ) )
var releaseConfig = new CreateTag . CreateReleaseData ( "https://git.altarik.fr" , project . git_owner , project . git_repo , "v" + project . version as String , giteaToken )
2024-02-08 20:36:03 +01:00
base {
archivesName = project . archives_base_name
}
sourceSets {
main {
resources {
srcDirs + = {
'src/generated'
2023-06-15 07:39:17 +02:00
}
2019-06-18 11:33:36 +02:00
}
}
}
2024-02-08 20:36:03 +01:00
loom {
runs {
// This adds a new gradle task that runs the datagen API: "gradlew runDatagen"
datagen {
inherit server
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file(" src / generated ")}"
vmArg "-Dfabric-api.datagen.modid=${mod_id}"
2019-06-18 11:33:36 +02:00
2024-02-08 20:36:03 +01:00
runDir "build/datagen"
}
}
2023-06-15 07:39:17 +02:00
}
2019-06-18 11:33:36 +02:00
repositories {
2024-02-16 21:34:21 +01:00
maven {
name 'altarik-snapshots'
url 'https://repo.altarik.fr/snapshots/'
}
maven {
name 'altarik-releases'
url 'https://repo.altarik.fr/releases/'
}
2024-02-26 16:28:02 +01:00
maven {
url "https://maven.teamresourceful.com/repository/maven-public/"
}
maven {
url "https://maven.resourcefulbees.com/repository/maven-public/"
}
2024-03-03 17:43:53 +01:00
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
2024-02-16 21:34:21 +01:00
mavenCentral ( )
2024-02-08 20:36:03 +01:00
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
2019-06-18 11:33:36 +02:00
}
dependencies {
2024-02-08 20:36:03 +01:00
// To change the versions see the gradle.properties file
2024-02-15 23:16:17 +01:00
include ( implementation ( annotationProcessor ( "io.github.llamalad7:mixinextras-fabric:0.2.2" ) ) )
2024-02-08 20:36:03 +01:00
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
2019-06-18 11:33:36 +02:00
2024-03-03 17:43:53 +01:00
// Indium and sodium for sodium support
modCompileOnly "maven.modrinth:indium:${project.indium_version}+mc${project.minecraft_version}"
modCompileOnly "maven.modrinth:sodium:mc${project.minecraft_version}-${project.sodium_version}"
2024-03-03 19:33:25 +01:00
// modRuntimeOnly "maven.modrinth:indium:${project.indium_version}+mc${project.minecraft_version}"
// modRuntimeOnly "maven.modrinth:sodium:mc${project.minecraft_version}-${project.sodium_version}"
2024-03-03 17:43:53 +01:00
2024-02-26 16:28:02 +01:00
// Athena for connected texture
modCompileOnly "earth.terrarium.athena:athena-fabric-${project.minecraft_version}:${project.athena_version}"
modRuntimeOnly "earth.terrarium.athena:athena-fabric-${project.minecraft_version}:${project.athena_version}"
// Chipped to test athena implementation
2024-02-28 21:21:28 +01:00
modRuntimeOnly "com.teamresourceful.resourcefullib:resourcefullib-fabric-${project.minecraft_version}:2.4.7"
modRuntimeOnly "earth.terrarium.chipped:Chipped-fabric-${project.minecraft_version}:3.1.2"
2024-02-26 16:28:02 +01:00
2024-02-08 20:36:03 +01:00
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
2023-07-21 02:33:51 +02:00
2024-02-08 20:36:03 +01:00
processResources {
inputs . property "version" , project . version
inputs . property "minecraft_version" , project . minecraft_version
inputs . property "loader_version" , project . loader_version
2024-02-16 21:42:26 +01:00
inputs . property "mod_id" , project . mod_id
2024-02-26 16:28:02 +01:00
inputs . property "athena_version" , project . athena_version
2024-03-03 17:43:53 +01:00
inputs . property "indium_version" , project . indium_version
inputs . property "sodium_version" , project . sodium_version
2024-02-08 20:36:03 +01:00
filteringCharset "UTF-8"
filesMatching ( "fabric.mod.json" ) {
2024-02-16 21:34:21 +01:00
expand inputs . properties
2024-02-08 20:36:03 +01:00
}
2019-06-18 11:33:36 +02:00
}
2024-02-08 20:36:03 +01:00
def targetJavaVersion = 17
tasks . withType ( JavaCompile ) . configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it . options . encoding = "UTF-8"
if ( targetJavaVersion > = 10 | | JavaVersion . current ( ) . isJava10Compatible ( ) ) {
it . options . release . set ( targetJavaVersion )
2023-07-11 10:16:48 +02:00
}
}
2024-02-08 20:36:03 +01:00
java {
2024-02-16 21:34:21 +01:00
sourceCompatibility = JavaVersion . VERSION_17
targetCompatibility = JavaVersion . VERSION_17
2024-02-08 20:36:03 +01:00
def javaVersion = JavaVersion . toVersion ( targetJavaVersion )
if ( JavaVersion . current ( ) < javaVersion ) {
toolchain . languageVersion = JavaLanguageVersion . of ( targetJavaVersion )
2019-06-18 11:33:36 +02:00
}
2024-02-08 20:36:03 +01:00
// 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 ( )
2019-06-18 11:33:36 +02:00
}
jar {
2024-02-08 20:36:03 +01:00
from ( "LICENSE" ) {
rename { "${it}_${project.archivesBaseName}" }
}
}
// configure the maven publication
publishing {
publications {
mavenJava ( MavenPublication ) {
from components . java
}
}
// 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.
2024-02-16 21:34:21 +01:00
maven {
name 'altarik'
url 'https://repo.altarik.fr/' . concat ( project . version . endsWith ( 'SNAPSHOT' ) ? 'snapshots/' : 'releases/' )
credentials {
username = getEnv ( "REPO_USERNAME" , local . getProperty ( "repo_username" ) )
password = getEnv ( "REPO_PASSWORD" , local . getProperty ( "repo_password" ) )
}
}
}
}
2024-03-03 19:33:25 +01:00
// configure modrinth publication
modrinth {
token = getEnv ( "MODRINTH_TOKEN" , local . getProperty ( "modrinth_token" ) )
projectId = project . modrinth_id
versionNumber = project . mod_version
versionName = "${project.archives_base_name} ${project.mod_version}"
versionType = project . mod_version . endsWith ( 'SNAPSHOT' ) ? 'beta' : 'release'
uploadFile = remapJar
gameVersions = [ project . minecraft_version ]
loaders = [ "fabric" ]
dependencies {
required . project "fabric-api"
optional . version "b1ZV3DIJ" , "${project.athena_version}"
optional . version "Orvt0mRa" , "${project.indium_version}+mc${project.minecraft_version}"
}
}
2024-02-16 21:34:21 +01:00
tasks . register ( "reportToDiscord" , ReportDiscord ) {
config . set ( reportConfig )
}
tasks . register ( "createTag" , CreateTag ) {
config . set ( releaseConfig )
}
static def getEnv ( String envName , String defaultValue ) {
String r = System . getenv ( envName )
if ( r ! = null ) {
return r
} else {
return defaultValue
2024-02-08 20:36:03 +01:00
}
2019-06-18 11:33:36 +02:00
}
2024-02-16 21:34:21 +01:00