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-04-25 13:23:06 +02:00
id 'fabric-loom' version '1.6-SNAPSHOT'
2024-02-08 20:36:03 +01:00
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 {
2024-07-22 18:54:46 +02:00
accessWidenerPath = file ( "src/main/resources/reframed.accesswidener" )
2024-02-08 20:36:03 +01:00
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-06-12 00:13:38 +02:00
maven {
url = "https://jitpack.io"
}
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-05-14 15:27:34 +02:00
// Athena for connected textures
2024-02-26 16:28:02 +01:00
modCompileOnly "earth.terrarium.athena:athena-fabric-${project.minecraft_version}:${project.athena_version}"
modRuntimeOnly "earth.terrarium.athena:athena-fabric-${project.minecraft_version}:${project.athena_version}"
2024-05-14 15:27:34 +02:00
// Continuity for connected textures
2024-03-25 15:22:28 +01:00
modCompileOnly "maven.modrinth:continuity:${project.continuity_version}"
modRuntimeOnly "maven.modrinth:continuity:${project.continuity_version}"
2024-02-26 16:28:02 +01:00
// 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-05-23 12:33:54 +02:00
// Axiom for blueprint support
2024-06-14 00:35:13 +02:00
modCompileOnly "maven.modrinth:N6n5dqoA:YxeYxQyz"
2024-06-12 00:13:38 +02:00
modCompileOnly "com.github.moulberry:AxiomClientAPI:1.0.5.3"
2024-05-23 12:33:54 +02:00
2024-03-25 16:27:58 +01:00
// Fabric API.
2024-02-08 20:36:03 +01:00
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-03-25 15:22:28 +01:00
inputs . property "continuity_version" , project . continuity_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
2024-05-14 15:27:34 +02:00
versionNumber = "${project.mod_version}-${project.minecraft_version}"
versionName = "${project.archives_base_name} ${project.mod_version}-${project.minecraft_version}"
2024-03-03 19:33:25 +01:00
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-03-25 17:12:05 +01:00
optional . version "1IjD5062" , "${project.continuity_version}"
2024-03-03 19:33:25 +01:00
}
}
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