mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 21:47:40 -05:00
- Cache fractions from -1024 to 1023 - Add BiomeModifications for platform-agnostic biome additions - Add FluidStackHooksForge to convert architectury FluidStacks to forge FluidStacks - Migrate to Forge Loom & Update Architect Plugin - Mark several methods in Mod as NotNull - Add Env as a replacement for EnvType
157 lines
4.6 KiB
Groovy
157 lines
4.6 KiB
Groovy
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
|
|
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext
|
|
import shadow.org.apache.tools.zip.ZipEntry
|
|
import shadow.org.codehaus.plexus.util.IOUtil
|
|
import shadow.org.apache.tools.zip.ZipOutputStream
|
|
|
|
plugins {
|
|
id "com.github.johnrengelman.shadow" version "5.0.0"
|
|
id "com.matthewprenger.cursegradle"
|
|
}
|
|
|
|
loom {
|
|
accessWidener(file("src/main/resources/architectury.accessWidener"))
|
|
silentMojangMappingsLicense()
|
|
}
|
|
|
|
configurations {
|
|
shadow
|
|
}
|
|
|
|
architectury {
|
|
platformSetupLoomIde()
|
|
}
|
|
|
|
dependencies {
|
|
minecraft("com.mojang:minecraft:${rootProject.architect.minecraft}")
|
|
mappings(minecraft.officialMojangMappings())
|
|
modCompile("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}")
|
|
modCompile("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}")
|
|
modCompileOnly("io.github.prospector:modmenu:${rootProject.mod_menu_version}")
|
|
implementation "net.jodah:typetools:0.6.2"
|
|
shadow "net.jodah:typetools:0.6.2"
|
|
|
|
compileOnly(project(path: ":common")) {
|
|
transitive = false
|
|
}
|
|
runtimeOnly(project(path: ":common", configuration: "transformed")) {
|
|
transitive = false
|
|
}
|
|
shadow(project(path: ":common", configuration: "transformed")) {
|
|
transitive = false
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
filesMatching("fabric.mod.json") {
|
|
expand "version": project.version
|
|
}
|
|
inputs.property "version", project.version
|
|
}
|
|
|
|
shadowJar {
|
|
relocate "net.jodah.typetools", "me.shedaniel.architectury.shadowed.impl.net.jodah.typetools"
|
|
transform(MergeAccessWidenersTransformer.class) {
|
|
it.resource = "architectury.accessWidener"
|
|
}
|
|
configurations = [project.configurations.shadow]
|
|
classifier "shadow"
|
|
}
|
|
|
|
remapJar {
|
|
dependsOn(shadowJar)
|
|
input.set(shadowJar.archiveFile)
|
|
archiveClassifier = "fabric"
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenFabric(MavenPublication) {
|
|
artifact(remapJar.archivePath) {
|
|
builtBy build
|
|
classifier "fabric"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
curseforge {
|
|
if (project.hasProperty("curse_api_key") || System.getenv("curse_api_key") != null) {
|
|
apiKey = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key")
|
|
project {
|
|
id = "419697"
|
|
releaseType = "release"
|
|
changelogType = "html"
|
|
changelog = releaseChangelog()
|
|
addGameVersion "1.16-Snapshot"
|
|
addGameVersion "1.16.4"
|
|
addGameVersion "Java 8"
|
|
addGameVersion "Fabric"
|
|
relations {
|
|
requiredDependency "fabric-api"
|
|
}
|
|
mainArtifact(remapJar.archivePath) {
|
|
displayName = "[Fabric $rootProject.supported_version] v$project.version"
|
|
}
|
|
afterEvaluate {
|
|
uploadTask.dependsOn("build")
|
|
}
|
|
}
|
|
}
|
|
options {
|
|
forgeGradleIntegration = false
|
|
javaVersionAutoDetect = false
|
|
}
|
|
}
|
|
|
|
rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge")
|
|
|
|
class MergeAccessWidenersTransformer implements Transformer {
|
|
String resource
|
|
ByteArrayOutputStream data
|
|
|
|
MergeAccessWidenersTransformer() {
|
|
data = new ByteArrayOutputStream()
|
|
data.write("accessWidener v1 named\n".bytes)
|
|
}
|
|
|
|
@Override
|
|
boolean canTransformResource(FileTreeElement element) {
|
|
def path = element.relativePath.pathString
|
|
if (resource != null && resource.equalsIgnoreCase(path)) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
@Override
|
|
void transform(TransformerContext context) {
|
|
def lines = context.is.readLines()
|
|
lines.removeIf { it == "accessWidener v1 named" }
|
|
IOUtil.copy(lines.join("\n"), data)
|
|
data.write('\n'.bytes)
|
|
|
|
context.is.close()
|
|
}
|
|
|
|
@Override
|
|
boolean hasTransformedResource() {
|
|
return data.size() > 0
|
|
}
|
|
|
|
void modifyOutputStream(org.apache.tools.zip.ZipOutputStream jos, boolean preserveFileTimestamps) {
|
|
throw new AbstractMethodError()
|
|
}
|
|
|
|
@Override
|
|
void modifyOutputStream(ZipOutputStream os, boolean preserveFileTimestamps) {
|
|
ZipEntry entry = new ZipEntry(resource)
|
|
entry.time = TransformerContext.getEntryTimestamp(preserveFileTimestamps, entry.time)
|
|
os.putNextEntry(entry)
|
|
|
|
IOUtil.copy(new ByteArrayInputStream(data.toByteArray()), os)
|
|
data.reset()
|
|
data.write('accessWidener v1 named\n'.bytes)
|
|
}
|
|
} |