2021-06-13 15:02:33 -04:00
|
|
|
buildscript {
|
|
|
|
dependencies {
|
|
|
|
classpath group: 'com.diluv.schoomp', name: 'Schoomp', version: '1.1.0'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-23 08:52:36 -04:00
|
|
|
plugins {
|
2021-12-03 16:37:35 -05:00
|
|
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
2022-07-01 10:58:31 -04:00
|
|
|
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
|
2021-06-13 15:02:33 -04:00
|
|
|
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
2020-08-23 08:52:36 -04:00
|
|
|
}
|
|
|
|
|
2021-06-13 15:02:33 -04:00
|
|
|
import com.diluv.schoomp.Webhook
|
|
|
|
import com.diluv.schoomp.message.Message
|
|
|
|
import com.diluv.schoomp.message.embed.Embed
|
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
architectury {
|
|
|
|
minecraft = rootProject.minecraft_version
|
2020-08-23 08:52:36 -04:00
|
|
|
}
|
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
subprojects {
|
|
|
|
apply plugin: "dev.architectury.loom"
|
2020-08-23 08:52:36 -04:00
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
loom {
|
|
|
|
silentMojangMappingsLicense()
|
2021-06-10 10:55:55 -04:00
|
|
|
}
|
2020-08-23 08:52:36 -04:00
|
|
|
|
2022-01-17 08:17:01 -05:00
|
|
|
repositories {
|
|
|
|
maven { url = 'https://maven.parchmentmc.org' }
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
dependencies {
|
|
|
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
2022-01-17 08:17:01 -05:00
|
|
|
mappings loom.layered() {
|
|
|
|
officialMojangMappings()
|
2022-02-27 20:31:56 -05:00
|
|
|
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
|
2022-01-17 08:17:01 -05:00
|
|
|
}
|
2021-06-10 10:55:55 -04:00
|
|
|
}
|
2020-08-23 08:52:36 -04:00
|
|
|
}
|
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
allprojects {
|
|
|
|
apply plugin: "java"
|
|
|
|
apply plugin: "architectury-plugin"
|
|
|
|
apply plugin: "maven-publish"
|
2020-08-23 08:52:36 -04:00
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
archivesBaseName = rootProject.archives_base_name
|
2021-06-11 18:15:14 -04:00
|
|
|
version = project.minecraft_version + "-" + rootProject.mod_version
|
2021-06-11 14:33:10 -04:00
|
|
|
group = rootProject.maven_group
|
2020-08-23 08:52:36 -04:00
|
|
|
|
2021-06-11 14:33:10 -04:00
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = "UTF-8"
|
2021-12-03 16:37:35 -05:00
|
|
|
options.release = 17
|
2021-06-10 10:55:55 -04:00
|
|
|
}
|
2021-06-11 14:33:10 -04:00
|
|
|
|
|
|
|
java {
|
|
|
|
withSourcesJar()
|
|
|
|
}
|
2021-06-10 10:55:55 -04:00
|
|
|
}
|
|
|
|
|
2021-06-13 15:02:33 -04:00
|
|
|
task buildAll {
|
|
|
|
dependsOn(":fabric:build")
|
|
|
|
dependsOn(":forge:build")
|
|
|
|
}
|
|
|
|
|
|
|
|
task cleanAll {
|
2022-01-10 10:55:59 -05:00
|
|
|
dependsOn clean
|
2021-06-13 15:02:33 -04:00
|
|
|
dependsOn(":common:clean")
|
|
|
|
dependsOn(":fabric:clean")
|
|
|
|
dependsOn(":forge:clean")
|
|
|
|
}
|
|
|
|
|
|
|
|
task publishAll {
|
|
|
|
dependsOn(":fabric:publish")
|
|
|
|
dependsOn(":forge:publish")
|
|
|
|
}
|
|
|
|
|
2021-06-10 10:55:55 -04:00
|
|
|
def changelog(int versions) {
|
|
|
|
try {
|
|
|
|
def changelog = ""
|
|
|
|
def match = 0
|
2021-08-13 05:21:38 -04:00
|
|
|
file("Changelog.md").eachLine {
|
2022-09-12 11:59:27 -04:00
|
|
|
if (it.matches("${project.project_name} [0-9]\\.[0-9]+\\.[0-9]+(\\.[0-9]*)?"))
|
2021-06-10 10:55:55 -04:00
|
|
|
match++
|
|
|
|
if (match <= versions) {
|
|
|
|
changelog += it + "\n"
|
|
|
|
} else
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return changelog + "\n\n"
|
|
|
|
} catch (exception) {
|
|
|
|
return "${project.project_name} ${project.mod_version}\n==========\n"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Splits the changelog into multiple parts if they get bigger than discords embed field size (1024)
|
|
|
|
def discordChangelog() {
|
|
|
|
def changelog = changelog(1)
|
|
|
|
def res = new ArrayList()
|
|
|
|
if (changelog.size() < 1024) {
|
|
|
|
res.add(changelog)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
def temp = ""
|
|
|
|
changelog.split("\n").each {
|
|
|
|
it = it + "\n"
|
|
|
|
if ((temp.size() + it.size()) >= 1024) {
|
|
|
|
res.add(temp)
|
|
|
|
temp = it
|
|
|
|
} else
|
|
|
|
temp += it
|
|
|
|
}
|
|
|
|
res.add(temp)
|
|
|
|
return res
|
2021-06-13 15:02:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
curseforge {
|
|
|
|
apiKey = findProperty('curseApiToken') ?: 0
|
|
|
|
|
|
|
|
project {
|
|
|
|
id = "${curse_id_fabric}"
|
|
|
|
"${project.curse_versions}".split(', ').each {
|
|
|
|
addGameVersion "${it}"
|
|
|
|
}
|
|
|
|
addGameVersion "Fabric"
|
2021-06-13 17:34:30 -04:00
|
|
|
mainArtifact(project(":fabric").tasks.getByName('remapJar')) {
|
2021-06-13 15:02:33 -04:00
|
|
|
def txt = changelog(1).replace("\n-", "\n\n- ")
|
2021-12-03 16:37:35 -05:00
|
|
|
txt = txt + "\n\n" + "For past versions see: ${project.full_changelog}"
|
2021-06-13 15:02:33 -04:00
|
|
|
changelog = txt
|
|
|
|
changelogType = "markdown"
|
|
|
|
releaseType = 'release'
|
|
|
|
}
|
|
|
|
relations {
|
|
|
|
"${project.curse_dep_fabric}".split(', ').each {
|
|
|
|
requiredDependency "${it}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project {
|
|
|
|
id = "${curse_id_forge}"
|
|
|
|
"${project.curse_versions}".split(', ').each {
|
|
|
|
addGameVersion "${it}"
|
|
|
|
}
|
|
|
|
addGameVersion "Forge"
|
2021-06-13 17:34:30 -04:00
|
|
|
mainArtifact(project(":forge").tasks.getByName('remapJar')) {
|
2021-06-13 15:02:33 -04:00
|
|
|
def txt = changelog(1).replace("\n-", "\n\n- ")
|
2021-12-03 16:37:35 -05:00
|
|
|
txt = txt + "\n\n" + "For past versions see: ${project.full_changelog}"
|
2021-06-13 15:02:33 -04:00
|
|
|
changelog = txt
|
|
|
|
changelogType = "markdown"
|
|
|
|
releaseType = 'release'
|
|
|
|
}
|
|
|
|
/*relations {
|
|
|
|
"${project.curse_dep_forge}".split(', ').each {
|
|
|
|
requiredDependency "${it}"
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-12 11:59:27 -04:00
|
|
|
def discordNotif(fabric, forge) {
|
2021-06-13 15:02:33 -04:00
|
|
|
try {
|
|
|
|
def webhook = new Webhook(findProperty('discordHook'), "${project.project_name} Upload")
|
|
|
|
|
|
|
|
def message = new Message()
|
|
|
|
def version = project.curse_versions.split(', ')[0]
|
|
|
|
message.setUsername("Curseforge Release")
|
2022-01-07 11:43:53 -05:00
|
|
|
message.setContent("<@&${project.discord_role}> ${project.project_name} ${project.mod_version} for Minecraft ${version} has been released!")
|
2021-06-13 15:02:33 -04:00
|
|
|
message.setAvatarUrl("https://cdn.discordapp.com/avatars/680540027255652407/e4b7a058b24843ae13389a9a3cc3ae8c.png?size=128")
|
|
|
|
|
|
|
|
def embed = new Embed()
|
2022-09-12 11:59:27 -04:00
|
|
|
|
|
|
|
if(fabric) {
|
|
|
|
def fileIDFabric = tasks.getByName("curseforge${project.curse_id_fabric}").property('mainArtifact').fileID
|
|
|
|
embed.addField('Get the fabric version here (When it is accepted)', "${project.findProperty('curse_page_fabric')}/files/${fileIDFabric}", false)
|
|
|
|
}
|
|
|
|
if(forge) {
|
|
|
|
def fileIDForge = tasks.getByName("curseforge${project.curse_id_forge}").property('mainArtifact').fileID
|
|
|
|
embed.addField('Get the forge version here (When it is accepted)', "${project.findProperty('curse_page_forge')}/files/${fileIDForge}", false)
|
|
|
|
}
|
2021-06-13 15:02:33 -04:00
|
|
|
def changelog = discordChangelog()
|
|
|
|
if (changelog.size() == 1)
|
|
|
|
embed.addField('Change Log', "```md\n${changelog.get(0) ?: 'Unavailable :('}```", false)
|
|
|
|
else
|
|
|
|
changelog.forEach {
|
|
|
|
embed.addField("Change Log", "```md\n${it}```", false)
|
|
|
|
}
|
|
|
|
embed.setColor(0xFF8000)
|
|
|
|
message.addEmbed(embed)
|
|
|
|
|
|
|
|
webhook.sendMessage(message)
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (IOException e) {
|
|
|
|
println 'Failed to push to the Discord webhook.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-12 11:59:27 -04:00
|
|
|
tasks.getByName("curseforge").doLast {
|
|
|
|
discordNotif(true, true)
|
|
|
|
}
|
|
|
|
|
2021-06-13 15:02:33 -04:00
|
|
|
task buildUploadAll(group: "publishing") {
|
2022-09-12 11:59:27 -04:00
|
|
|
dependsOn cleanAll, buildAll, publishAll, tasks.findByName("curseforge")
|
2021-06-13 15:02:33 -04:00
|
|
|
buildAll.mustRunAfter cleanAll
|
|
|
|
tasks.findByName("curseforge").mustRunAfter publishAll
|
|
|
|
}
|
|
|
|
|
2022-09-12 11:59:27 -04:00
|
|
|
afterEvaluate {
|
|
|
|
task buildUploadFabric(group: "publishing") {
|
|
|
|
dependsOn cleanAll, ":fabric:build", ":fabric:publish", "curseforge${curse_id_fabric}"
|
|
|
|
project("fabric").build.mustRunAfter cleanAll
|
|
|
|
project("fabric").publish.mustRunAfter ":fabric:build"
|
|
|
|
tasks.findByName("curseforge${curse_id_fabric}").mustRunAfter ":fabric:publish"
|
2022-09-12 13:12:32 -04:00
|
|
|
doLast {
|
2022-09-12 11:59:27 -04:00
|
|
|
discordNotif(true, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task buildUploadForge(group: "publishing") {
|
|
|
|
dependsOn cleanAll, ":forge:build", ":forge:publish", "curseforge${curse_id_forge}"
|
|
|
|
project("forge").build.mustRunAfter cleanAll
|
|
|
|
project("forge").publish.mustRunAfter ":forge:build"
|
|
|
|
tasks.findByName("curseforge${curse_id_forge}").mustRunAfter ":forge:publish"
|
2022-09-12 13:12:32 -04:00
|
|
|
doLast {
|
2022-09-12 11:59:27 -04:00
|
|
|
discordNotif(false, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 15:02:33 -04:00
|
|
|
tasks.getByName("curseforge").dependsOn buildAll
|
2022-02-27 20:31:56 -05:00
|
|
|
publishAll.dependsOn buildAll
|