mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-16 10:45:15 +01:00
242 lines
7.1 KiB
Groovy
242 lines
7.1 KiB
Groovy
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
// Stolen https://github.com/FabricMC/fabric/blob/1.17/build.gradle
|
|
plugins {
|
|
id "java"
|
|
id "maven-publish"
|
|
id "fabric-loom" version "0.8-SNAPSHOT" apply false
|
|
id "org.ajoberstar.grgit" version "3.1.1"
|
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
|
}
|
|
|
|
def ENV = System.getenv()
|
|
def vvVer = "4.0.0-21w20a-SNAPSHOT"
|
|
|
|
description = "Client-side and server-side ViaVersion implementation for Fabric"
|
|
version = "0.4.0+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
|
|
logger.lifecycle("Building ViaFabric: $version")
|
|
|
|
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)
|
|
}
|
|
|
|
allprojects {
|
|
apply plugin: "maven-publish"
|
|
apply plugin: "fabric-loom"
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
def targetVersion = 8
|
|
if (JavaVersion.current().isJava9Compatible()) {
|
|
it.options.release = targetVersion
|
|
} else {
|
|
sourceCompatibility = JavaVersion.toVersion(targetVersion)
|
|
targetCompatibility = JavaVersion.toVersion(targetVersion)
|
|
}
|
|
}
|
|
|
|
group = "com.viaversion.fabric"
|
|
|
|
configurations {
|
|
dev
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven { url = "https://repo.viaversion.com/" }
|
|
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
|
|
maven { url = "https://maven.fabricmc.net/" }
|
|
maven { url = "https://server.bbkr.space/artifactory/libs-snapshot" }
|
|
maven { url = "https://server.bbkr.space/artifactory/libs-release" }
|
|
maven { url = "https://maven.legacyfabric.net/" }
|
|
maven { url = "https://maven.terraformersmc.com/releases/" }
|
|
}
|
|
|
|
dependencies {
|
|
// transitive = false because Guava is conflicting on runClient
|
|
implementation("com.viaversion:viaversion:$vvVer") { transitive = false }
|
|
implementation("org.yaml:snakeyaml:1.28")
|
|
|
|
modImplementation("net.fabricmc:fabric-loader:0.11.3")
|
|
}
|
|
|
|
jar {
|
|
archiveClassifier = "dev"
|
|
}
|
|
|
|
afterEvaluate {
|
|
remapJar {
|
|
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
|
|
archiveFileName = "${archivesBaseName}-${version}.jar"
|
|
}
|
|
|
|
artifacts {
|
|
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
filesMatching("fabric.mod.json") {
|
|
filter(ReplaceTokens, tokens: [
|
|
version : rootProject.version,
|
|
description: rootProject.description
|
|
])
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
archiveClassifier = "sources"
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
minecraft {
|
|
intermediaryUrl = {
|
|
if (it == "1.8.9") "https://maven.legacyfabric.net/net/fabricmc/intermediary/$it/intermediary-$it-v2.jar"
|
|
else "https://maven.fabricmc.net/net/fabricmc/intermediary/$it/intermediary-$it-v2.jar"
|
|
}
|
|
}
|
|
}
|
|
|
|
subprojects {
|
|
dependencies {
|
|
implementation rootProject
|
|
}
|
|
|
|
task remapMavenJar(type: Copy, dependsOn: remapJar) {
|
|
afterEvaluate {
|
|
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
|
|
into("${project.buildDir}/libs/")
|
|
rename { String fn -> "$archivesBaseName-${version}-maven.jar" }
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
afterEvaluate {
|
|
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
|
|
builtBy remapMavenJar
|
|
}
|
|
|
|
artifact(sourcesJar) {
|
|
builtBy remapSourcesJar
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
setupRepositories(repositories)
|
|
}
|
|
}
|
|
|
|
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
|
|
afterEvaluate {
|
|
input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
|
|
archiveFileName = "${archivesBaseName}-${version}-maven.jar"
|
|
addNestedDependencies = false
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
|
|
builtBy remapMavenJar
|
|
}
|
|
|
|
artifact(sourcesJar) {
|
|
builtBy remapSourcesJar
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
setupRepositories(repositories)
|
|
}
|
|
|
|
void setupRepositories(RepositoryHandler repositories) {
|
|
//repositories.mavenLocal() // uncomment for testing
|
|
def ENV = System.getenv()
|
|
if (ENV.MAVEN_URL) {
|
|
repositories.maven {
|
|
url ENV.MAVEN_URL
|
|
credentials {
|
|
username ENV.MAVEN_USERNAME
|
|
password ENV.MAVEN_PASSWORD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
|
|
|
|
dependencies {
|
|
minecraft("com.mojang:minecraft:1.8.9")
|
|
mappings("net.fabricmc:yarn:1.8.9+build.202103291533:v2")
|
|
|
|
include("com.viaversion:viaversion:$vvVer")
|
|
include("org.yaml:snakeyaml:1.28")
|
|
|
|
subprojects.each {
|
|
include project("${it.name}:")
|
|
}
|
|
}
|
|
|
|
curseforge {
|
|
if (ENV.CURSEFORGE_API_KEY) {
|
|
apiKey = ENV.CURSEFORGE_API_KEY
|
|
}
|
|
|
|
project {
|
|
id = "391298"
|
|
changelog = "A changelog can be found at https://github.com/ViaVersion/ViaFabric/commits"
|
|
releaseType = "alpha"
|
|
Arrays.<String> asList("1.17", "1.16.5", "1.15.2", "1.14.4", "1.8.9",
|
|
"Java 8", "Java 9", "Java 10", "Java 11", "Java 12", "Java 13", "Java 14", "Java 15", "Java 16", "Fabric")
|
|
.forEach { ver -> addGameVersion(ver) }
|
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
|
displayName = "[${getBranch()}] ViaFabric " + rootProject.version
|
|
relations {
|
|
optionalDependency("fabric-api")
|
|
optionalDependency("legacy-fabric-api")
|
|
optionalDependency("cotton-client-commands")
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
uploadTask.dependsOn("remapJar")
|
|
}
|
|
}
|
|
|
|
options {
|
|
forgeGradleIntegration = false
|
|
}
|
|
}
|
|
|
|
if (getBranch() == "main" && ENV.CURSEFORGE_API_KEY && !ENV.CURSEFORGE_API_KEY.isEmpty()) {
|
|
defaultTasks("clean", "build", "curseforge")
|
|
} else {
|
|
defaultTasks("clean", "build")
|
|
}
|