Add refmap target namespace property. (#628)

* Add refmap target namespace Property.

* Fix build.
This commit is contained in:
modmuss50
2022-04-17 21:15:58 +01:00
committed by GitHub
parent 0fda2a07bd
commit 5f5dfcb3a7
3 changed files with 17 additions and 2 deletions

View File

@@ -36,6 +36,8 @@ public interface MixinExtensionAPI {
Property<String> getDefaultRefmapName();
Property<String> getRefmapTargetNamespace();
/**
* Apply Mixin AP to sourceSet.
* @param sourceSet the sourceSet that applies Mixin AP.

View File

@@ -89,7 +89,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, loom.getMappingsProvider().tinyMappings.toFile().getCanonicalPath());
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, MixinMappingsService.getMixinMappingFile(project, sourceSet).getCanonicalPath());
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, refmapName));
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:" + loom.getMixin().getRefmapTargetNamespace().get());
put(Constants.MixinArguments.QUIET, "true");
}};

View File

@@ -1,7 +1,7 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 FabricMC
* Copyright (c) 2021-2022 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,15 +36,21 @@ import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.util.PatternSet;
import net.fabricmc.loom.api.MixinExtensionAPI;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
protected final Project project;
protected final Property<Boolean> useMixinAp;
private final Property<String> refmapTargetNamespace;
public MixinExtensionApiImpl(Project project) {
this.project = Objects.requireNonNull(project);
this.useMixinAp = project.getObjects().property(Boolean.class)
.convention(true);
this.refmapTargetNamespace = project.getObjects().property(String.class)
.convention(MappingsNamespace.INTERMEDIARY.toString());
this.refmapTargetNamespace.finalizeValueOnRead();
}
protected final PatternSet add0(SourceSet sourceSet, String refmapName) {
@@ -58,6 +64,13 @@ public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
return useMixinAp;
}
@Override
public Property<String> getRefmapTargetNamespace() {
if (!getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor.");
return refmapTargetNamespace;
}
@Override
public void add(SourceSet sourceSet, String refmapName, Action<PatternSet> action) {
PatternSet pattern = add0(sourceSet, refmapName);