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-02 18:17:19 +02:00
|
|
|
id "fabric-loom" version "0.7-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()
|
|
|
|
|
|
|
|
class Globals {
|
|
|
|
static def baseVersion = "0.4.0"
|
|
|
|
}
|
|
|
|
|
|
|
|
version = Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
|
|
|
|
logger.lifecycle("Building ViaFabric: " + version)
|
|
|
|
|
|
|
|
import net.fabricmc.loom.task.RunClientTask
|
|
|
|
import net.fabricmc.loom.task.RunServerTask
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
def moduleDependencies(project, List<String> depNames) {
|
|
|
|
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'dev') }
|
|
|
|
project.dependencies {
|
|
|
|
deps.each {
|
|
|
|
compile it
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testmod {
|
|
|
|
compileClasspath += main.compileClasspath
|
|
|
|
runtimeClasspath += main.runtimeClasspath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task runTestmodClient(type: RunClientTask) {
|
|
|
|
classpath sourceSets.testmod.runtimeClasspath
|
|
|
|
}
|
|
|
|
|
|
|
|
task runTestmodServer(type: RunServerTask) {
|
|
|
|
classpath sourceSets.testmod.runtimeClasspath
|
|
|
|
}
|
|
|
|
|
|
|
|
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:4.0.0-21w17a") { transitive = false }
|
|
|
|
implementation("org.yaml:snakeyaml:1.28")
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
filesMatching("fabric.mod.json") {
|
|
|
|
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
|
2021-05-02 17:01:24 +02:00
|
|
|
version : version,
|
|
|
|
description: 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
|
|
|
}
|
|
|
|
|
|
|
|
javadoc {
|
|
|
|
options {
|
|
|
|
source = "8"
|
|
|
|
encoding = "UTF-8"
|
|
|
|
charSet = "UTF-8"
|
|
|
|
memberLevel = JavadocMemberLevel.PACKAGE
|
|
|
|
links(
|
|
|
|
"https://guava.dev/releases/21.0/api/docs/",
|
|
|
|
"https://asm.ow2.io/javadoc/",
|
|
|
|
"https://docs.oracle.com/javase/8/docs/api/",
|
|
|
|
"http://jenkins.liteloader.com/job/Mixin/javadoc/",
|
|
|
|
"https://logging.apache.org/log4j/2.x/log4j-api/apidocs/"
|
|
|
|
// Need to add minecraft jd publication etc once there is one available
|
|
|
|
)
|
|
|
|
// Disable the crazy super-strict doclint tool in Java 8
|
|
|
|
addStringOption("Xdoclint:none", "-quiet")
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects.each {
|
|
|
|
source(it.sourceSets.main.allJava.srcDirs)
|
|
|
|
}
|
|
|
|
|
|
|
|
classpath = sourceSets.main.compileClasspath
|
|
|
|
include("**/api/**")
|
|
|
|
failOnError false
|
|
|
|
}
|
|
|
|
|
|
|
|
task javadocJar(type: 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
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
javadoc.enabled = false
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
artifact javadocJar
|
|
|
|
|
|
|
|
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") }
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testmod
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
minecraft("com.mojang:minecraft:1.8.9")
|
|
|
|
mappings("net.fabricmc:yarn:1.8.9+build.202103291533:v2")
|
2021-05-02 18:17:19 +02:00
|
|
|
modImplementation("net.fabricmc:fabric-loader:0.10.5+build.213")
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2021-05-02 17:01:24 +02:00
|
|
|
include("com.viaversion:viaversion:4.0.0-21w17a")
|
|
|
|
include("org.yaml:snakeyaml:1.28")
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
afterEvaluate {
|
|
|
|
subprojects.each {
|
2021-05-02 18:17:19 +02:00
|
|
|
//implementation project(path: ":${it.name}", configuration: "dev")
|
2021-05-02 16:01:46 +02:00
|
|
|
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"
|
2021-05-02 17:01:24 +02:00
|
|
|
Arrays.<String> asList("1.17", "1.16.5", "1.15.2", "1.14.4", "1.8.9", "Java 8", "Java 9", "Java 10", "Fabric")
|
|
|
|
.forEach { ver -> addGameVersion(ver) }
|
2021-05-02 16:01:46 +02:00
|
|
|
|
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
|
|
|
displayName = "[${getBranch()}] ViaFabric $Globals.baseVersion"
|
2021-05-02 17:01:24 +02:00
|
|
|
relations {
|
|
|
|
requiredDependency("fabric-api")
|
|
|
|
requiredDependency("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
|
|
|
|
|
|
|
if (getBranch() == "master" && ENV.CURSEFORGE_API_KEY && !ENV.CURSEFORGE_API_KEY.isEmpty()) {
|
|
|
|
defaultTasks("clean", "build", "curseforge")
|
|
|
|
} else {
|
|
|
|
defaultTasks("clean", "build")
|
2021-05-02 18:21:27 +02:00
|
|
|
}
|