architectury / architectury-loom

A Gradle plugin to setup environments for Fabric, Forge, NeoForge and Quilt modding.
https://docs.architectury.dev/loom/introduction
MIT License
115 stars 41 forks source link

Source sets other than main are not compiled in runs #217

Open dhyces opened 5 months ago

dhyces commented 5 months ago

Arch loom version: 1.6.397

The problem is that source sets added into a ModSettings config do not have their associated compile...Java task run.

runs {
    data {
        configName = "Datagen"
        mods {
            "example" {
                sourceSet(sourceSets.datagen) // This is not compiled
            }
        }
    }
}

This is an issue in my mod Trimmed where I have a separate source set for datagen. Here is the repo at a specific history with the issue present: https://github.com/dhyces/trimmed/blob/bb35457aa677f6425966774d9f2d982c0a109226/neo/build.gradle.kts Example repo with a small project and repro steps in README: https://github.com/dhyces/arch_issue_example

Juuxel commented 5 months ago

You need to set source = sourceSets.datagen in the run config as that's the primary source set here.

  runs {
      data {
          configName = "Datagen"
+         source = sourceSets.datagen
          mods {
              "example" {
                  sourceSet(sourceSets.datagen) // This is not compiled
              }
          }
      }
  }

The source sets listed in mods only determine how the mod file paths on the classpath are grouped[^1], while the source property determines which source set is compiled (along with its dependencies). [^1]: Not entirely true on Neo and Forge, but you need to set source to get the right things to compile. This matches how Loom works on Fabric too.

dhyces commented 5 months ago

Hm, looks like caching must have messed that up for me, because I had tried that and noticed no difference. However, now I'm running into a compilation error. Seems like the compiled intermediary common source set is attempted to be used?

Details

12:25:08 PM: Executing ':neo:datagenClasses'... > Task :buildSrc:checkKotlinGradlePluginConfigurationErrors > Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE > Task :buildSrc:extractPrecompiledScriptPluginPlugins UP-TO-DATE > Task :buildSrc:compilePluginsBlocks UP-TO-DATE > Task :buildSrc:generatePrecompiledScriptPluginAccessors UP-TO-DATE > Task :buildSrc:generateScriptPluginAdapters UP-TO-DATE > Task :buildSrc:compileKotlin UP-TO-DATE > Task :buildSrc:compileJava NO-SOURCE > Task :buildSrc:compileGroovy NO-SOURCE > Task :buildSrc:pluginDescriptors UP-TO-DATE > Task :buildSrc:processResources UP-TO-DATE > Task :buildSrc:classes UP-TO-DATE > Task :buildSrc:jar UP-TO-DATE > Configure project :common Architectury Loom: 1.6.397 This version of Architectury Loom is in beta! Please report any issues you encounter: https://github.com/architectury/architectury-loom/issues > Configure project :neo NeoForge support is experimental. Please report any issues! > Task :neo:processDatagenResources NO-SOURCE > Task :common:compileJava UP-TO-DATE > Task :common:processResources UP-TO-DATE > Task :common:classes UP-TO-DATE > Task :common:jar > Task :common:remapJar > Task :neo:compileDatagenJava FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. 15 actionable tasks: 4 executed, 11 up-to-date C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:7: error: cannot access class_2405 public class VanillaItemModelOverrideProvider extends ItemOverrideDataProvider { ^ class file for net.minecraft.class_2405 not found C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:9: error: cannot access class_7784 super(output, "minecraft"); ^ class file for net.minecraft.class_7784 not found C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:14: error: cannot access class_1935 anyTrimBuilder(new ArmorSet(Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS)) ^ class file for net.minecraft.class_1935 not found C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:17: error: incompatible types: Item cannot be converted to class_1935 anyTrimBuilder(new ArmorSet(Items.CHAINMAIL_HELMET, Items.CHAINMAIL_CHESTPLATE, Items.CHAINMAIL_LEGGINGS, Items.CHAINMAIL_BOOTS)) ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:20: error: incompatible types: Item cannot be converted to class_1935 anyTrimBuilder(new ArmorSet(Items.IRON_HELMET, Items.IRON_CHESTPLATE, Items.IRON_LEGGINGS, Items.IRON_BOOTS)) ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:23: error: incompatible types: Item cannot be converted to class_1935 anyTrimBuilder(new ArmorSet(Items.GOLDEN_HELMET, Items.GOLDEN_CHESTPLATE, Items.GOLDEN_LEGGINGS, Items.GOLDEN_BOOTS)) ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:26: error: incompatible types: Item cannot be converted to class_1935 anyTrimBuilder(new ArmorSet(Items.DIAMOND_HELMET, Items.DIAMOND_CHESTPLATE, Items.DIAMOND_LEGGINGS, Items.DIAMOND_BOOTS)) ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:29: error: incompatible types: Item cannot be converted to class_1935 anyTrimBuilder(new ArmorSet(Items.NETHERITE_HELMET, Items.NETHERITE_CHESTPLATE, Items.NETHERITE_LEGGINGS, Items.NETHERITE_BOOTS)) ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\model\VanillaItemModelOverrideProvider.java:32: error: incompatible types: Item cannot be converted to class_1935 addAnyTrimOverride(Items.TURTLE_HELMET); ^ C:\Users\pokmo\OneDrive\Desktop\DevStuff\Java\trimmed\neo\src\datagen\java\dev\dhyces\trimmed\TrimmedDatagen.java:20: error: no suitable method found for addProvider(boolean,VanillaItemModelOverrideProvider) generator.addProvider(event.includeClient(), new VanillaItemModelOverrideProvider(packOutput)); ^ method DataGenerator.addProvider(boolean,Factory) is not applicable (cannot infer type-variable(s) T#1 (argument mismatch; VanillaItemModelOverrideProvider cannot be converted to Factory)) method DataGenerator.addProvider(boolean,T#2) is not applicable (inference variable T#2 has incompatible bounds upper bounds: DataProvider lower bounds: VanillaItemModelOverrideProvider) where T#1,T#2 are type-variables: T#1 extends DataProvider declared in method addProvider(boolean,Factory) T#2 extends DataProvider declared in method addProvider(boolean,T#2) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 10 errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':neo:compileDatagenJava'. > Compilation failed; see the compiler error output for details. * Try: > Run with --info option to get more log output. > Run with --scan to get full insights. BUILD FAILED in 6s 12:25:14 PM: Execution finished ':neo:datagenClasses'.