fabric/build.gradle

810 lines
21 KiB
Groovy
Raw Normal View History

plugins {
2021-05-12 15:23:04 -04:00
id "java-library"
id "eclipse"
id "idea"
id "maven-publish"
id 'jacoco'
id "fabric-loom" version "1.7.3" apply false
id "com.diffplug.spotless" version "6.20.0"
2024-08-11 09:51:54 -04:00
id "org.ajoberstar.grgit" version "5.2.2"
id "me.modmuss50.remotesign" version "0.4.0" apply false
2023-12-08 10:19:29 -05:00
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}
def ENV = System.getenv()
version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
2020-04-05 10:51:59 -04: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 net.fabricmc.loom.util.gradle.SourceSetHelper
import groovy.json.JsonSlurper
import org.apache.commons.codec.digest.DigestUtils
def getSubprojectVersion(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 (grgit == null) {
return version + "+nogit"
}
2021-04-14 13:35:48 -04:00
def latestCommits = grgit.log(paths: [project.name], maxCommits: 1)
if (latestCommits.isEmpty()) {
return version + "+uncommited"
}
return version + "+" + latestCommits.get(0).id.substring(0, 8) + DigestUtils.sha256Hex(project.rootProject.minecraft_version).substring(0, 2)
}
def getBranch() {
def ENV = System.getenv()
if (ENV.GITHUB_REF) {
def branch = ENV.GITHUB_REF
2019-08-27 15:40:07 -04:00
return branch.substring(branch.lastIndexOf("/") + 1)
2019-08-27 15:26:27 -04:00
}
if (grgit == null) {
return "unknown"
}
def branch = grgit.branch.current().name
return branch.substring(branch.lastIndexOf("/") + 1)
}
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 15:23:04 -04:00
api it
}
clientOutputs.each {
clientImplementation it
}
}
// 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")
deps.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")
}
}
}
}
}
}
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 11:16:30 -04:00
apply plugin: "maven-publish"
apply plugin: "me.modmuss50.remotesign"
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY
useDummyForTesting = ENV.SIGNING_SERVER == null
afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
}
publishing {
setupRepositories(repositories)
}
if (metaProjects.contains(it.name)) {
return
}
2021-05-12 15:23:04 -04:00
apply plugin: "java-library"
apply plugin: "checkstyle"
apply plugin: "fabric-loom"
apply plugin: "com.diffplug.spotless"
2018-12-14 13:48:37 -05:00
tasks.withType(JavaCompile).configureEach {
2024-04-03 10:46:52 -04:00
it.options.release = 21
}
java {
// Must be added before the split source sets are setup.
withSourcesJar()
}
loom {
splitEnvironmentSourceSets()
mixin {
useLegacyMixinAp = true
}
}
2020-05-03 12:56:50 -04: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 12:56:50 -04:00
}
test {
compileClasspath += testmodClient.compileClasspath
runtimeClasspath += testmodClient.runtimeClasspath
}
2020-05-03 12:56:50 -04:00
}
2021-05-12 15:23:04 -04:00
loom {
runtimeOnlyLog4j = true
2021-05-12 15:23:04 -04:00
runs {
testmodClient {
client()
ideConfigGenerated project.rootProject == project
name = "Testmod Client"
source sourceSets.testmodClient
2021-05-12 15:23:04 -04:00
}
testmodServer {
server()
ideConfigGenerated project.rootProject == project
name = "Testmod Server"
source sourceSets.testmod
}
}
}
loom.runs.configureEach {
vmArgs(debugArgs)
}
allprojects.each { p ->
if (metaProjects.contains(project.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
testImplementation 'org.mockito:mockito-core:5.4.0'
}
test {
useJUnitPlatform()
afterEvaluate {
// See: https://github.com/FabricMC/fabric-loader/pull/585
def classPathGroups = loom.mods.stream()
.map { modSettings ->
SourceSetHelper.getClasspath(modSettings, getProject()).stream()
.map(File.&getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator))
}
.collect(Collectors.joining(File.pathSeparator+File.pathSeparator))
systemProperty("fabric.classPathGroups", classPathGroups)
}
}
tasks.withType(ProcessResources).configureEach {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
removeUnusedImports()
importOrder('java', 'javax', '', 'net.minecraft', 'net.fabricmc')
indentWithTabs()
trimTrailingWhitespace()
}
}
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = "10.12.1"
}
2021-05-12 15:23:04 -04:00
tasks.withType(AbstractArchiveTask).configureEach {
2021-05-12 15:23:04 -04: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 14:23:48 -04: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 14:23:48 -04:00
group = "fabric"
}
tasks.register('testmodJar', Jar) {
from sourceSets.testmod.output
from sourceSets.testmodClient.output
destinationDirectory = new File(project.buildDir, "devlibs")
archiveClassifier = "testmod"
}
[jar, sourcesJar].each {
2022-09-25 09:46:02 -04:00
it.from(rootProject.file("LICENSE")) {
rename { "${it}-${project.base.archivesName.get()}"}
2022-09-25 09:46:02 -04:00
}
}
if (file("src/client").exists() && !file("src/main").exists()) {
remapJar {
additionalClientOnlyEntries.add("LICENSE-${project.base.archivesName.get()}")
}
remapSourcesJar {
additionalClientOnlyEntries.add("LICENSE-${project.base.archivesName.get()}")
}
}
tasks.register('remapTestmodJar', net.fabricmc.loom.task.RemapJarTask) {
dependsOn testmodJar
input = testmodJar.archiveFile
archiveClassifier = "testmod"
addNestedDependencies = false
includesClientOnlyClasses = true
clientOnlySourceSetName = sourceSets.testmodClient.name
}
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 10:04:30 -04:00
remapTestmodJar {
def testModJarTasks = []
subprojects {
if (metaProjects.contains(it.name) || !(it.file("src/testmod").exists() || it.file("src/testmodClient").exists())) {
return
}
2022-05-24 10:04:30 -04:00
testModJarTasks += it.tasks.remapTestmodJar
}
nestedJars.setFrom(testModJarTasks)
addNestedDependencies = true
clientOnlySourceSetName = sourceSets.testmodClient.name
2022-05-24 10:04:30 -04: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 10:46:52 -04: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/**")
failOnError true
2018-12-22 10:21:31 -05: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 15:23:04 -04:00
loom {
runs {
gametest {
inherit testmodServer
name "Game Test"
// Enable the gametest runner
vmArg "-Dfabric-api.gametest"
vmArg "-Dfabric-api.gametest.report-file=${project.buildDir}/junit.xml"
runDir "build/gametest"
}
2021-05-12 15:23:04 -04:00
autoTestServer {
inherit testmodServer
name "Auto Test Server"
vmArg "-Dfabric.autoTest"
}
autoTestClient {
inherit testmodClient
name "Auto Test Client"
2021-05-12 15:23:04 -04:00
vmArg "-Dfabric.autoTest"
vmArg "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail"
vmArg "-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
2021-05-12 15:23:04 -04:00
}
// Create duplicate tasks for this, as jacoco slows things down a bit
gametestCoverage {
inherit gametest
name "Game Test Coverage"
ideConfigGenerated = false
}
autoTestClientCoverage {
inherit autoTestClient
name "Auto Test Client Coverage"
ideConfigGenerated = false
}
}
}
test.dependsOn runGametest
def coverageTasks = [
runGametestCoverage,
runAutoTestClientCoverage
]
jacoco {
coverageTasks.forEach {
applyTo it
}
}
tasks.register('coverage', JacocoReport) {
dependsOn coverageTasks
coverageTasks.forEach {
executionData it
}
// Add all source as input
allprojects { p ->
2024-02-10 16:24:55 -05:00
if (p.path.startsWith(":deprecated") || metaProjects.contains(p.name)) {
return
}
sourceSets p.sourceSets.main, p.sourceSets.client, p.sourceSets.testmod, p.sourceSets.testmodClient
}
// Exclude mixins
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: '**/mixin/**')
}))
}
configurations {
productionRuntime {
extendsFrom configurations.minecraftLibraries
extendsFrom configurations.loaderLibraries
extendsFrom configurations.minecraftRuntimeLibraries
}
productionRuntimeServer
}
dependencies {
productionRuntime "net.fabricmc:fabric-loader:${project.loader_version}"
productionRuntime "net.fabricmc:intermediary:${project.minecraft_version}"
productionRuntimeServer "net.fabricmc:fabric-installer:${project.installer_version}:server"
}
import net.fabricmc.loom.util.Platform
// This is very far beyond loom's API if you copy this, you're on your own.
tasks.register('runProductionAutoTestClient', JavaExec) {
dependsOn remapJar, remapTestmodJar, downloadAssets
classpath.from configurations.productionRuntime
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
workingDir = file("run")
doFirst {
classpath.from loom.minecraftProvider.minecraftClientJar
workingDir.mkdirs()
args(
"--assetIndex", loom.minecraftProvider.versionInfo.assetIndex().fabricId(loom.minecraftProvider.minecraftVersion()),
"--assetsDir", new File(loom.files.userCache, "assets").absolutePath,
"--gameDir", workingDir.absolutePath
)
if (Platform.CURRENT.operatingSystem.isMacOS()) {
jvmArgs(
"-XstartOnFirstThread"
)
}
jvmArgs(
"-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}",
"-Dfabric.autoTest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
)
jvmArgs(debugArgs)
}
}
tasks.register('serverPropertiesJar', Jar) {
def propsFile = file("build/tmp/install.properties")
doFirst {
propsFile.text = """\
fabric-loader-version=${project.loader_version}
game-version=${project.minecraft_version}
""".stripMargin().stripIndent()
}
archiveFileName = "test-server-properties.jar"
destinationDirectory = file("build/tmp")
from(propsFile)
}
tasks.register('runProductionAutoTestServer', JavaExec) {
// TODO re-enable with https://github.com/FabricMC/fabric-loader/pull/967
enabled = false
dependsOn remapJar, remapTestmodJar, serverPropertiesJar
classpath.from configurations.productionRuntimeServer, serverPropertiesJar
mainClass = "net.fabricmc.installer.ServerLauncher"
workingDir = file("run")
doFirst {
workingDir.mkdirs()
jvmArgs(
"-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}",
"-Dfabric.autoTest",
)
jvmArgs(debugArgs)
args("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 12:56:50 -04:00
dependencies {
2021-05-12 15:23:04 -04: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 12:56:50 -04:00
}
2019-04-23 19:14:43 -04:00
publishing {
publications {
mavenJava(MavenPublication) {
pom {
addPomMetadataInformation(project, pom)
}
artifact(signRemapJar.output) {
builtBy(signRemapJar)
}
artifact(remapSourcesJar) {
builtBy remapSourcesJar
}
2019-04-23 19:14:43 -04:00
}
2019-07-24 17:07:45 -04:00
}
2019-04-23 19:14:43 -04:00
}
// 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-23 19:14:43 -04:00
}
2019-04-23 19:14:43 -04:00
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
artifact remapTestmodJar
pom {
addPomMetadataInformation(rootProject, pom)
}
pom.withXml {
def depsNode = asNode().appendNode("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
}
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
2019-05-17 10:20:37 -04:00
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
// Depend on the deprecated BOM to allow opting out of deprecated modules.
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", group)
depNode.appendNode("artifactId", "fabric-api-deprecated")
depNode.appendNode("version", version)
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 13:42:42 -04:00
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
void setupRepositories(RepositoryHandler repositories) {
//repositories.mavenLocal() // uncomment for testing
def ENV = System.getenv()
if (ENV.MAVEN_URL) {
repositories.maven {
url ENV.MAVEN_URL
if (ENV.MAVEN_USERNAME) {
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
2019-04-23 19:14:43 -04: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-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
}
}
}
remapJar {
afterEvaluate {
subprojects.each {
if (it.name in devOnlyModules || metaProjects.contains(it.name)) {
return
}
// Include the signed or none signed jar from the sub project.
nestedJars.from project("${it.path}").tasks.getByName("signRemapJar")
}
}
}
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 13:10:52 -04: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-11 18:00:57 -04:00
}
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "P7dR8mSH"
minecraftVersions.add(project.minecraft_version)
2019-05-11 18:00:57 -04: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 13:58:47 -04: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