Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@
import org.gradle.api.Action;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project;
import org.gradle.api.logging.configuration.WarningMode;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.util.PatternSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.fabricmc.loom.api.MixinExtensionAPI;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;

public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
static final String MIXIN_AP_DISABLED_ERROR = "The mixin annotation is no longer enabled by default, you should remove any loom.mixin configuration. If you wish to continue to use the mixin AP you can set useLegacyMixinAp = true.";
private static final String MIXIN_AP_DISABLED_ERROR = "The mixin annotation is no longer enabled by default, you should remove any loom.mixin configuration. If you wish to continue to use the mixin AP you can set useLegacyMixinAp = true.";
private static final Logger LOGGER = LoggerFactory.getLogger(MixinExtensionApiImpl.class);

protected final Project project;
protected final Property<Boolean> useMixinAp;
Expand Down Expand Up @@ -77,7 +81,7 @@ public Property<Boolean> getUseLegacyMixinAp() {

@Override
public Property<String> getRefmapTargetNamespace() {
if (!getUseLegacyMixinAp().get()) throw new IllegalStateException(MIXIN_AP_DISABLED_ERROR);
if (!getUseLegacyMixinAp().get()) logLegacyMixinAPConfiguration();

return refmapTargetNamespace;
}
Expand Down Expand Up @@ -175,4 +179,14 @@ protected PatternSet add0(SourceSet sourceSet, Provider<String> refmapName) {
throw new RuntimeException("Yeah... something is really wrong");
}
}

final void logLegacyMixinAPConfiguration() {
final WarningMode warningMode = project.getGradle().getStartParameter().getWarningMode();

if (warningMode == WarningMode.Fail) {
throw new IllegalStateException(MIXIN_AP_DISABLED_ERROR);
} else if (warningMode != WarningMode.None) {
LOGGER.warn(MIXIN_AP_DISABLED_ERROR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public MixinExtensionImpl(Project project) {

@Override
public Property<String> getDefaultRefmapName() {
if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException(MIXIN_AP_DISABLED_ERROR);
if (!super.getUseLegacyMixinAp().get()) logLegacyMixinAPConfiguration();

return defaultRefmapName;
}
Expand All @@ -81,7 +81,7 @@ private String getDefaultMixinRefmapName() {

@Override
protected PatternSet add0(SourceSet sourceSet, Provider<String> refmapName) {
if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException(MIXIN_AP_DISABLED_ERROR);
if (!super.getUseLegacyMixinAp().get()) logLegacyMixinAPConfiguration();

PatternSet pattern = new PatternSet().setIncludes(Collections.singletonList("**/*.json"));
MixinExtension.setMixinInformationContainer(sourceSet, new MixinExtension.MixinInformationContainer(sourceSet, refmapName, pattern));
Expand Down