MinecraftForge / ForgeGradle

Minecraft mod development framework used by Forge and FML for the gradle build system
GNU Lesser General Public License v2.1
508 stars 436 forks source link

Access Transformers with `clean` task cause compile errors #935

Closed gmitch215 closed 9 months ago

gmitch215 commented 9 months ago

Hello, I'm trying to use Forge Access Transformers with my project. However, when you include the clean task, it causes compile errors:

final class ForgePacketData extends ServerboundPacketData implements Packet<ServerGamePacketListener> {
                                                                     ^
  symbol: class Packet
/home/runner/work/SocketMC/SocketMC/forge/src/main/java/me/gamercoder215/socketmc/ForgePacketData.java:12: error: cannot find symbol
final class ForgePacketData extends ServerboundPacketData implements Packet<ServerGamePacketListener> {
                                                                            ^
  symbol: class ServerGamePacketListener
/home/runner/work/SocketMC/SocketMC/forge/src/main/java/me/gamercoder215/socketmc/ForgePacketData.java:19: error: cannot find symbol
    public void write(FriendlyByteBuf pBuffer) {
                      ^
  symbol:   class FriendlyByteBuf
  location: class ForgePacketData
/home/runner/work/SocketMC/SocketMC/forge/src/main/java/me/gamercoder215/socketmc/ForgePacketData.java:35: error: cannot find symbol
    public void handle(ServerGamePacketListener pHandler) {}
                       ^
  symbol:   class ServerGamePacketListener
  location: class ForgePacketData
/home/runner/work/SocketMC/SocketMC/forge/src/main/java/me/gamercoder215/socketmc/forge/mixin/ForgeMixinClientHandshakePacketListenerImpl.java:21: error: cannot find symbol
@Mixin(ClientHandshakePacketListenerImpl.class)
       ^
  symbol: class ClientHandshakePacketListenerImpl
/home/runner/work/SocketMC/SocketMC/forge/src/main/java/me/gamercoder215/socketmc/forge/mixin/ForgeMixinMinecraft.java:12: error: cannot find symbol
@Mixin(Minecraft.class)

// ...

It seems that clean is running after the access transformers, causing them to delete the modified sources before compileJava takes place. Is this a bug? Do I need to set up something in my build.gradle.kts?

LexManos commented 9 months ago

This is one of the many qwerks of gradle and the hacks we have to do to make it bend to our will. Run it as two separate invocations and it should work fine.

To clarify, this is a known issue (for several years) and I cant fix it with the codebase in the state that it's in. I have plans to rewrite the toolchain to address this issue and many others. but I have limited time for the next couple months. So use the work around for now.