fabric/fabric-data-generation-api-v1/build.gradle

200 lines
5.2 KiB
Groovy
Raw Permalink Normal View History

version = getSubprojectVersion(project)
moduleDependencies(project, [
'fabric-api-base',
Default English Translations for `c` namespaced tags (#3716) * Created tag translation datagen * generate lang file * Add fruit translation * renamed interface injection * Adjust missing translation message * Fixed for checkStyle * More checkstyle fighting... * Bump version of modules. * Oops wrong module got bumped * moving and renaming files * adjust enum class naming * rename enum and move package * Renamed one more enum * Undo version bump. Will be handled at release * Some suggestions implemented * Added crowdin entry * Update crowdin.yml Co-authored-by: modmuss <modmuss50@gmail.com> * Cleanup enum checking * spotless fixes * Added buckets and powder snow bucket tag translation * Some more suggested changes * setup ConventionLogWarnings to match ConventionLogWarningsClient setup * Change property to be usable in prod * Set short as default property * Remove unused import * Fixed copy/paste error * fixed ingot translations * lang and method name fixes * Fixed filepath issue * Fixed redstone name * fixed javadoc whitespace * Move translation warning to server * Move translation class to better file path * trying to pass the regex * put it under impl * Cleanup translation check * Update fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com> * Update fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/FabricTagKey.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/FabricTagKey.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> --------- Co-authored-by: modmuss <modmuss50@gmail.com> Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com> Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com>
2024-05-07 14:03:18 -04:00
'fabric-convention-tags-v2',
'fabric-registry-sync-v0',
'fabric-networking-api-v1',
'fabric-resource-conditions-api-v1',
'fabric-item-group-api-v1',
2024-04-16 13:01:57 -04:00
'fabric-recipe-api-v1'
])
dependencies {
}
sourceSets {
testmod {
resources {
srcDirs += [
'src/testmod/generated'
]
}
}
}
loom {
accessWidenerPath = file("src/main/resources/fabric-data-generation-api-v1.accesswidener")
runs {
datagen {
inherit testmodServer
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}"
vmArg "-Dfabric-api.datagen.strict-validation"
ideConfigGenerated = true
runDir "build/datagen"
}
datagenClient {
client()
name "Data Generation Client"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}"
vmArg "-Dfabric-api.datagen.strict-validation"
ideConfigGenerated = true
runDir "build/datagen"
source sourceSets.testmodClient
}
}
}
test.dependsOn runDatagen
task datapackZip(type: Zip, dependsOn: runDatagen) {
archiveFileName = "${base.archivesName.get()}-${project.version}-test-datapack.zip"
destinationDirectory = layout.buildDirectory.dir('libs')
from file("src/testmod/generated")
from file("pack.mcmeta")
}
build.dependsOn datapackZip
import org.objectweb.asm.ClassReader
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode
import java.lang.reflect.Modifier
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
task generateAccessWidener() {
doLast {
2023-02-01 11:35:59 -05:00
File inputJar = loom.namedMinecraftProvider.parentMinecraftProvider.commonJar.path.toFile()
String accessWidener = "accessWidener\tv2\tnamed\n"
accessWidener += "\n"
accessWidener += "# DO NOT EDIT BY HAND! This file is generated automatically.\n"
accessWidener += "# Edit \"template.accesswidener\" instead then run \"gradlew generateAccessWidener\".\n"
accessWidener += "\n"
accessWidener += file("template.accesswidener").text + "\n"
def classes = getClasses(inputJar)
visitMethods(classes["net/minecraft/data/server/recipe/RecipeProvider"]) { name, desc, owner ->
if (it.name == "generate")
return
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
}
visitMethods(classes["net/minecraft/data/client/BlockStateModelGenerator"]) { name, desc, owner ->
if (desc == "()V")
// Skip over methods that dont take any arguments, as they are specific to minecraft.
return
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
}
visitMethods(classes["net/minecraft/data/server/loottable/BlockLootTableGenerator"]) { name, desc, owner ->
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
}
visitMethods(classes["net/minecraft/data/client/ItemModelGenerator"]) { name, desc, owner ->
accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n"
}
classes.values().forEach { classNode ->
visitFinalMethods(classNode) { name, desc, owner ->
if (name != "getName" || desc != "()Ljava/lang/String;") {
// Not the method we are after
return
}
if (!hasAncestor(classNode, classes, "net/minecraft/data/DataProvider")) {
// Not a descendant of DataProvider
return
}
accessWidener += "transitive-extendable\tmethod\t${owner}\t${name}\t${desc}\n"
}
}
file("src/main/resources/fabric-data-generation-api-v1.accesswidener").text = accessWidener
}
}
def visitMethods(ClassNode classNode, closure) {
classNode.methods.forEach {
if ((it.access & Opcodes.ACC_SYNTHETIC) != 0 || (it.access & Opcodes.ACC_PUBLIC) != 0)
return
if (it.name.startsWith("<"))
return
closure(it.name, it.desc, classNode.name)
}
}
def visitFinalMethods(ClassNode classNode, closure) {
classNode.methods.forEach {
if (!Modifier.isFinal(it.access))
return
if (it.name.startsWith("<"))
return
closure(it.name, it.desc, classNode.name)
}
}
// Return a map of all class names to classNodes
def getClasses(File input) {
Map<String, ClassNode> classes = new TreeMap<>()
new ZipFile(input).withCloseable { ZipFile zip ->
zip.entries().toList().forEach { ZipEntry entry ->
if (!entry.name.endsWith(".class")) {
return
}
zip.getInputStream(entry).withCloseable { is ->
ClassReader reader = new ClassReader(is)
ClassNode classNode = new ClassNode()
reader.accept(classNode, ClassReader.SKIP_CODE)
classes.put(classNode.name, classNode)
}
}
}
return classes
}
def hasAncestor(ClassNode classNode, Map<String, ClassNode> classes, String ancestorName) {
if (classNode.superName == ancestorName) {
return true
}
// Recuse through the super classes
def superClass = classes.get(classNode.superName)
if (superClass != null && hasAncestor(superClass, classes, ancestorName)) {
return true
}
for (def interfaceName : classNode.interfaces) {
if (interfaceName == ancestorName) {
return true
}
def ifaceClass = classes.get(interfaceName)
if (ifaceClass != null && hasAncestor(ifaceClass, classes, ancestorName)) {
return true
}
}
}
Add fabric-convention-tags-v1 (#2063) * Add framework for common-tags-v1 * Add javadoc to fabric tool tags * Fix wrong package arrangement * Add some more tags * Add more biome tags Thanks to TelepathicGrunt for the suggestions * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-common-tags-api-v1/src/main/java/net/fabricmc/fabric/api/tags/v1/CommonEnchantmentTags.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Clarify enchantment tags * Add no-shulker tag * Add minecart tag * Begin work on datagen and populating tags * Add bucket tags * First pass at populating biome tags * Add boat tag * Fix missing inclusion of f:shears into c:shears * Hide fabric tool tags in datagen * Add weapon damage enhancement tag * Change impl package name to be inline with rest of fapi * Rename enchantment tags * Some cleanup * Populate blocktag datagen Remove crops tag * Add javadoc links to vanilla counterparts * Move datagen to its own sourceset * Fix package names for checkstyle * Populate more entries * Remove exclusion tag * Add license headers Fix checkstyle * Add missing nether quarts to ores tag * Use `worldgen/biome` instead of `biomes` for biome tags Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Manually include all biomes for overworld * Remove ancient debris from NetheriteOres * Add and populate glass tags * Add and populate movement enhancement * Break up item tags * Add armour damage reduction tag * Add missing ore and related tags * Fix quartz tags * Add floral tag * Add golden carrot * Correct some biome tag issues * Separate SNOWY_PLAINS and PLAINS * Add SNOWY tag and remove snowy biomes from ICY * Correct enchantment tag Remove silk touch tag * Fix more biome issues * Add deep and shllow ocean tags * Add no-move tag * Remove netherite ores * Add shulker tags * Add raw ore * Add dye tags * Fif dye tags * Fix typo * Document some biome tags where the naming may not be clear * Remove tag mirroring for blocks and items * Rename module Remove unused methods * Rename impl package * Rename packages and module * Rename folder * Rename api classes * Add generateResources task to cover all resource generation tasks. * Add generated tags to repo * Fix ocean tag excluding shallow ocean * Iterate registry to generate foods tag * Remove cache, add to gitignore * Rename generated folder Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> Co-authored-by: modmuss50 <modmuss50@gmail.com>
2022-04-17 14:23:48 -04:00
generateResources.dependsOn generateAccessWidener