import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id 'java' id 'maven-publish' id 'java-gradle-plugin' id 'idea' id 'eclipse' id 'groovy' id 'checkstyle' id 'jacoco' id 'codenarc' id "org.cadixdev.licenser" version "0.5.0" id 'com.github.johnrengelman.shadow' version '4.0.4' id 'net.kyori.blossom' version '1.2.0' } sourceCompatibility = 1.8 targetCompatibility = 1.8 group = "dev.architectury" archivesBaseName = project.name def baseVersion = '0.7.4' def runNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "9999" def isSnapshot = System.getenv("PR_NUM") != null def buildNum = "release #$runNumber" if (!isSnapshot) { version = baseVersion + "." + runNumber } else { version = baseVersion + "-PR." + System.getenv("PR_NUM") + "." + runNumber } logger.lifecycle(":building plugin v${version}") repositories { mavenCentral() maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } maven { url "https://maven.minecraftforge.net/" } } dependencies { implementation gradleApi() // Compile against groovy 3 to aid with gradle 7 support. Remove when updating to gradle 7 compileOnly 'org.codehaus.groovy:groovy:3.0.7' // libraries implementation ('commons-io:commons-io:2.8.0') implementation ('org.zeroturnaround:zt-zip:1.14') implementation ('com.google.code.gson:gson:2.8.6') implementation ('com.google.guava:guava:30.1-jre') implementation ('org.ow2.asm:asm:9.2') implementation ('org.ow2.asm:asm-analysis:9.2') implementation ('org.ow2.asm:asm-commons:9.2') implementation ('org.ow2.asm:asm-tree:9.2') implementation ('org.ow2.asm:asm-util:9.2') implementation ('me.tongfei:progressbar:0.9.0') // game handling utils implementation ('net.fabricmc:stitch:0.6.1') { exclude module: 'mercury' exclude module: 'enigma' } // tinyfile management implementation ('dev.architectury:tiny-remapper:1.1.0') implementation ('dev.architectury:mappings-layers-core:1.4.9') implementation ('net.fabricmc:tiny-mappings-parser:0.3.0+build.17') implementation 'net.fabricmc:access-widener:1.0.0' implementation 'net.fabricmc:mapping-io:0.1.3' implementation ('net.fabricmc:lorenz-tiny:3.0.0') { transitive = false } implementation ('org.cadixdev:lorenz-io-proguard:0.5.6') implementation "dev.architectury:refmap-remapper:1.0.5" // decompilers implementation ('net.fabricmc:fabric-fernflower:1.3.0') implementation ('org.benf:cfr:0.151') // source code remapping implementation ('dev.architectury:mercury:0.1.0.10') // Kapt integration compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21') // Forge patches implementation ('net.minecraftforge:installertools:1.2.0') implementation ('net.minecraftforge:binarypatcher:1.1.1') implementation ('org.cadixdev:lorenz:0.5.3') implementation ('org.cadixdev:lorenz-asm:0.5.3') implementation ('de.oceanlabs.mcp:mcinjector:3.8.0') implementation ('com.opencsv:opencsv:5.4') // Testing testImplementation(gradleTestKit()) testImplementation('org.spockframework:spock-core:1.3-groovy-2.4') { exclude module: 'groovy-all' } testImplementation 'io.javalin:javalin:3.13.4' compileOnly 'org.jetbrains:annotations:20.1.0' } blossom { replaceToken '$LOOM_VERSION', version } jar { classifier 'jar' } task mainJar(type: Jar, dependsOn: jar) { from zipTree(jar.archivePath) manifest { attributes 'Implementation-Version': project.version + ' Build(' + buildNum + ')' } } task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } license { header rootProject.file("HEADER") include "**/*.java" include "**/*.groovy" exclude '**/loom/util/DownloadUtil.java' exclude '**/projects' exclude '**/loom/util/FileSystemUtil.java' } checkstyle { configFile = file('checkstyle.xml') toolVersion = '8.39' } codenarc { toolVersion = "2.0.0" configFile = file("codenarc.groovy") } gradlePlugin { plugins { fabricLoom { id = 'dev.architectury.loom' implementationClass = 'net.fabricmc.loom.LoomGradlePlugin' } } } build.dependsOn mainJar jacoco { toolVersion = "0.8.6" } // Run to get test coverage. jacocoTestReport { dependsOn test reports { xml.enabled false csv.enabled false html.destination file("${buildDir}/jacocoHtml") } } test { maxHeapSize = "4096m" } import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node publishing { publications { plugin(MavenPublication) { groupId 'dev.architectury.loom' artifactId 'dev.architectury.loom.gradle.plugin' from components.java artifact mainJar artifact sourcesJar } maven(MavenPublication) { publication -> groupId project.group artifactId project.archivesBaseName from components.java artifact mainJar artifact sourcesJar artifact javadocJar } if (isSnapshot) return mavenSnapshot(MavenPublication) { publication -> groupId project.group artifactId project.archivesBaseName version baseVersion + '-SNAPSHOT' from components.java artifact mainJar artifact sourcesJar artifact javadocJar } pluginSnapshot(MavenPublication) { groupId 'dev.architectury.loom' artifactId 'dev.architectury.loom.gradle.plugin' version baseVersion + '-SNAPSHOT' pom.withXml { // Based off org.gradle.plugin.devel.plugins.MavenPluginPublishPlugin Element root = asElement() Document document = root.getOwnerDocument() Node dependencies = root.appendChild(document.createElement('dependencies')) Node dependency = dependencies.appendChild(document.createElement('dependency')) Node groupId = dependency.appendChild(document.createElement('groupId')) groupId.setTextContent(project.group) Node artifactId = dependency.appendChild(document.createElement('artifactId')) artifactId.setTextContent(project.archivesBaseName) Node version = dependency.appendChild(document.createElement('version')) version.setTextContent(baseVersion + '-SNAPSHOT') } } } repositories { if (System.getenv("MAVEN_PASS") != null) { maven { url = "https://deploy.shedaniel.me/" credentials { username = "shedaniel" password = System.getenv("MAVEN_PASS") } } } } } // A task to output a json file with a list of all the test to run task writeActionsTestMatrix() { doLast { def testMatrix = [] file('src/test/groovy/net/fabricmc/loom/test/integration').eachFile { if (it.name.endsWith("Test.groovy")) { if (it.name.endsWith("ReproducibleBuildTest.groovy")) { // This test gets a special case to run across all os's return } def className = it.name.replace(".groovy", "") testMatrix.add("net.fabricmc.loom.test.integration.${className}") } } // Run all the unit tests togeather testMatrix.add("net.fabricmc.loom.test.unit.*") def json = groovy.json.JsonOutput.toJson(testMatrix) def output = file("build/test_matrix.json") output.parentFile.mkdir() output.text = json } }