mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 17:46:25 -05:00
9be3744a3b
For now this will only be for 1.16.2
311 lines
7.6 KiB
Groovy
311 lines
7.6 KiB
Groovy
buildscript {
|
|
dependencies {
|
|
classpath 'org.kohsuke:github-api:1.114'
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'java'
|
|
id 'eclipse'
|
|
id 'idea'
|
|
id 'maven-publish'
|
|
id 'fabric-loom' version '0.5-SNAPSHOT' apply false
|
|
id 'net.minecrell.licenser' version '0.4.1'
|
|
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.16.1"
|
|
static def mcVersion = "1.16.2-pre1"
|
|
static def yarnVersion = "+build.1"
|
|
}
|
|
|
|
version = Globals.baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") + "-" + getBranch()
|
|
logger.lifecycle("Building Fabric: " + version)
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils
|
|
|
|
def getSubprojectVersion(project, version) {
|
|
if (grgit == null) {
|
|
return version + "+nogit"
|
|
}
|
|
def latestCommits = grgit.log(paths: [project.name], maxCommits: 1)
|
|
if (latestCommits.isEmpty()) {
|
|
return version + "+uncommited"
|
|
} else {
|
|
return version + "+" + latestCommits.get(0).id.substring(0, 8) + DigestUtils.sha256Hex(Globals.mcVersion).substring(0, 2)
|
|
}
|
|
}
|
|
|
|
def getBranch() {
|
|
if (System.getenv().GIT_BRANCH) {
|
|
def branch = System.getenv().GIT_BRANCH
|
|
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: 'checkstyle'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'fabric-loom'
|
|
apply plugin: 'net.minecrell.licenser'
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
|
|
group = "net.fabricmc.fabric-api"
|
|
|
|
sourceSets {
|
|
testmod {
|
|
compileClasspath += main.compileClasspath
|
|
runtimeClasspath += main.runtimeClasspath
|
|
}
|
|
}
|
|
|
|
loom {
|
|
shareCaches = true
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "com.mojang:minecraft:$Globals.mcVersion"
|
|
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
|
|
modCompile "net.fabricmc:fabric-loader:0.8.9+build.203"
|
|
}
|
|
|
|
configurations {
|
|
dev
|
|
}
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
}
|
|
|
|
jar {
|
|
classifier = "dev"
|
|
}
|
|
|
|
afterEvaluate {
|
|
remapJar {
|
|
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
|
|
archiveName = "${archivesBaseName}-${version}.jar"
|
|
}
|
|
|
|
artifacts {
|
|
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
|
|
}
|
|
|
|
processResources {
|
|
inputs.property "version", project.version
|
|
|
|
from(sourceSets.main.resources.srcDirs) {
|
|
include "fabric.mod.json"
|
|
expand "version": project.version
|
|
}
|
|
|
|
from(sourceSets.main.resources.srcDirs) {
|
|
exclude "fabric.mod.json"
|
|
}
|
|
}
|
|
|
|
license {
|
|
header rootProject.file('HEADER')
|
|
include '**/*.java'
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
checkstyle {
|
|
configFile = rootProject.file("checkstyle.xml")
|
|
toolVersion = '8.31'
|
|
}
|
|
}
|
|
|
|
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
|
|
classifier = 'fatjavadoc'
|
|
}
|
|
build.dependsOn javadocJar
|
|
|
|
subprojects {
|
|
|
|
dependencies {
|
|
testmodCompile sourceSets.main.output
|
|
}
|
|
|
|
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")
|
|
archiveName = "${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
|
|
}
|
|
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
|
|
if (project.hasProperty('mavenPass')) {
|
|
repositories.maven {
|
|
url "http://mavenupload.modmuss50.me/"
|
|
credentials {
|
|
username 'buildslave'
|
|
password project.getProperty('mavenPass')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task licenseFormatAll
|
|
subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
|
|
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
|
|
|
|
sourceSets {
|
|
testmod
|
|
}
|
|
|
|
dependencies {
|
|
afterEvaluate {
|
|
subprojects.each {
|
|
compile project(path: ":${it.name}", configuration: "dev")
|
|
include project("${it.name}:")
|
|
|
|
testmodCompile project("${it.name}:").sourceSets.testmod.output
|
|
}
|
|
}
|
|
}
|
|
|
|
curseforge {
|
|
if (project.hasProperty('curse_api_key')) {
|
|
apiKey = project.getProperty('curse_api_key')
|
|
}
|
|
project {
|
|
id = '306612'
|
|
changelog = 'A changelog can be found at https://github.com/FabricMC/fabric/commits'
|
|
releaseType = 'beta'
|
|
addGameVersion '1.16-Snapshot'
|
|
addGameVersion 'Fabric'
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
|
displayName = "[$Globals.mcVersion] Fabric API $Globals.baseVersion build $ENV.BUILD_NUMBER"
|
|
}
|
|
afterEvaluate {
|
|
uploadTask.dependsOn("remapJar")
|
|
}
|
|
}
|
|
options {
|
|
forgeGradleIntegration = false
|
|
}
|
|
}
|
|
|
|
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'
|
|
|
|
import org.kohsuke.github.GHReleaseBuilder
|
|
import org.kohsuke.github.GitHub
|
|
|
|
task github(dependsOn: remapMavenJar) {
|
|
onlyIf {
|
|
project.hasProperty('github_api_key')
|
|
}
|
|
doLast {
|
|
def github = GitHub.connectUsingOAuth(project.getProperty('github_api_key') as String)
|
|
def repository = github.getRepository("FabricMC/fabric")
|
|
|
|
def releaseBuilder = new GHReleaseBuilder(repository, version as String)
|
|
releaseBuilder.name("[$Globals.mcVersion] Fabric API $Globals.baseVersion build $ENV.BUILD_NUMBER")
|
|
releaseBuilder.body('A changelog can be found at https://github.com/FabricMC/fabric/commits')
|
|
releaseBuilder.commitish(getBranch())
|
|
|
|
def ghRelease = releaseBuilder.create()
|
|
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
|
|
}
|
|
}
|