I am developing a mod within IntelliJ Ultimate and I'm using Kotlin instead of Java. This comes with various problems, because Forge and ForgeGradle are vastly undocumented. To solve one of my problems, I tried to move the resource output into the classes output within the IDE. Forge seems unable to load resources using the ResourceLocation system (again, undocumented), if the resources do not reside alongside the classes in the filesystem. If I try to load a resource using the classloader:
SomeClass.class.getResourceAsStream("/assets/<mod.id>/textures/items/someTexture.png")
the resource is found, so it is not a problem to find resources in general. Just forge is unable to find them, as long as they are not in the same output folder as the JVM class files.
But when I tried to move the output resources into the compilation output folder like this:
sourceSets {
main {
output.resourcesDir = output.classesDirs.find { it.getPath().contains("kotlin") }
}
}
then creating the reobfuscated jar file (using the reobf task of forge-gradle) failed: (the assets are found this way, if the client is started within the IDE)
Error while building FML annotations cache: duplicate entry: assets/<mod.id>/blockstates/someFile.json
java.util.zip.ZipException: duplicate entry: assets/<mod.id>/blockstates/someFile.json
at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)
at net.minecraftforge.gradle.user.TaskExtractAnnotations.processJar(TaskExtractAnnotations.java:96)
at net.minecraftforge.gradle.user.TaskExtractAnnotations.doTask(TaskExtractAnnotations.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
// 133 further calls omitted
However, the build output folders only contained one version of the resource files, so I suspect the gradle processResources task to be responsible. It is, again, undocumented and I have no idea what the task is actually doing (besides expanding some variables within the mcmod.info file, if configured that way. I tried to omit the task configuration and I tried to reconfigure the task to exclude all resources. The result of reobfJar was exactly the same.
So: What does processResources do, why can't I relocate the resources output of gradle and why do I need to do that (so resources can be found) in the first place?