2021-07-16 12:03:07 +02:00
|
|
|
// todo migrate this code to kotlin
|
2021-05-14 02:05:30 +02:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
// Stolen https://github.com/FabricMC/fabric/blob/1.17/build.gradle
|
|
|
|
plugins {
|
|
|
|
id "java"
|
|
|
|
id "maven-publish"
|
2021-05-14 02:05:30 +02:00
|
|
|
id "fabric-loom" version "0.8-SNAPSHOT" apply false
|
2021-05-02 16:01:46 +02:00
|
|
|
id "org.ajoberstar.grgit" version "3.1.1"
|
|
|
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
|
|
|
}
|
|
|
|
|
|
|
|
def ENV = System.getenv()
|
2021-07-07 17:19:30 +02:00
|
|
|
def vvVer = "4.0.2-SNAPSHOT"
|
2021-06-17 20:04:30 +02:00
|
|
|
def yamlVer = "1.29"
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2021-05-02 19:13:07 +02:00
|
|
|
description = "Client-side and server-side ViaVersion implementation for Fabric"
|
2021-07-07 16:08:52 +02:00
|
|
|
version = "0.4.3+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
|
2021-05-14 02:05:30 +02:00
|
|
|
logger.lifecycle("Building ViaFabric: $version")
|
2021-05-02 16:01:46 +02:00
|
|
|
|
|
|
|
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/" }
|
2021-07-16 12:09:40 +02:00
|
|
|
//maven { url = "https://maven.terraformersmc.com/releases/" }
|
2021-07-16 12:03:07 +02:00
|
|
|
maven { url = "https://raw.githubusercontent.com/TerraformersMC/Archive/main/releases/" }
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
// transitive = false because Guava is conflicting on runClient
|
2021-05-06 01:11:28 +02:00
|
|
|
implementation("com.viaversion:viaversion:$vvVer") { transitive = false }
|
2021-06-17 20:04:30 +02:00
|
|
|
implementation("org.yaml:snakeyaml:$yamlVer")
|
2021-05-10 01:34:48 +02:00
|
|
|
|
2021-06-17 20:04:30 +02:00
|
|
|
modImplementation("net.fabricmc:fabric-loader:0.11.6")
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
2021-05-02 17:01:24 +02:00
|
|
|
archiveClassifier = "dev"
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
remapJar {
|
|
|
|
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
|
2021-05-02 17:01:24 +02:00
|
|
|
archiveFileName = "${archivesBaseName}-${version}.jar"
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
|
|
|
|
}
|
2021-05-10 01:34:48 +02:00
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
processResources {
|
|
|
|
filesMatching("fabric.mod.json") {
|
2021-05-14 02:05:30 +02:00
|
|
|
filter(ReplaceTokens, tokens: [
|
2021-05-10 01:34:48 +02:00
|
|
|
version : rootProject.version,
|
|
|
|
description: rootProject.description
|
|
|
|
])
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
|
|
archiveClassifier = "sources"
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
}
|
2021-05-02 17:56:59 +02:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
subprojects {
|
|
|
|
dependencies {
|
|
|
|
implementation rootProject
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
2021-05-02 17:01:24 +02:00
|
|
|
archiveFileName = "${archivesBaseName}-${version}-maven.jar"
|
2021-05-02 16:01:46 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-04 20:26:43 +02:00
|
|
|
subprojects.each {
|
|
|
|
remapJar.dependsOn("${it.path}:remapJar")
|
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
|
|
|
|
dependencies {
|
|
|
|
minecraft("com.mojang:minecraft:1.8.9")
|
|
|
|
mappings("net.fabricmc:yarn:1.8.9+build.202103291533:v2")
|
|
|
|
|
2021-05-06 01:11:28 +02:00
|
|
|
include("com.viaversion:viaversion:$vvVer")
|
2021-06-17 20:04:30 +02:00
|
|
|
include("org.yaml:snakeyaml:$yamlVer")
|
2021-05-02 17:01:24 +02:00
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
subprojects.each {
|
|
|
|
include project("${it.name}:")
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2021-07-07 14:15:51 +02:00
|
|
|
Arrays.<String> asList("1.17.1", "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", "Java 17", "Fabric")
|
2021-05-02 17:01:24 +02:00
|
|
|
.forEach { ver -> addGameVersion(ver) }
|
2021-05-02 16:01:46 +02:00
|
|
|
|
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
2021-05-02 19:35:52 +02:00
|
|
|
displayName = "[${getBranch()}] ViaFabric " + rootProject.version
|
2021-05-02 17:01:24 +02:00
|
|
|
relations {
|
2021-05-04 23:14:54 +02:00
|
|
|
optionalDependency("fabric-api")
|
|
|
|
optionalDependency("legacy-fabric-api")
|
2021-05-02 17:26:15 +02:00
|
|
|
optionalDependency("cotton-client-commands")
|
2021-05-02 17:01:24 +02:00
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
uploadTask.dependsOn("remapJar")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
forgeGradleIntegration = false
|
|
|
|
}
|
|
|
|
}
|
2021-05-02 17:01:24 +02:00
|
|
|
|
2021-05-02 18:49:49 +02:00
|
|
|
if (getBranch() == "main" && ENV.CURSEFORGE_API_KEY && !ENV.CURSEFORGE_API_KEY.isEmpty()) {
|
2021-05-02 17:01:24 +02:00
|
|
|
defaultTasks("clean", "build", "curseforge")
|
|
|
|
} else {
|
|
|
|
defaultTasks("clean", "build")
|
2021-05-02 18:21:27 +02:00
|
|
|
}
|