Skip to content

Commit

Permalink
Add option to disable auto skip remap
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Nov 22, 2023
1 parent 5b63d05 commit 072d4b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
28 changes: 19 additions & 9 deletions src/main/java/net/fabricmc/loom/task/AbstractRemapJarTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public abstract class AbstractRemapJarTask extends Jar {
@ApiStatus.Internal
public abstract Property<String> getJarType();

@ApiStatus.Experimental
@Input
@Optional
public abstract Property<Boolean> getAutoSkipRemap();

private final Provider<JarManifestService> jarManifestServiceProvider;

@Inject
Expand All @@ -126,6 +131,20 @@ public AbstractRemapJarTask() {
usesService(jarManifestServiceProvider);
}

protected final <P extends AbstractRemapParams> void autoSkipRemap(LoomGradleExtension extension, P params) {
if (getAutoSkipRemap().getOrElse(true) && shouldSkipRemap(extension)) {
params.getSourceNamespace().set(getTargetNamespace());
}
}

private boolean shouldSkipRemap(LoomGradleExtension extension) {
return extension.isNeoForge()
&& extension.getMappingConfiguration() instanceof FieldMigratedMappingConfiguration c
&& c.isMojangMappedProject()
&& MappingsNamespace.of(this.getSourceNamespace().get()) == MappingsNamespace.NAMED
&& MappingsNamespace.of(this.getTargetNamespace().get()) == MappingsNamespace.MOJANG;
}

public final <P extends AbstractRemapParams> void submitWork(Class<? extends AbstractRemapAction<P>> workAction, Action<P> action) {
final WorkQueue workQueue = getWorkerExecutor().noIsolation();

Expand Down Expand Up @@ -160,15 +179,6 @@ public final <P extends AbstractRemapParams> void submitWork(Class<? extends Abs

protected abstract List<String> getClientOnlyEntries(SourceSet sourceSet);

@ApiStatus.Internal
public boolean shouldSkipRemap(LoomGradleExtension extension) {
return extension.isNeoForge()
&& extension.getMappingConfiguration() instanceof FieldMigratedMappingConfiguration c
&& c.isMojangMappedProject()
&& MappingsNamespace.of(this.getSourceNamespace().get()) == MappingsNamespace.NAMED
&& MappingsNamespace.of(this.getTargetNamespace().get()) == MappingsNamespace.MOJANG;
}

public interface AbstractRemapParams extends WorkParameters {
RegularFileProperty getInputFile();
RegularFileProperty getOutputFile();
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/fabricmc/loom/task/RemapJarTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,9 @@ private void setupPreparationTask() {
public void run() {
final LoomGradleExtension extension = LoomGradleExtension.get(getProject());

if (shouldSkipRemap(extension)) {
getSourceNamespace().convention(getTargetNamespace());
}

submitWork(RemapAction.class, params -> {
autoSkipRemap(extension, params);

if (getAddNestedDependencies().get()) {
params.getNestedJars().from(getNestedJars());

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public RemapSourcesJarTask() {
public void run() {
final LoomGradleExtension extension = LoomGradleExtension.get(getProject());

if (shouldSkipRemap(extension)) {
getSourceNamespace().convention(getTargetNamespace());
}

submitWork(RemapSourcesAction.class, params -> {
autoSkipRemap(extension, params);

if (!params.namespacesMatch()) {
params.getSourcesRemapperServiceUuid().set(UnsafeWorkQueueHelper.create(SourceRemapperService.create(serviceManagerProvider.get().get(), this)));
}
Expand Down

0 comments on commit 072d4b3

Please sign in to comment.