Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
loom:datagen [2022/09/16 15:14] – created shedanielloom:datagen [2023/12/03 01:16] – restructure juuz
Line 1: Line 1:
-====== Data Generators ======+====== Forge Data Generators ====== 
 + 
 +**NOTE:** This is **only** for Forge projects! Data Generators are still in development for Architectury projects. Fabric projects can follow Fabric Loom documentation. 
 + 
 +To make Data Generators work, we first need to add the src/generated folder to the resources classpath. 
 + 
 +We will first define where the generated folder is, so we can reuse it: 
 +<code groovy> 
 +def generatedResources = file("src/generated"
 +</code> 
 + 
 +And, we will add it to the main source set, the one we use for launching Minecraft, so that our generated resources can be present in-game and the production artifacts: 
 + 
 +<code groovy> 
 +sourceSets { 
 +    main { 
 +        resources.srcDir generatedResources 
 +    } 
 +
 +</code> 
 + 
 +Then, we can add our data generator run configuration: 
 + 
 +<code groovy> 
 +loom { 
 +    runs { 
 +        data { 
 +            data() 
 +            programArgs "--all", "--mod", "<INSERT MOD ID HERE>" 
 +            programArgs "--output", generatedResources.absolutePath 
 +        } 
 +    } 
 +
 +</code> 
 + 
 +Refresh Gradle, and you are done! 
 + 
 +If you wish to add more arguments (like ''--existing''), following is an example on how to add additional arguments: 
 + 
 +<code groovy> 
 +loom { 
 +    runs { 
 +        data { 
 +            programArgs "--existing", file("src/main/resources").absolutePath 
 +        } 
 +    } 
 +
 +</code> 
 + 
 +===== Legacy dataGen() function ===== 
 + 
 +**The legacy dataGen() block has been deprecated and may not function properly in future versions of Loom** 
 + 
 +The Loom DSL for Forge Data Generators was deprecated due to its low customisability and relatively ease of manually configuring it in the project’s build.gradle. The documentation 
 +below is included mostly as a historical reference.
  
 Data Generators Support has been added to Architectury Loom, starting from 0.6.55, this is how you declare it: Data Generators Support has been added to Architectury Loom, starting from 0.6.55, this is how you declare it:
Line 25: Line 79:
 </code> </code>
  
-**NOTE:** Data Generators are still in development for architectury / fabric projects, this is **only** for Forge projects!