mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
150 lines
4.4 KiB
Groovy
150 lines
4.4 KiB
Groovy
plugins {
|
|
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
|
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
|
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
|
|
id "io.github.pacifistmc.forgix" version "1.2.9"
|
|
id "me.shedaniel.unified-publishing" version "0.1.+"
|
|
}
|
|
|
|
version = "${project.mod_version}+${project.minecraft_version}"
|
|
ext.version_name = "${project.capitalized_name} ${project.mod_version}"
|
|
ext.headTag = "git describe --tags --abbrev=0 HEAD".execute([], rootProject.projectDir).text.trim()
|
|
ext.previousTag = "git describe --tags --abbrev=0 HEAD^".execute([], rootProject.projectDir).text.trim()
|
|
|
|
architectury {
|
|
minecraft = project.minecraft_version
|
|
}
|
|
|
|
forgix {
|
|
group = "$project.maven_group.$project.mod_id"
|
|
// forgix does not append .jar extension for some reason
|
|
mergedJarName = "${project.archives_name}-${project.version}.jar"
|
|
outputDir = "build/libs/merged"
|
|
}
|
|
|
|
allprojects {
|
|
apply plugin: "java"
|
|
|
|
version = rootProject.version
|
|
group = project.maven_group
|
|
}
|
|
|
|
subprojects {
|
|
apply plugin: "dev.architectury.loom"
|
|
apply plugin: "architectury-plugin"
|
|
|
|
loom {
|
|
silentMojangMappingsLicense()
|
|
}
|
|
|
|
base {
|
|
archivesName = "$rootProject.archives_name-$project.name"
|
|
}
|
|
|
|
build.finalizedBy(mergeJars)
|
|
assemble.finalizedBy(mergeJars)
|
|
|
|
repositories {
|
|
maven {
|
|
name = "ParchmentMC"
|
|
url = "https://maven.parchmentmc.org"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
|
mappings loom.layered {
|
|
officialMojangMappings()
|
|
parchment("org.parchmentmc.data:parchment-$rootProject.minecraft_version:$rootProject.parchment_mappings@zip")
|
|
}
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_21
|
|
targetCompatibility = JavaVersion.VERSION_21
|
|
}
|
|
|
|
jar {
|
|
from "$rootProject.projectDir/LICENSE"
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
it.options.encoding = "UTF-8"
|
|
|
|
it.options.release.set(21)
|
|
}
|
|
}
|
|
|
|
// Adapted from https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.7/ferry.gradle
|
|
tasks.register("generateChangelog") {
|
|
ext.changelog = ""
|
|
|
|
def lastTag = previousTag
|
|
def currentTag = headTag
|
|
|
|
def changes = new StringBuilder()
|
|
def commits = "git log --max-count=${project.changelog_max_commit_search} --pretty=format:\"%b\" $lastTag..$currentTag".execute()
|
|
commits.in.eachLine { line -> // Loops over the lines the git log command returns
|
|
def processedLine = line.toString()
|
|
if (processedLine.startsWith("\"")) {
|
|
processedLine = processedLine.substring(1)
|
|
}
|
|
if (processedLine.endsWith("\"")) {
|
|
processedLine = processedLine.substring(0, processedLine.length() - 1)
|
|
}
|
|
if (processedLine.startsWith("- ")) {
|
|
if (changes.length() == 0) {
|
|
changes << processedLine
|
|
} else {
|
|
changes << "\n$processedLine"
|
|
}
|
|
}
|
|
}
|
|
commits.err.eachLine { line -> println line }
|
|
commits.waitFor()
|
|
|
|
ext.changelog = changes.toString()
|
|
if (ext.changelog.isEmpty()) {
|
|
ext.changelog = "No Changelog Available"
|
|
}
|
|
}
|
|
|
|
tasks.register("assertNewVersion") {
|
|
if (headTag == previousTag) {
|
|
throw new GradleException("Current version $headTag is the same as previous. Please create a new version tag if you want to proceed.")
|
|
}
|
|
}
|
|
|
|
tasks.publishUnified.dependsOn("assertNewVersion", "build")
|
|
|
|
unifiedPublishing {
|
|
project {
|
|
displayName = version_name.toString()
|
|
version = project.version
|
|
changelog = generateChangelog.changelog
|
|
releaseType = "release"
|
|
gameVersions = List.of(project.game_versions.split(","))
|
|
gameLoaders = List.of(project.mod_loaders.split(","))
|
|
|
|
mainPublication.set(file("build/libs/merged/${project.archives_name}-${project.version}.jar"))
|
|
|
|
var cfToken = System.getenv("CF_TOKEN")
|
|
if (cfToken != null) {
|
|
curseforge {
|
|
token = cfToken
|
|
id = project.curseforge_id
|
|
}
|
|
}
|
|
|
|
var mrToken = System.getenv("MODRINTH_TOKEN")
|
|
if (mrToken != null) {
|
|
modrinth {
|
|
token = mrToken
|
|
id = project.modrinth_id
|
|
}
|
|
}
|
|
}
|
|
}
|