ModernFix/build.gradle
2023-05-01 19:05:08 -04:00

221 lines
7.3 KiB
Groovy

plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
id "maven-publish"
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.palantir.git-version' version '1.0.0'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.79.0'
id "com.modrinth.minotaur" version "2.+" apply false
id("com.diffplug.spotless") version "6.18.0" apply false
}
architectury {
minecraft = rootProject.minecraft_version
}
ext.archives_base_name = 'modernfix-mc' + minecraft_version
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
apply plugin: "com.diffplug.spotless"
spotless {
java {
removeUnusedImports()
}
}
group = 'org.embeddedt'
version = gitVersion()
archivesBaseName = rootProject.archives_base_name + '-' + project.name
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
repositories {
maven { url 'https://modmaven.dev/' }
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
maven {
// Shedaniel's maven (Architectury API)
url = "https://maven.architectury.dev"
content {
includeGroup "me.shedaniel"
}
}
maven {
// saps.dev Maven (KubeJS and Rhino)
url = "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
}
}
maven { // CTM
url "https://maven.tterrag.com/"
}
maven { url 'https://maven.blamejared.com' }
repositories {
maven {
name = "Fuzs Mod Resources"
url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
}
}
}
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
}
}
processResources {
def mixinFileList = []
def mixinDirectory = file("src/main/java/org/embeddedt/modernfix/" + project.name + "/mixin")
fileTree(mixinDirectory).visit { FileVisitDetails details ->
if(details.file.isFile()) {
def fileName = mixinDirectory.relativePath(details.file).toString().replaceFirst(/\.java$/, "").replace('/', '.')
mixinFileList << fileName
}
}
def mixinClassesStringB = new StringBuilder()
for(int i = 0; i < mixinFileList.size(); i++) {
mixinClassesStringB.append(" \"")
mixinClassesStringB.append(mixinFileList.get(i))
mixinClassesStringB.append('"')
if(i < (mixinFileList.size() - 1))
mixinClassesStringB.append(',')
mixinClassesStringB.append('\n')
}
def replacements = [
mixin_classes: mixinClassesStringB.toString()
]
inputs.properties replacements
def filePattern = "modernfix-" + project.name + ".mixins.json"
filesMatching(filePattern) {
expand replacements
}
}
}
/*
modCompileOnly("mezz.jei:jei-${minecraft_version}:${jei_version}")
//modRuntimeOnly("mezz.jei:jei-${minecraft_version}:${jei_version}")
modCompileOnly("curse.maven:refinedstorage-243076:${refined_storage_version}")
modCompileOnly("dev.latvian.mods:kubejs-forge:${kubejs_version}")
modCompileOnly("curse.maven:jeresources-240630:3545538")
modCompileOnly("curse.maven:jepb-437558:3172880")
modCompileOnly("curse.maven:babel-436964:3196072")
modCompileOnly("curse.maven:twforest-227639:3575220")
modRuntimeOnly("curse.maven:ferritecore-429235:4074330")
modCompileOnly("team.chisel.ctm:CTM:${ctm_version}")
modCompileOnly("curse.maven:supermartijncore-454372:4455378")
modCompileOnly("curse.maven:valhesiastructures-347488:3476252")
modCompileOnly files("deps/starlight-1.2.jar")
modCompileOnly("appeng:appliedenergistics2:8.4.7")
modCompileOnly("vazkii.patchouli:Patchouli:1.16.4-53.3")
*/
tasks.withType(JavaCompile) {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
/*
if (JavaVersion.current().isJava9Compatible()) {
options.release = targetVersion
}
*/
}
task generateChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
def details = versionDetails();
if(details.commitDistance > 0) {
fromRef = details.lastTag;
} else {
def secondLastTagCmd = "git describe --abbrev=0 " + details.lastTag + "^"
def secondLastTag = secondLastTagCmd.execute().text.trim()
fromRef = secondLastTag;
}
file = new File("CHANGELOG.md");
def otherTemplateContent = new File('gradle/changelog.mustache').getText('UTF-8');
templateContent = "## Changes since " + fromRef + "\n" + otherTemplateContent;
toCommit = "HEAD";
}
/*
curseforge {
if (System.getenv("CURSEFORGE_TOKEN") != null) {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = "790626"
changelog = file('./CHANGELOG.md')
changelogType = "markdown"
releaseType = "release"
addGameVersion "Forge"
addGameVersion minecraft_version
mainArtifact remapJar
}
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "modernfix" // This can be the project ID or the slug. Either will work!
versionType = "release" // This is the default -- can also be `beta` or `alpha`
uploadFile = remapJar
gameVersions = [minecraft_version]
loaders = ["forge"]
changelog.set(provider { file("./CHANGELOG.md").getText('UTF-8') })
}
tasks.register('checkCleanTag') {
doLast {
def details = versionDetails()
if (!details.isCleanTag || versionDetails().commitDistance != 0) {
throw new GradleException('Not a clean tree.')
}
}
}
tasks.curseforge.dependsOn(":checkCleanTag")
tasks.curseforge.dependsOn(":generateChangelog")
tasks.modrinth.dependsOn(":checkCleanTag")
tasks.modrinth.dependsOn(":generateChangelog")
tasks.register('publishToModSites') {
publishToModSites.dependsOn(tasks.modrinth)
publishToModSites.dependsOn(tasks.curseforge)
}
*/