import java.nio.charset.StandardCharsets buildscript { repositories { mavenLocal() jcenter() google() } dependencies { classpath 'com.guardsquare:proguard-gradle:7.0.1' } } plugins { id "fabric-loom" version "0.6-SNAPSHOT" apply false id "maven-publish" id "java-library" } group = "draylar" archivesBaseName = "omega-config" subprojects { apply plugin: 'fabric-loom' apply plugin: 'maven-publish' apply plugin: 'java-library' archivesBaseName = project.name group = "draylar.${project.group}" // import utility functions apply from: "https://raw.githubusercontent.com/NerdHubMC/Gradle-Scripts/master/scripts/utilities.gradle" repositories { mavenCentral() } compileJava { options.encoding = StandardCharsets.UTF_8.name() } if (JavaVersion.current().isJava8Compatible()) { allprojects { tasks.withType(Javadoc) { options.addStringOption("Xdoclint:none", "-quiet") } } } jar { from "LICENSE.md" from "LICENSE" manifest.mainAttributes( "Implementation-Title": project.archivesBaseName, "Implementation-Version": mod_version, "Maven-Artifact": "${project.group}:${project.name}:${mod_version}".toLowerCase(Locale.ROOT), "Built-On-Minecraft": "${project.minecraft_version}", "Built-On-Java": "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})" ) } task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource classifier = "sources" } task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir classifier = "javadoc" } tasks.build.dependsOn javadocJar publishing { publications { mavenJava(MavenPublication) { artifact(file("${project.buildDir}/libs/${archivesBaseName}-${project.mod_version}.jar")) { builtBy(remapJar) } pom.withXml { def depsNode = asNode().appendNode("dependencies") subprojects.each { def depNode = depsNode.appendNode("dependency") depNode.appendNode("groupId", it.group) depNode.appendNode("artifactId", it.name) depNode.appendNode("version", it.version) depNode.appendNode("scope", "compile") } } } } } tasks.publish.dependsOn build //stupid fix for maven/loom not publishing the main artifact task ('proguard', type: proguard.gradle.ProGuardTask) { configuration './proguard.conf' verbose injars project.buildDir.toString() + '/libs/' + archivesBaseName + "-" + project.mod_version + ".jar" outjars project.buildDir.toString() + '/libs/' + archivesBaseName + "-" + project.mod_version + "-min.jar" printmapping 'out.map' keepparameternames renamesourcefileattribute 'SourceFile' keepattributes 'Signature,Exceptions,InnerClasses,PermittedSubclasses,EnclosingMethod,Deprecated,SourceFile,LineNumberTable' keepattributes '*Annotation*' keep 'public class * { \ public protected *; \ }' keepclassmembernames 'class * { \ java.lang.Class class$(java.lang.String); \ java.lang.Class class$(java.lang.String, boolean); \ }' keepclassmembers 'class draylar.omegaconfig.mixin.* {\ ;\ ();\ ;\ }' } } allprojects { apply plugin: "fabric-loom" sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 version = System.getenv("TRAVIS_TAG") ?: project.mod_version repositories { maven { name = "FabricMC" url = "https://maven.fabricmc.net" } maven { url = "https://maven.terraformersmc.com/releases/"} } 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}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "com.terraformersmc:modmenu:1.16.8" } processResources { // this will ensure that this task is redone when there"s a change inputs.property "version", mod_version // replace stuff in fabric.mod.json, nothing else from(sourceSets.main.resources.srcDirs) { include "fabric.mod.json" // add mod metadata expand "version": mod_version } // copy everything else, that"s not the fabric.mod.json from(sourceSets.main.resources.srcDirs) { exclude "fabric.mod.json" } } jar { from(rootProject.file("LICENSE.md")) { rename { "LICENSE_${project.archivesBaseName.replace('-', '_')}"} } } } sourceSets { testmod { compileClasspath += main.compileClasspath runtimeClasspath += main.runtimeClasspath } test { compileClasspath += main.compileClasspath runtimeClasspath += main.runtimeClasspath } } task licenseFormatAll subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") } subprojects.each { remapJar.dependsOn("${it.path}:remapJar") } repositories { maven { name = "JitPack" url = "https://jitpack.io" } } dependencies { 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}" modImplementation "com.terraformersmc:modmenu:1.16.8" afterEvaluate { testmodImplementation sourceSets.main.output } afterEvaluate { subprojects.each { api it include it } } } publishing { publications { mavenJava(MavenPublication) { artifact(file("${project.buildDir}/libs/${archivesBaseName}-${project.mod_version}.jar")) { builtBy(remapJar) } pom.withXml { def depsNode = asNode().appendNode("dependencies") subprojects.each { def depNode = depsNode.appendNode("dependency") depNode.appendNode("groupId", it.group) depNode.appendNode("artifactId", it.name) depNode.appendNode("version", it.version) depNode.appendNode("scope", "compile") } } } } } tasks.publish.dependsOn build //stupid fix for maven/loom not publishing the main artifact