diff --git a/src/main/java/net/fabricmc/loom/extension/MixinExtensionApiImpl.java b/src/main/java/net/fabricmc/loom/extension/MixinExtensionApiImpl.java index bdcf7e657..eae0061ec 100644 --- a/src/main/java/net/fabricmc/loom/extension/MixinExtensionApiImpl.java +++ b/src/main/java/net/fabricmc/loom/extension/MixinExtensionApiImpl.java @@ -74,9 +74,20 @@ public Property getUseLegacyMixinAp() { return useMixinAp; } + protected void checkMixinApEnabled() { + if (LoomGradleExtension.get(project).isForge()) { + // Arch: We need to access afterEvaluate state in useLegacyMixinAp's convention, so let's not query it. + // Otherwise, this extension can't be used in a buildscript without afterEvaluate. + // https://github.com/architectury/architectury-loom/issues/242 + return; + } + + if (!getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor."); + } + @Override public Property getRefmapTargetNamespace() { - if (!getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor."); + checkMixinApEnabled(); return refmapTargetNamespace; } diff --git a/src/main/java/net/fabricmc/loom/extension/MixinExtensionImpl.java b/src/main/java/net/fabricmc/loom/extension/MixinExtensionImpl.java index cc8b03a6a..796b6e358 100644 --- a/src/main/java/net/fabricmc/loom/extension/MixinExtensionImpl.java +++ b/src/main/java/net/fabricmc/loom/extension/MixinExtensionImpl.java @@ -61,10 +61,7 @@ public MixinExtensionImpl(Project project) { @Override public Property getDefaultRefmapName() { - // Arch: We need to access afterEvaluate state in useLegacyMixinAp's convention, so let's not query it. - // Otherwise, this property can't be set in a buildscript without afterEvaluate. - // https://github.com/architectury/architectury-loom/issues/242 - // if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor."); + checkMixinApEnabled(); return defaultRefmapName; } @@ -84,7 +81,7 @@ private String getDefaultMixinRefmapName() { @Override protected PatternSet add0(SourceSet sourceSet, Provider refmapName) { - if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor."); + checkMixinApEnabled(); PatternSet pattern = new PatternSet().setIncludes(Collections.singletonList("**/*.json")); MixinExtension.setMixinInformationContainer(sourceSet, new MixinExtension.MixinInformationContainer(sourceSet, refmapName, pattern));