Toolbox/build.gradle

135 lines
4.3 KiB
Groovy
Raw Normal View History

import fr.altarik.ReportDiscord
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' apply false
}
Properties local = new Properties()
2023-07-20 19:17:19 +02:00
try {
local.load(new FileInputStream(rootProject.file("local.properties")))
} catch (IOException ignored) {}
group = project.maven_group
version = project.maven_version
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
2023-07-26 23:33:01 +02:00
var reportConfig = new ReportDiscord.ReportData("https://discord.com/api/", webhookId, webhookToken, project.rootProject.name, "Update " + project.version + " has been published", repoUrl);
allprojects {
apply plugin: 'maven-publish'
2023-03-19 19:38:08 +01:00
apply plugin: 'fabric-loom'
group = project.maven_group
version = project.maven_version
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
maven {
name 'altarik-snapshots'
url 'https://repo.altarik.fr/snapshots/'
}
maven {
name 'altarik-releases'
url 'https://repo.altarik.fr/releases/'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
name 'altarik'
url 'https://repo.altarik.fr/'.concat(project.version.endsWith('SNAPSHOT') ? 'snapshots/' : 'releases/')
credentials {
2023-07-20 19:17:19 +02:00
username = getEnv("REPO_USERNAME", local.getProperty("repo_username"))
password = getEnv("REPO_PASSWORD", local.getProperty("repo_password"))
}
}
2022-09-19 23:52:14 +02:00
}
}
2023-03-19 19:38:08 +01:00
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
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"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}"
2023-03-19 19:38:08 +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}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
java {
withSourcesJar()
withJavadocJar()
}
test {
useJUnitPlatform()
}
}
2023-03-19 19:38:08 +01:00
dependencies {
include subprojects.collect { project -> project }
implementation subprojects.collect { project -> project }
2023-03-19 19:38:08 +01:00
}
2023-07-20 19:17:19 +02:00
static def getEnv(String envName, String defaultValue) {
2023-07-20 19:17:58 +02:00
String r = System.getenv(envName)
2023-07-20 19:17:19 +02:00
if(r != null) {
2023-07-20 19:17:58 +02:00
return r
2023-07-20 19:17:19 +02:00
} else {
2023-07-20 19:17:58 +02:00
return defaultValue
2023-07-20 19:17:19 +02:00
}
}
tasks.register("reportToDiscord", ReportDiscord) {
config.set(reportConfig)
}
2023-03-19 19:38:08 +01:00
/*jar {
dependsOn subprojects.jar
subprojects.each { project ->
from(project.jar) {
into("META-INF/jars/")
}
2022-09-19 23:52:14 +02:00
}
2023-03-19 19:38:08 +01:00
}*/