fabric/build.gradle

781 lines
20 KiB
Groovy
Raw Permalink Normal View History

plugins {
2021-05-12 20:23:04 +01:00
id "java-library"
id "eclipse"
id "maven-publish"
id "fabric-loom" version "1.10.1" apply false
id "com.diffplug.spotless" version "7.0.2"
2024-12-18 18:22:30 +00:00
id "me.modmuss50.remotesign" version "0.5.0" apply false
2023-12-08 15:19:29 +00:00
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}
def branchProvider = providers.of(GitBranchValueSource.class) {}
version = project.version + "+" + (providers.environmentVariable("CI").present ? branchProvider.get() : "local")
2020-04-05 15:51:59 +01:00
logger.lifecycle("Building Fabric: " + version)
def metaProjects = [
'deprecated',
'fabric-api-bom',
'fabric-api-catalog'
]
def debugArgs = [
"-enableassertions",
"-Dmixin.debug.verify=true",
//"-Dmixin.debug.strict=true",
"-Dmixin.debug.countInjections=true",
]
import groovy.json.JsonSlurper
import org.apache.commons.codec.digest.DigestUtils
import net.fabricmc.fabric.impl.build.CommitHashValueSource
import net.fabricmc.fabric.impl.build.GitBranchValueSource
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
def getSubprojectVersion(Project project) {
// Get the version from the gradle.properties file
def version = project.properties["${project.name}-version"]
if (!version) {
throw new NullPointerException("Could not find version for " + project.name)
}
if (!project.providers.environmentVariable("CI").present) {
return version + "+local"
2019-08-27 20:26:27 +01:00
}
def hashProvider = project.providers.of(CommitHashValueSource.class) {
parameters.directory = project.name
}
return version + "+" + hashProvider.get().substring(0, 8) + DigestUtils.sha256Hex(project.rootProject.minecraft_version).substring(0, 2)
}
def moduleDependencies(project, List<String> depNames) {
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'namedElements') }
def clientOutputs = depNames.iterator().collect { findProject(":$it").sourceSets.client.output }
project.dependencies {
deps.each {
2021-05-12 20:23:04 +01:00
api it
}
clientOutputs.each {
clientImplementation it
}
}
def depNodes = deps.collect {
[
groupId: it.group,
artifactId: it.name,
2025-02-17 21:53:59 +00:00
version: getSubprojectVersion(project.project(":" + it.name)),
scope: "compile"
]
}
// As we manually handle the maven artifacts, we need to also manually specify the deps.
project.publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
for (def depNode in depNodes) {
def node = depsNode.appendNode("dependency")
for (def entry in depNode) {
node.appendNode(entry.key, entry.value)
}
}
}
}
}
}
}
def testDependencies(project, List<String> depNames) {
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'namedElements') }
def clientOutputs = depNames.iterator().collect { findProject(":$it").sourceSets.client.output }
project.dependencies {
deps.each {
testmodImplementation it
}
clientOutputs.each {
testmodClientImplementation it
}
}
}
allprojects {
group = "net.fabricmc.fabric-api"
2022-05-01 16:16:30 +01:00
apply plugin: "maven-publish"
apply plugin: "me.modmuss50.remotesign"
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
remoteSign {
requestUrl = providers.environmentVariable("SIGNING_SERVER")
pgpAuthKey = providers.environmentVariable("SIGNING_PGP_KEY")
jarAuthKey = providers.environmentVariable("SIGNING_JAR_KEY")
useDummyForTesting = !providers.environmentVariable("SIGNING_SERVER").present
afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
}
publishing {
setupRepositories(repositories)
}
if (metaProjects.contains(it.name)) {
return
}
2021-05-12 20:23:04 +01:00
apply plugin: "java-library"
apply plugin: "checkstyle"
apply plugin: "fabric-loom"
apply plugin: "com.diffplug.spotless"
2018-12-14 18:48:37 +00:00
tasks.withType(JavaCompile).configureEach {
2024-04-03 15:46:52 +01:00
it.options.release = 21
}
java {
// Must be added before the split source sets are setup.
withSourcesJar()
}
loom {
splitEnvironmentSourceSets()
mixin {
useLegacyMixinAp = false
}
}
2020-05-03 17:56:50 +01:00
sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
testmodClient {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += client.compileClasspath
runtimeClasspath += client.runtimeClasspath
compileClasspath += testmod.compileClasspath
runtimeClasspath += testmod.runtimeClasspath
2020-05-03 17:56:50 +01:00
}
test {
compileClasspath += testmodClient.compileClasspath
runtimeClasspath += testmodClient.runtimeClasspath
}
2020-05-03 17:56:50 +01:00
}
2021-05-12 20:23:04 +01:00
loom {
runtimeOnlyLog4j = true
2021-05-12 20:23:04 +01:00
runs {
testmodClient {
client()
ideConfigGenerated project.rootProject == project
name = "Testmod Client"
source sourceSets.testmodClient
2021-05-12 20:23:04 +01:00
}
testmodServer {
server()
ideConfigGenerated project.rootProject == project
name = "Testmod Server"
source sourceSets.testmod
}
}
}
loom.runs.configureEach {
vmArgs(debugArgs)
}
allprojects.each { p ->
if (metaProjects.contains(p.name)) {
return
}
loom.mods.register(p.name) {
sourceSet p.sourceSets.main
sourceSet p.sourceSets.client
}
loom.mods.register(p.name + "-testmod") {
sourceSet p.sourceSets.testmod
sourceSet p.sourceSets.testmodClient
}
}
dependencies {
minecraft "com.mojang:minecraft:$rootProject.minecraft_version"
mappings "net.fabricmc:yarn:${rootProject.minecraft_version}${project.yarn_version}:v2"
modApi "net.fabricmc:fabric-loader:${project.loader_version}"
testmodImplementation sourceSets.main.output
testmodClientImplementation sourceSets.main.output
testmodClientImplementation sourceSets.client.output
testmodClientImplementation sourceSets.testmod.output
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
testImplementation sourceSets.testmodClient.output
2024-09-18 15:29:30 +01:00
testImplementation 'org.mockito:mockito-core:5.13.0'
}
test {
useJUnitPlatform()
}
tasks.withType(ProcessResources).configureEach {
2025-02-17 21:20:54 +00:00
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
2025-02-17 21:20:54 +00:00
expand "version": inputs.properties.version
}
}
spotless {
lineEndings = com.diffplug.spotless.LineEnding.UNIX
java {
licenseHeaderFile(rootProject.file("HEADER"))
removeUnusedImports()
importOrder('java', 'javax', '', 'net.minecraft', 'net.fabricmc')
leadingSpacesToTabs()
trimTrailingWhitespace()
}
// Sort the en_us translation files
// The other languages are handled by Crowdin
json {
target 'src/**/lang/en_us.json'
targetExclude 'src/**/generated/**'
gson().indentWithSpaces(2).sortByKeys()
}
}
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = "10.20.2"
}
2021-05-12 20:23:04 +01:00
tasks.withType(AbstractArchiveTask).configureEach {
2021-05-12 20:23:04 +01:00
preserveFileTimestamps = false
reproducibleFileOrder = true
}
remoteSign {
sign remapJar
}
Add fabric-convention-tags-v1 (#2063) * Add framework for common-tags-v1 * Add javadoc to fabric tool tags * Fix wrong package arrangement * Add some more tags * Add more biome tags Thanks to TelepathicGrunt for the suggestions * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Clarify enchantment tags * Add no-shulker tag * Add minecart tag * Begin work on datagen and populating tags * Add bucket tags * First pass at populating biome tags * Add boat tag * Fix missing inclusion of f:shears into c:shears * Hide fabric tool tags in datagen * Add weapon damage enhancement tag * Change impl package name to be inline with rest of fapi * Rename enchantment tags * Some cleanup * Populate blocktag datagen Remove crops tag * Add javadoc links to vanilla counterparts * Move datagen to its own sourceset * Fix package names for checkstyle * Populate more entries * Remove exclusion tag * Add license headers Fix checkstyle * Add missing nether quarts to ores tag * Use `worldgen/biome` instead of `biomes` for biome tags Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Manually include all biomes for overworld * Remove ancient debris from NetheriteOres * Add and populate glass tags * Add and populate movement enhancement * Break up item tags * Add armour damage reduction tag * Add missing ore and related tags * Fix quartz tags * Add floral tag * Add golden carrot * Correct some biome tag issues * Separate SNOWY_PLAINS and PLAINS * Add SNOWY tag and remove snowy biomes from ICY * Correct enchantment tag Remove silk touch tag * Fix more biome issues * Add deep and shllow ocean tags * Add no-move tag * Remove netherite ores * Add shulker tags * Add raw ore * Add dye tags * Fif dye tags * Fix typo * Document some biome tags where the naming may not be clear * Remove tag mirroring for blocks and items * Rename module Remove unused methods * Rename impl package * Rename packages and module * Rename folder * Rename api classes * Add generateResources task to cover all resource generation tasks. * Add generated tags to repo * Fix ocean tag excluding shallow ocean * Iterate registry to generate foods tag * Remove cache, add to gitignore * Rename generated folder Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> Co-authored-by: modmuss50 <modmuss50@gmail.com>
2022-04-17 19:23:48 +01:00
// Run this task after updating minecraft to regenerate any required resources
tasks.register('generateResources') {
Add fabric-convention-tags-v1 (#2063) * Add framework for common-tags-v1 * Add javadoc to fabric tool tags * Fix wrong package arrangement * Add some more tags * Add more biome tags Thanks to TelepathicGrunt for the suggestions * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Clarify enchantment tags * Add no-shulker tag * Add minecart tag * Begin work on datagen and populating tags * Add bucket tags * First pass at populating biome tags * Add boat tag * Fix missing inclusion of f:shears into c:shears * Hide fabric tool tags in datagen * Add weapon damage enhancement tag * Change impl package name to be inline with rest of fapi * Rename enchantment tags * Some cleanup * Populate blocktag datagen Remove crops tag * Add javadoc links to vanilla counterparts * Move datagen to its own sourceset * Fix package names for checkstyle * Populate more entries * Remove exclusion tag * Add license headers Fix checkstyle * Add missing nether quarts to ores tag * Use `worldgen/biome` instead of `biomes` for biome tags Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Manually include all biomes for overworld * Remove ancient debris from NetheriteOres * Add and populate glass tags * Add and populate movement enhancement * Break up item tags * Add armour damage reduction tag * Add missing ore and related tags * Fix quartz tags * Add floral tag * Add golden carrot * Correct some biome tag issues * Separate SNOWY_PLAINS and PLAINS * Add SNOWY tag and remove snowy biomes from ICY * Correct enchantment tag Remove silk touch tag * Fix more biome issues * Add deep and shllow ocean tags * Add no-move tag * Remove netherite ores * Add shulker tags * Add raw ore * Add dye tags * Fif dye tags * Fix typo * Document some biome tags where the naming may not be clear * Remove tag mirroring for blocks and items * Rename module Remove unused methods * Rename impl package * Rename packages and module * Rename folder * Rename api classes * Add generateResources task to cover all resource generation tasks. * Add generated tags to repo * Fix ocean tag excluding shallow ocean * Iterate registry to generate foods tag * Remove cache, add to gitignore * Rename generated folder Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> Co-authored-by: modmuss50 <modmuss50@gmail.com>
2022-04-17 19:23:48 +01:00
group = "fabric"
}
tasks.register('testmodJar', Jar) {
from sourceSets.testmod.output
from sourceSets.testmodClient.output
destinationDirectory = new File(project.buildDir, "devlibs")
archiveClassifier = "testmod"
}
String archivesName = project.base.archivesName.get()
[jar, sourcesJar].each {
2022-09-25 14:46:02 +01:00
it.from(rootProject.file("LICENSE")) {
rename { "${it}-${archivesName}"}
2022-09-25 14:46:02 +01:00
}
}
if (file("src/client").exists() && !file("src/main").exists()) {
tasks.named("remapJar", net.fabricmc.loom.task.AbstractRemapJarTask) {
additionalClientOnlyEntries.add("LICENSE-${archivesName}".toString())
}
remapSourcesJar {
additionalClientOnlyEntries.add("LICENSE-${archivesName}".toString())
}
}
tasks.register('remapTestmodJar', net.fabricmc.loom.task.RemapJarTask) {
dependsOn testmodJar
input = testmodJar.archiveFile
archiveClassifier = "testmod"
addNestedDependencies = false
includesClientOnlyClasses = true
clientOnlySourceSetName = sourceSets.testmodClient.name
classpath.from(sourceSets.testmodClient.compileClasspath)
}
build.dependsOn remapTestmodJar
tasks.register('validateMixinNames', net.fabricmc.loom.task.ValidateMixinNameTask) {
source(sourceSets.main.output)
source(sourceSets.client.output)
source(sourceSets.testmod.output)
}
// Apply to each valid subproject.
apply from: rootProject.file('gradle/package-info.gradle')
apply from: rootProject.file('gradle/validate-annotations.gradle')
}
2022-05-24 15:04:30 +01:00
remapTestmodJar {
def testModJarTasks = []
subprojects {
if (metaProjects.contains(it.name) || !(it.file("src/testmod").exists() || it.file("src/testmodClient").exists())) {
return
}
2022-05-24 15:04:30 +01:00
testModJarTasks += it.tasks.remapTestmodJar
}
nestedJars.setFrom(testModJarTasks)
addNestedDependencies = true
clientOnlySourceSetName = sourceSets.testmodClient.name
2022-05-24 15:04:30 +01:00
}
// Apply auxiliary buildscripts to submodules
// This must be done after all plugins are applied to subprojects
apply from: "gradle/module-validation.gradle"
apply from: "gradle/module-versioning.gradle"
loom {
accessWidenerPath = file("gradle/javadoc.accesswidener")
}
javadoc {
options {
2024-04-03 15:46:52 +01:00
source = "21"
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
links(
"https://maven.fabricmc.net/docs/yarn-${rootProject.minecraft_version}${project.yarn_version}/"
)
// Disable the crazy super-strict doclint tool in Java 8
addStringOption("Xdoclint:none", "-quiet")
tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:'
)
}
allprojects.each {
if (metaProjects.contains(it.name)) {
return
}
source(it.sourceSets.main.allJava)
source(it.sourceSets.client.allJava)
}
classpath = files(sourceSets.main.compileClasspath, sourceSets.client.compileClasspath)
include("**/api/**")
2024-12-18 18:22:30 +00:00
failOnError = true
2018-12-22 16:21:31 +01:00
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
from javadoc.destinationDir
//Set as `fatjavadoc` to prevent an ide form trying to use this javadoc, over using the modules javadoc
archiveClassifier = "fatjavadoc"
}
build.dependsOn javadocJar
2021-05-12 20:23:04 +01:00
loom {
runs {
gametest {
inherit testmodServer
name "Game Test"
// Enable the gametest runner
vmArg "-Dfabric-api.gametest"
vmArg "-Dfabric-api.gametest.report-file=${project.layout.buildDirectory.file("junit.xml").get().getAsFile()}"
runDir "build/gametest"
}
2021-05-12 20:23:04 +01:00
autoTestServer {
inherit testmodServer
name "Auto Test Server"
vmArg "-Dfabric.autoTest"
}
clientGametest {
inherit testmodClient
name "Client Game Test"
vmArg "-Dfabric.client.gametest"
vmArg "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail"
vmArg "-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
2021-05-12 20:23:04 +01:00
}
}
}
runGametest {
outputs.file project.layout.buildDirectory.file("junit.xml")
}
test.dependsOn runGametest
configurations {
productionMods {
transitive = false
}
}
dependencies {
productionMods project(':fabric-client-gametest-api-v1')
}
def productionMods = project.files(configurations.productionMods, remapJar.archiveFile, remapTestmodJar.archiveFile)
tasks.register('runProductionClientGametest', net.fabricmc.loom.task.prod.ClientProductionRunTask) {
mods.setFrom productionMods
jvmArgs.addAll([
"-Dfabric.client.gametest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
])
jvmArgs.addAll(debugArgs)
if (providers.environmentVariable("ENABLE_TRACY").present) {
tracy {
tracyCapture = file("tracy-capture")
output = file("profile.tracy")
}
}
}
tasks.register('runProductionAutoTestServer', net.fabricmc.loom.task.prod.ServerProductionRunTask) {
mods.setFrom productionMods
jvmArgs.add("-Dfabric.autoTest")
jvmArgs.addAll(debugArgs)
programArgs.add("nogui")
}
// Format all the gradle files
spotless {
groovyGradle {
target 'src/**/*.gradle', '*.gradle', 'gradle/*.gradle'
greclipse()
}
}
def addPomMetadataInformation(Project project, MavenPom pom) {
def modJsonFile = project.file("src/main/resources/fabric.mod.json")
if (!modJsonFile.exists()) {
modJsonFile = project.file("src/client/resources/fabric.mod.json")
}
def modJson = new JsonSlurper().parse(modJsonFile)
pom.name = modJson.name
pom.url = "https://github.com/FabricMC/fabric/tree/HEAD/${project.rootDir.relativePath(project.projectDir)}"
pom.description = modJson.description
pom.licenses {
license {
name = "Apache-2.0"
url = "https://github.com/FabricMC/fabric/blob/HEAD/LICENSE"
}
}
pom.developers {
developer {
name = "FabricMC"
url = "https://fabricmc.net/"
}
}
pom.scm {
connection = "scm:git:https://github.com/FabricMC/fabric.git"
url = "https://github.com/FabricMC/fabric"
developerConnection = "scm:git:git@github.com:FabricMC/fabric.git"
}
pom.issueManagement {
system = "GitHub"
url = "https://github.com/FabricMC/fabric/issues"
}
}
subprojects {
if (metaProjects.contains(it.name)) {
return
}
base {
archivesName = project.name
}
2020-05-03 17:56:50 +01:00
dependencies {
2021-05-12 20:23:04 +01:00
testmodImplementation sourceSets.main.output
// Make all modules depend on the gametest api (and thus res loader) to try and promote its usage.
if (project.name != "fabric-gametest-api-v1") {
testmodImplementation project(path: ':fabric-gametest-api-v1', configuration: 'namedElements')
testmodClientImplementation project(":fabric-gametest-api-v1").sourceSets.client.output
testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements')
testmodClientImplementation project(":fabric-resource-loader-v0").sourceSets.client.output
}
// Make all testmods run with registry-sync-v0 as it is required to register new objects.
if (project.name != "fabric-registry-sync-v0") {
testmodRuntimeOnly project(path: ':fabric-registry-sync-v0', configuration: 'namedElements')
testmodClientImplementation project(":fabric-registry-sync-v0").sourceSets.client.output
}
2020-05-03 17:56:50 +01:00
}
2019-04-24 01:14:43 +02:00
publishing {
publications {
mavenJava(MavenPublication) {
pom {
addPomMetadataInformation(project, pom)
}
artifact(signRemapJar.output) {
builtBy(signRemapJar)
}
artifact(remapSourcesJar) {
builtBy remapSourcesJar
}
2019-04-24 01:14:43 +02:00
}
2019-07-24 23:07:45 +02:00
}
2019-04-24 01:14:43 +02:00
}
def projectName = it.name
def projectVersion = getSubprojectVersion(it)
// Skip publishing if the artifact already exists on the maven server
tasks.withType(PublishToMavenRepository).configureEach {
onlyIf {
if (!providers.environmentVariable("MAVEN_URL").present) {
// Always try to publish if the maven url is not set (e.g locally)
return true
}
def artifactPath = "https://maven.fabricmc.net/net/fabricmc/fabric-api/${projectName}/${projectVersion}/${projectName}-${projectVersion}.pom"
boolean exists = HttpClient.newHttpClient().withCloseable { client ->
def request = HttpRequest.newBuilder()
.uri(URI.create(artifactPath))
.method("HEAD", HttpRequest.BodyPublishers.noBody())
.build()
def response = client.send(request, HttpResponse.BodyHandlers.discarding())
response.statusCode() == 200
}
if (exists) {
logger.lifecycle("${projectName}-${projectVersion}.pom has already been published")
} else {
logger.lifecycle("${projectName}-${projectVersion}.pom does not exist, publishing")
}
return !exists
}
}
// We manually handle the pom generation
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
javadoc.enabled = false
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(signRemapJar.output) {
builtBy(signRemapJar)
2019-04-24 01:14:43 +02:00
}
2019-04-24 01:14:43 +02:00
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
artifact remapTestmodJar
pom {
addPomMetadataInformation(rootProject, pom)
}
List<Map<String, String>> dependencies = []
subprojects.each {
// The maven BOM containing all of the deprecated modules is added manually below.
if (it.path.startsWith(":deprecated") || metaProjects.contains(it.name)) {
return
}
dependencies.add([
'groupId': it.group,
'artifactId': it.name,
2025-02-17 16:15:23 +00:00
'version': getSubprojectVersion(it),
'scope': 'compile'
])
}
def thisGroup = group
def thisVersion = version
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
for (dep in dependencies) {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", dep['groupId'])
depNode.appendNode("artifactId", dep['artifactId'])
depNode.appendNode("version", dep['version'])
depNode.appendNode("scope", dep['scope'])
}
// Depend on the deprecated BOM to allow opting out of deprecated modules.
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", thisGroup)
depNode.appendNode("artifactId", "fabric-api-deprecated")
depNode.appendNode("version", thisVersion)
depNode.appendNode("scope", "compile")
}
}
}
}
// Required until the deprecation is removed. Fabric API's main jar that is published to maven does not contain sub modules.
2021-09-17 18:42:42 +01:00
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
void setupRepositories(RepositoryHandler repositories) {
//repositories.mavenLocal() // uncomment for testing
if (providers.environmentVariable("MAVEN_URL").present) {
repositories.maven {
url = providers.environmentVariable("MAVEN_URL")
credentials {
2025-02-15 15:36:49 +00:00
username = providers.environmentVariable("MAVEN_USERNAME").get()
password = providers.environmentVariable("MAVEN_PASSWORD").get()
2019-04-24 01:14:43 +02:00
}
}
}
}
subprojects.each {
if (metaProjects.contains(it.name)) {
return
}
remapJar.dependsOn("${it.path}:remapJar")
}
// These modules are not included in the fat jar, maven will resolve them via the pom.
def devOnlyModules = [
"fabric-client-gametest-api-v1",
"fabric-gametest-api-v1",
]
dependencies {
afterEvaluate {
subprojects.each {
if (metaProjects.contains(it.name)) {
return
}
api project(path: "${it.path}", configuration: "namedElements")
clientImplementation project("${it.path}:").sourceSets.client.output
testmodImplementation project("${it.path}:").sourceSets.testmod.output
testmodClientImplementation project("${it.path}:").sourceSets.testmodClient.output
}
}
}
configurations {
nestedJars {
transitive = false
}
}
dependencies {
subprojects.each {
if (it.name in devOnlyModules || metaProjects.contains(it.name)) {
return
}
nestedJars project("${it.path}")
}
}
remapJar {
nestedJars.from configurations.nestedJars
}
// Attempt to create a single jar with all files from all nested jars, this will fail if there are duplicate files.
tasks.register("checkNoDuplicateFiles", Zip) {
inputs.files configurations.nestedJars
destinationDirectory = layout.buildDirectory.dir("test")
from {
configurations.nestedJars.files.collect { zipTree(it) }
}
// We expect these files to be duplicated, so exclude them.
exclude 'META-INF/**'
exclude 'fabric.mod.json'
}
check.dependsOn "checkNoDuplicateFiles"
publishMods {
file = signRemapJar.output
changelog = providers.environmentVariable("CHANGELOG").getOrElse("No changelog provided")
type = project.prerelease == "true" ? BETA : STABLE
displayName = "[${project.minecraft_version}] Fabric API $project.version"
modLoaders.add("fabric")
2023-08-09 18:10:52 +01:00
dryRun = providers.environmentVariable("CURSEFORGE_API_KEY").getOrNull() == null
curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
projectId = "306612"
minecraftVersions.add(project.curseforge_minecraft_version)
2019-05-12 00:00:57 +02:00
}
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "P7dR8mSH"
minecraftVersions.add(project.minecraft_version)
2019-05-12 00:00:57 +02:00
}
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("FabricMC/dryrun")
commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun")
2020-07-01 18:58:47 +01:00
}
}
assemble.dependsOn signRemapJar
import java.util.stream.Collectors
// A task to ensure that the version being released has not already been released.
tasks.register('checkVersion') {
doFirst {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
tasks.publishMods.dependsOn checkVersion
publish.mustRunAfter checkVersion