buildscript { dependencies { classpath 'org.kohsuke:github-api:1.135' } } plugins { id "fabric-loom" version "0.11-SNAPSHOT" id "maven-publish" id "org.ajoberstar.grgit" version "3.1.0" id "com.matthewprenger.cursegradle" version "1.4.0" id "com.modrinth.minotaur" version "1.1.0" } repositories { mavenCentral() jcenter() maven { name 'm2-dv8tion' url 'https://m2.dv8tion.net/releases' } } def ENV = System.getenv() archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group sourceCompatibility = 16 targetCompatibility = 16 dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" include(modImplementation(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version))) include(modImplementation(fabricApi.module("fabric-api-base", project.fabric_version))) implementation include('net.dv8tion:JDA:5.0.0-alpha.5') { exclude module: 'opus-java' } include "net.sf.trove4j:trove4j:3.0.3" include 'org.apache.commons:commons-collections4:4.1' include 'com.neovisionaries:nv-websocket-client:2.14' include 'com.squareup.okhttp3:okhttp:3.13.0' include 'com.squareup.okio:okio:1.17.2' include 'com.fasterxml.jackson.core:jackson-databind:2.10.1' include 'com.fasterxml.jackson.core:jackson-annotations:2.10.1' include 'com.fasterxml.jackson.core:jackson-core:2.10.1' } compileJava { sourceCompatibility = 16 targetCompatibility = 16 options.encoding = 'UTF-8' } processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { expand "version": project.version } } // 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 tasks.withType(JavaCompile) { options.encoding = "UTF-8" } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. /*task sourcesJar(type: Jar, dependsOn: classes) { classifier = "sources" from sourceSets.main.allSource }*/ jar { from "LICENSE" } def getBranch() { def ENV = System.getenv() if (ENV.GITHUB_REF) { def branch = ENV.GITHUB_REF return branch.substring(branch.lastIndexOf("/") + 1) } if (grgit == null) { return "unknown" } def branch = grgit.branch.current().name return branch.substring(branch.lastIndexOf("/") + 1) } task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) { input = jar.archiveFile archiveFileName = "${archivesBaseName}-${project.version}-maven.jar" addNestedDependencies = false } build.dependsOn remapMavenJar curseforge { if (ENV.CURSEFORGE_API_KEY) { apiKey = ENV.CURSEFORGE_API_KEY } project { id = "575422" changelog = ENV.CHANGELOG ?: "No changelog provided" releaseType = "release" addGameVersion "1.18-Snapshot" addGameVersion "Fabric" mainArtifact(remapJar) { displayName = "[$project.supported_versions] AutoWhitelist - $project.version" } afterEvaluate { uploadTask.dependsOn("remapJar") } } options { forgeGradleIntegration = false } } import org.kohsuke.github.GHReleaseBuilder import org.kohsuke.github.GitHub task github(dependsOn: remapMavenJar) { onlyIf { ENV.GITHUB_TOKEN } doLast { def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String) def repository = github.getRepository(ENV.GITHUB_REPOSITORY) def releaseBuilder = new GHReleaseBuilder(repository, version as String) releaseBuilder.name("[$project.supported_versions] AutoWhitelist - $project.version") releaseBuilder.body(ENV.CHANGELOG ?: "No changelog provided") releaseBuilder.commitish(getBranch()) releaseBuilder.prerelease(false) def ghRelease = releaseBuilder.create() ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive"); } } task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: remapMavenJar) { onlyIf { ENV.MODRINTH_TOKEN } token = ENV.MODRINTH_TOKEN projectId = "2tvyop0z" versionNumber = version versionName = "[$project.supported_versions] AutoWhitelist - $project.version" releaseType = "release" changelog = ENV.CHANGELOG ?: "No changelog provided" uploadFile = remapJar addGameVersion(project.minecraft_version) addLoader('fabric') }