2022-08-27 17:45:51 +02:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = 'Fabric'
|
|
|
|
url = 'https://maven.fabricmc.net/'
|
|
|
|
}
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
|
|
|
name = 'CurseGradle'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/32776914/packages/maven'
|
|
|
|
}
|
|
|
|
gradlePluginPortal()
|
|
|
|
if (project.hasProperty("libjf_version")) {
|
|
|
|
maven {
|
|
|
|
name = 'JF Commons'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/35745143/packages/maven'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = 'LibJF'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/25805200/packages/maven'
|
|
|
|
}
|
|
|
|
}
|
2022-08-28 11:07:22 +02:00
|
|
|
mavenLocal()
|
2022-08-27 17:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2022-08-28 15:02:26 +02:00
|
|
|
classpath "net.fabricmc:fabric-loom:1.0-SNAPSHOT"
|
2022-08-27 17:45:51 +02:00
|
|
|
classpath "org.ajoberstar.grgit:grgit-gradle:5.0.0"
|
|
|
|
classpath "com.modrinth.minotaur:Minotaur:2.3.1"
|
|
|
|
classpath "io.gitlab.jfronny:CurseGradle:1.4.0-1642087331626"
|
|
|
|
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
|
|
|
|
if (project.hasProperty("libjf_version")) classpath "io.gitlab.jfronny.libjf:libjf-config-compiler-plugin:${project.getProperty("libjf_version")}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.curseforgeAvailable = project.hasProperty("curseforge_id")
|
|
|
|
ext.modrinthAvailable = project.hasProperty("modrinth_id")
|
|
|
|
|
|
|
|
ext.devOnlyModules = project.hasProperty("dev_only_module") ? project.getProperty("dev_only_module").split(", ") : []
|
|
|
|
ext.nonModSubprojects = project.hasProperty("non_mod_project") ? project.getProperty("non_mod_project").split(", ") : []
|
2022-08-28 13:20:14 +02:00
|
|
|
ext.injectConfig = project.hasProperty("libjf_version")
|
2022-08-28 13:22:05 +02:00
|
|
|
if (ext.injectConfig) ext.configCompilerVersion = project.getProperty("libjf_version")
|
2022-08-27 17:45:51 +02:00
|
|
|
|
|
|
|
apply plugin: 'idea'
|
|
|
|
apply plugin: 'java-library'
|
|
|
|
apply plugin: 'maven-publish'
|
|
|
|
if (ext.curseforgeAvailable) apply plugin: com.matthewprenger.cursegradle.CurseGradlePlugin
|
|
|
|
if (ext.modrinthAvailable) apply plugin: com.modrinth.minotaur.Minotaur
|
2022-08-28 13:22:05 +02:00
|
|
|
if (ext.injectConfig) apply plugin: io.gitlab.jfronny.libjf.config.plugin.ConfigPlugin
|
2022-08-27 17:45:51 +02:00
|
|
|
apply plugin: org.ajoberstar.grgit.gradle.GrgitPlugin
|
|
|
|
|
|
|
|
enum VersionType { release, beta, alpha }
|
|
|
|
|
|
|
|
// Fetch changelog
|
|
|
|
def changelogStr = ""
|
|
|
|
ext.currentVer = "0.0.0+nogit"
|
|
|
|
ext.currentType = VersionType.alpha
|
|
|
|
if (grgit != null) {
|
|
|
|
ext.currentVer = "0.0.0+notag"
|
|
|
|
grgit.open(dir: project.projectDir.toString())
|
|
|
|
def tagList = grgit.tag.list()
|
|
|
|
tagList.sort((left, right) -> right.commit.dateTime.compareTo(left.commit.dateTime))
|
|
|
|
if (tagList.size() >= 1) {
|
|
|
|
if (tagList.get(0).fullMessage != null) {
|
|
|
|
changelogStr += tagList.get(0).fullMessage + "\n"
|
|
|
|
}
|
|
|
|
ext.currentType = VersionType.release
|
|
|
|
ext.currentVer = tagList.get(0).getName()
|
|
|
|
switch (ext.currentVer[0]) {
|
|
|
|
case 'v':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
break
|
|
|
|
case 'b':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
ext.currentType = VersionType.beta
|
|
|
|
break
|
|
|
|
case 'a':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
ext.currentType = VersionType.alpha
|
|
|
|
break
|
|
|
|
}
|
|
|
|
def commits = new ArrayList<>(tagList.size() >= 2
|
|
|
|
? grgit.log{range(tagList.get(1).fullName, tagList.get(0).fullName)}
|
|
|
|
: grgit.log(includes: [grgit.tag.list().get(0).fullName]))
|
|
|
|
Collections.reverse(commits)
|
|
|
|
changelogStr += "Commits in " + ext.currentType.toString() + " " + ext.currentVer + ":\n"
|
|
|
|
for (def commit : commits) {
|
|
|
|
changelogStr += "- " + commit.shortMessage + "\n"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (changelogStr == "") {
|
|
|
|
changelogStr = "No changelog"
|
|
|
|
}
|
|
|
|
if (!project.hasProperty("release")) {
|
|
|
|
ext.currentVer += "-" + Instant.now().getEpochSecond()
|
|
|
|
}
|
|
|
|
println(changelogStr)
|
|
|
|
|
|
|
|
if (!project.hasProperty("modrinth_required_dependencies"))
|
|
|
|
project.ext.modrinth_required_dependencies = ""
|
|
|
|
else
|
|
|
|
project.ext.modrinth_required_dependencies = project.modrinth_required_dependencies
|
|
|
|
if (!project.hasProperty("modrinth_optional_dependencies"))
|
|
|
|
project.ext.modrinth_optional_dependencies = ""
|
|
|
|
else
|
|
|
|
project.ext.modrinth_optional_dependencies = project.modrinth_optional_dependencies
|
|
|
|
if (!project.hasProperty("curseforge_required_dependencies"))
|
|
|
|
project.ext.curseforge_required_dependencies = ""
|
|
|
|
else
|
|
|
|
project.ext.curseforge_required_dependencies = project.curseforge_required_dependencies
|
|
|
|
if (!project.hasProperty("curseforge_optional_dependencies"))
|
|
|
|
project.ext.curseforge_optional_dependencies = ""
|
|
|
|
else
|
|
|
|
project.ext.curseforge_optional_dependencies = project.curseforge_optional_dependencies
|
|
|
|
|
|
|
|
task deployDebug() {
|
|
|
|
}
|
|
|
|
|
|
|
|
task deployRelease() {
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.deployRelease.dependsOn(tasks.deployDebug)
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
if (project.name in rootProject.nonModSubprojects) return
|
|
|
|
|
|
|
|
apply plugin: "java-library"
|
|
|
|
apply plugin: "maven-publish"
|
|
|
|
apply plugin: net.fabricmc.loom.bootstrap.LoomGradlePluginBootstrap
|
|
|
|
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
2022-08-28 13:23:41 +02:00
|
|
|
if (rootProject.injectConfig) apply plugin: io.gitlab.jfronny.libjf.config.plugin.ConfigPlugin
|
2022-08-27 17:45:51 +02:00
|
|
|
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
it.options.encoding = "UTF-8"
|
|
|
|
it.options.release = 17
|
|
|
|
}
|
|
|
|
|
|
|
|
if (project.hasProperty("archives_base_name"))
|
|
|
|
archivesBaseName = project.archives_base_name
|
|
|
|
|
|
|
|
group = project.maven_group
|
2022-08-28 13:23:41 +02:00
|
|
|
version = "$rootProject.currentVer"
|
2022-08-27 17:45:51 +02:00
|
|
|
|
|
|
|
loom {
|
|
|
|
runtimeOnlyLog4j = true
|
|
|
|
splitEnvironmentSourceSets()
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testmod {
|
|
|
|
compileClasspath += main.compileClasspath
|
|
|
|
runtimeClasspath += main.runtimeClasspath
|
|
|
|
|
|
|
|
compileClasspath += client.compileClasspath
|
|
|
|
runtimeClasspath += client.runtimeClasspath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
|
|
if (project.hasProperty("yarn_mappings")) {
|
|
|
|
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
|
|
|
|
} else {
|
|
|
|
mappings loom.officialMojangMappings()
|
|
|
|
}
|
|
|
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
|
|
|
|
|
|
testmodImplementation sourceSets.main.output
|
|
|
|
testmodImplementation sourceSets.client.output
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = 'TerraformersMC'
|
|
|
|
url = 'https://maven.terraformersmc.com/'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = 'LibJF'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/25805200/packages/maven'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = 'JF Gson'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/35030495/packages/maven'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = 'JF Commons'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/35745143/packages/maven'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = 'JF FLoader'
|
|
|
|
url = 'https://gitlab.com/api/v4/projects/36014652/packages/maven'
|
|
|
|
}
|
|
|
|
mavenCentral()
|
2022-08-28 11:07:22 +02:00
|
|
|
mavenLocal()
|
2022-08-27 17:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
dev
|
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
|
|
|
archiveClassifier = 'dev'
|
|
|
|
}
|
|
|
|
|
|
|
|
var shadowJarInput = jar
|
|
|
|
|
2022-08-28 13:23:41 +02:00
|
|
|
if (rootProject.injectConfig) {
|
2022-08-27 17:45:51 +02:00
|
|
|
task injectCompiledConfig(type: io.gitlab.jfronny.libjf.config.plugin.ConfigInjectTask, dependsOn: jar) {
|
|
|
|
from jar
|
|
|
|
modId = archivesBaseName
|
|
|
|
archiveClassifier = 'config-inject'
|
|
|
|
destinationDirectory = file("${project.buildDir}/devlibs")
|
|
|
|
}
|
|
|
|
shadowJarInput = injectCompiledConfig
|
|
|
|
}
|
|
|
|
|
2022-09-26 18:08:16 +02:00
|
|
|
task completeJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar, dependsOn: shadowJarInput) {
|
2022-08-27 17:45:51 +02:00
|
|
|
from shadowJarInput
|
|
|
|
configurations = [ project.configurations.shadow ]
|
|
|
|
archiveClassifier = 'shadow'
|
|
|
|
destinationDirectory = file("${project.buildDir}/devlibs")
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
remapJar {
|
2022-09-26 18:07:22 +02:00
|
|
|
dependsOn completeJar
|
2022-08-27 17:45:51 +02:00
|
|
|
|
2022-09-26 18:07:22 +02:00
|
|
|
input = completeJar.archiveFile
|
2022-08-27 17:45:51 +02:00
|
|
|
archiveFileName = "${archivesBaseName}-${project.version}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
dev file: jar.archiveFile.get().asFile, type: "jar", builtBy: jar
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
inputs.property 'version', project.version
|
|
|
|
|
|
|
|
filesMatching('fabric.mod.json') {
|
|
|
|
expand 'version': project.version
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
project.rootProject.allprojects.each { sub ->
|
|
|
|
if (!(sub.name in rootProject.nonModSubprojects)) {
|
|
|
|
loom.mods.register(sub.name, {
|
|
|
|
sourceSet sub.sourceSets.main
|
|
|
|
sourceSet sub.sourceSets.client
|
|
|
|
})
|
|
|
|
loom.mods.register(sub.name + "-testmod", {
|
|
|
|
sourceSet sub.sourceSets.testmod
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
java {
|
|
|
|
withSourcesJar()
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(AbstractArchiveTask) {
|
|
|
|
preserveFileTimestamps = false
|
|
|
|
reproducibleFileOrder = true
|
|
|
|
}
|
|
|
|
|
2022-09-26 18:07:22 +02:00
|
|
|
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: completeJar) {
|
|
|
|
input = completeJar.archiveFile
|
2022-08-27 17:45:51 +02:00
|
|
|
archiveFileName = "${archivesBaseName}-${project.version}-maven.jar"
|
|
|
|
addNestedDependencies = false
|
|
|
|
}
|
|
|
|
build.dependsOn remapMavenJar
|
|
|
|
|
|
|
|
task testmodJar(type: Jar) { //TODO include deps
|
|
|
|
from sourceSets.testmod.output
|
|
|
|
destinationDirectory = new File(project.buildDir, "devlibs")
|
|
|
|
archiveClassifier = "testmod"
|
|
|
|
}
|
|
|
|
|
|
|
|
task remapTestmodJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: testmodJar) {
|
|
|
|
input = testmodJar.archiveFile
|
|
|
|
archiveClassifier = "testmod"
|
|
|
|
addNestedDependencies = false
|
|
|
|
}
|
|
|
|
build.dependsOn remapTestmodJar
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
artifact(remapMavenJar) {
|
|
|
|
builtBy remapMavenJar
|
|
|
|
}
|
|
|
|
|
|
|
|
artifact(sourcesJar) {
|
|
|
|
builtBy remapSourcesJar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
|
|
|
|
if (project.hasProperty("maven")) {
|
|
|
|
maven {
|
|
|
|
url = project.getProperty("maven")
|
|
|
|
name = "dynamic"
|
|
|
|
|
|
|
|
credentials(HttpHeaderCredentials) {
|
|
|
|
name = "Job-Token"
|
|
|
|
value = System.getenv().CI_JOB_TOKEN
|
|
|
|
}
|
|
|
|
authentication {
|
|
|
|
header(HttpHeaderAuthentication)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.publish.dependsOn(tasks.build)
|
|
|
|
rootProject.tasks.deployDebug.dependsOn(tasks.publish)
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
if (project.name in rootProject.nonModSubprojects) return
|
|
|
|
|
|
|
|
javadoc.enabled = false
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
testmodImplementation sourceSets.main.output
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
genClientOnlySources.enabled = false
|
|
|
|
genCommonSources.enabled = false
|
|
|
|
unpickClientOnlyJar.enabled = false
|
|
|
|
unpickCommonJar.enabled = false
|
|
|
|
|
|
|
|
rootProject.dependencies {
|
|
|
|
api project(path: project.path, configuration: "shadow")
|
|
|
|
clientImplementation project.sourceSets.client.output
|
|
|
|
testmodImplementation project.sourceSets.testmod.output
|
|
|
|
|
|
|
|
if (!(project.name in rootProject.devOnlyModules)) {
|
|
|
|
include project
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testmod
|
|
|
|
}
|
|
|
|
|
|
|
|
def readmeFile = rootProject.file("README.md")
|
|
|
|
|
|
|
|
if (ext.modrinthAvailable) {
|
|
|
|
modrinth {
|
|
|
|
token = System.getenv().MODRINTH_API_TOKEN
|
|
|
|
projectId = project.modrinth_id
|
|
|
|
versionName = "[${project.minecraft_version}] ${version}"
|
|
|
|
versionType = project.ext.currentType.toString()
|
|
|
|
changelog = changelogStr
|
|
|
|
uploadFile = remapJar
|
|
|
|
gameVersions = ["${project.minecraft_version}"]
|
|
|
|
loaders = ['fabric']
|
|
|
|
dependencies {
|
|
|
|
if (!project.ext.modrinth_required_dependencies.isEmpty()) {
|
|
|
|
project.ext.modrinth_required_dependencies.split(", ").each { String dep ->
|
|
|
|
required.project dep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!project.ext.modrinth_optional_dependencies.isEmpty()) {
|
|
|
|
project.ext.modrinth_optional_dependencies.split(", ").each { String dep ->
|
|
|
|
optional.project dep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (readmeFile.exists()) {
|
|
|
|
syncBodyFrom = readmeFile.text + "\n\n[![Contact](https://img.shields.io/badge/-Contact-informational)](https://jfronny.gitlab.io/contact.html)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.deployRelease.dependsOn(tasks.modrinth)
|
|
|
|
if (readmeFile.exists()) {
|
|
|
|
tasks.deployRelease.dependsOn(tasks.modrinthSyncBody)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext.curseforgeAvailable) {
|
|
|
|
curseforge {
|
|
|
|
if (System.getenv().CURSEFORGE_API_TOKEN) {
|
|
|
|
apiKey = System.getenv().CURSEFORGE_API_TOKEN
|
|
|
|
} else {
|
|
|
|
println "No CURSEFORGE_API_TOKEN specified"
|
|
|
|
}
|
|
|
|
project {
|
|
|
|
id = project.curseforge_id
|
|
|
|
releaseType = 'release'
|
|
|
|
addGameVersion "Fabric"
|
|
|
|
addGameVersion "${project.minecraft_version}"
|
|
|
|
changelog = changelogStr
|
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
|
|
|
|
mainArtifact.displayName = "[${project.minecraft_version}] ${version}"
|
|
|
|
if (!project.ext.curseforge_required_dependencies.isEmpty() || !project.ext.curseforge_optional_dependencies.isEmpty()) {
|
|
|
|
relations {
|
|
|
|
if (!project.ext.curseforge_required_dependencies.isEmpty()) {
|
|
|
|
project.ext.curseforge_required_dependencies.split(", ").each {
|
|
|
|
String dep -> requiredDependency dep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!project.ext.curseforge_optional_dependencies.isEmpty()) {
|
|
|
|
project.ext.curseforge_optional_dependencies.split(", ").each {
|
|
|
|
String dep -> optionalDependency dep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
releaseType = project.ext.currentType.toString()
|
|
|
|
afterEvaluate {
|
|
|
|
uploadTask.dependsOn(build)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
options {
|
|
|
|
forgeGradleIntegration = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.deployRelease.dependsOn(tasks.curseforge)
|
|
|
|
}
|