-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathLoomGradleExtensionApiImpl.java
More file actions
600 lines (495 loc) · 22.8 KB
/
LoomGradleExtensionApiImpl.java
File metadata and controls
600 lines (495 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2021-2025 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.fabricmc.loom.extension;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.NamedDomainObjectList;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.SetProperty;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.tasks.Jar;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.api.InterfaceInjectionExtensionAPI;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinExtensionAPI;
import net.fabricmc.loom.api.ModSettings;
import net.fabricmc.loom.api.RemapConfigurationSettings;
import net.fabricmc.loom.api.decompilers.DecompilerOptions;
import net.fabricmc.loom.api.mappings.intermediate.IntermediateMappingsProvider;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
import net.fabricmc.loom.api.mappings.layered.spec.LayeredMappingSpecBuilder;
import net.fabricmc.loom.api.processor.MinecraftJarProcessor;
import net.fabricmc.loom.api.remapping.RemapperExtension;
import net.fabricmc.loom.api.remapping.RemapperParameters;
import net.fabricmc.loom.configuration.RemapConfigurations;
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
import net.fabricmc.loom.configuration.mods.ArtifactMetadata;
import net.fabricmc.loom.configuration.processors.JarProcessor;
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec;
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilderImpl;
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsFactory;
import net.fabricmc.loom.configuration.providers.minecraft.ManifestLocations;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftJarConfiguration;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMetadataProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftSourceSets;
import net.fabricmc.loom.task.GenerateSourcesTask;
import net.fabricmc.loom.util.DeprecationHelper;
import net.fabricmc.loom.util.MirrorUtil;
import net.fabricmc.loom.util.fmj.FabricModJson;
import net.fabricmc.loom.util.fmj.FabricModJsonHelpers;
import net.fabricmc.loom.util.gradle.SourceSetHelper;
/**
* This class implements the public extension api.
*/
public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionAPI {
protected final DeprecationHelper deprecationHelper;
@Deprecated()
protected final ListProperty<JarProcessor> jarProcessors;
protected final ConfigurableFileCollection log4jConfigs;
protected final RegularFileProperty accessWidener;
protected final RegularFileProperty fabricModJsonPath;
protected final ManifestLocations versionsManifests;
protected final Property<String> customMetadata;
protected final SetProperty<String> knownIndyBsms;
protected final Property<Boolean> transitiveAccessWideners;
protected final Property<Boolean> modProvidedJavadoc;
protected final Property<String> intermediary;
protected final Property<IntermediateMappingsProvider> intermediateMappingsProvider;
private final Property<String> productionNamespace;
private final Property<Boolean> useIntermediateMappings;
private final Property<String> defaultMixinRemapType;
private final Property<Boolean> remapJsrAnnotationsToJetBrains;
private final Property<Boolean> runtimeOnlyLog4j;
private final Property<Boolean> runtimeOnlyLwjglGraphics;
private final Property<Boolean> splitModDependencies;
private final Property<MinecraftJarConfiguration<?, ?, ?>> minecraftJarConfiguration;
private final Property<Boolean> splitEnvironmentalSourceSet;
private final InterfaceInjectionExtensionAPI interfaceInjectionExtension;
private final NamedDomainObjectContainer<RunConfigSettings> runConfigs;
private final NamedDomainObjectContainer<DecompilerOptions> decompilers;
private final NamedDomainObjectContainer<ModSettings> mods;
private final NamedDomainObjectList<RemapConfigurationSettings> remapConfigurations;
private final ListProperty<MinecraftJarProcessor<?>> minecraftJarProcessors;
protected final ListProperty<RemapperExtensionHolder> remapperExtensions;
// A common mistake with layered mappings is to call the wrong `officialMojangMappings` method, use this to keep track of when we are building a layered mapping spec.
protected final ThreadLocal<Boolean> layeredSpecBuilderScope = ThreadLocal.withInitial(() -> false);
public static final String DEFAULT_INTERMEDIARY_URL = "https://maven.fabricmc.net/net/fabricmc/intermediary/%1$s/intermediary-%1$s-v2.jar";
protected boolean hasEvaluatedLayeredMappings = false;
protected final Map<LayeredMappingSpec, LayeredMappingsFactory> layeredMappingsDependencyMap = new HashMap<>();
protected LoomGradleExtensionApiImpl(Project project, LoomFiles directories) {
this.jarProcessors = project.getObjects().listProperty(JarProcessor.class)
.empty();
this.log4jConfigs = project.files(directories.getDefaultLog4jConfigFile());
this.accessWidener = project.getObjects().fileProperty();
this.fabricModJsonPath = project.getObjects().fileProperty();
this.versionsManifests = new ManifestLocations();
this.versionsManifests.add("mojang", MirrorUtil.getVersionManifests(project), -2);
this.versionsManifests.add("fabric_experimental", MirrorUtil.getExperimentalVersions(project), -1);
this.customMetadata = project.getObjects().property(String.class);
this.knownIndyBsms = project.getObjects().setProperty(String.class).convention(Set.of(
"java/lang/invoke/StringConcatFactory",
"java/lang/runtime/ObjectMethods",
"org/codehaus/groovy/vmplugin/v8/IndyInterface"
));
this.knownIndyBsms.finalizeValueOnRead();
this.transitiveAccessWideners = project.getObjects().property(Boolean.class)
.convention(true);
this.transitiveAccessWideners.finalizeValueOnRead();
this.modProvidedJavadoc = project.getObjects().property(Boolean.class)
.convention(true);
this.modProvidedJavadoc.finalizeValueOnRead();
this.intermediary = project.getObjects().property(String.class)
.convention(DEFAULT_INTERMEDIARY_URL);
this.productionNamespace = project.getObjects().property(String.class);
this.productionNamespace.convention(project.provider(() -> LoomGradleExtension.get(project).getMetadataProvider().isUnobfuscated() ? MappingsNamespace.OFFICIAL.toString() : MappingsNamespace.INTERMEDIARY.toString()));
this.productionNamespace.finalizeValueOnRead();
this.useIntermediateMappings = project.getObjects().property(Boolean.class);
this.useIntermediateMappings.convention(project.provider(() -> !LoomGradleExtension.get(project).getMetadataProvider().isUnobfuscated()));
this.useIntermediateMappings.finalizeValueOnRead();
this.defaultMixinRemapType = project.getObjects().property(String.class);
this.defaultMixinRemapType.convention(project.provider(() -> LoomGradleExtension.get(project).getMetadataProvider().isUnobfuscated() ? ArtifactMetadata.MixinRemapType.STATIC.name() : ArtifactMetadata.MixinRemapType.MIXIN.name()));
this.defaultMixinRemapType.finalizeValueOnRead();
this.intermediateMappingsProvider = project.getObjects().property(IntermediateMappingsProvider.class);
this.intermediateMappingsProvider.finalizeValueOnRead();
this.deprecationHelper = new DeprecationHelper.ProjectBased(project);
this.runConfigs = project.container(RunConfigSettings.class,
baseName -> project.getObjects().newInstance(RunConfigSettings.class, project, baseName));
this.decompilers = project.getObjects().domainObjectContainer(DecompilerOptions.class);
this.mods = project.getObjects().domainObjectContainer(ModSettings.class);
this.remapConfigurations = project.getObjects().namedDomainObjectList(RemapConfigurationSettings.class);
//noinspection unchecked
this.minecraftJarProcessors = (ListProperty<MinecraftJarProcessor<?>>) (Object) project.getObjects().listProperty(MinecraftJarProcessor.class);
this.minecraftJarProcessors.finalizeValueOnRead();
//noinspection unchecked
this.minecraftJarConfiguration = project.getObjects().property((Class<MinecraftJarConfiguration<?, ?, ?>>) (Class<?>) MinecraftJarConfiguration.class)
.convention(project.provider(() -> {
final LoomGradleExtension extension = LoomGradleExtension.get(project);
final MinecraftMetadataProvider metadataProvider = extension.getMetadataProvider();
// if no configuration is selected by the user, attempt to select one
// based on the mc version and which sides are present for it
if (!metadataProvider.getVersionMeta().hasServer()) {
return MinecraftJarConfiguration.CLIENT_ONLY;
} else if (!metadataProvider.getVersionMeta().hasClient()) {
return MinecraftJarConfiguration.SERVER_ONLY;
} else if (!metadataProvider.getVersionMeta().isLegacyVersion()) {
return MinecraftJarConfiguration.MERGED;
} else {
return MinecraftJarConfiguration.LEGACY_MERGED;
}
}));
this.minecraftJarConfiguration.finalizeValueOnRead();
this.accessWidener.finalizeValueOnRead();
this.getGameJarProcessors().finalizeValueOnRead();
this.remapJsrAnnotationsToJetBrains = project.getObjects().property(Boolean.class).convention(true);
this.remapJsrAnnotationsToJetBrains.finalizeValueOnRead();
this.runtimeOnlyLog4j = project.getObjects().property(Boolean.class).convention(false);
this.runtimeOnlyLog4j.finalizeValueOnRead();
this.runtimeOnlyLwjglGraphics = project.getObjects().property(Boolean.class).convention(false);
this.runtimeOnlyLwjglGraphics.finalizeValueOnRead();
this.splitModDependencies = project.getObjects().property(Boolean.class).convention(true);
this.splitModDependencies.finalizeValueOnRead();
this.interfaceInjectionExtension = project.getObjects().newInstance(InterfaceInjectionExtensionAPI.class);
this.interfaceInjectionExtension.getIsEnabled().convention(true);
this.splitEnvironmentalSourceSet = project.getObjects().property(Boolean.class).convention(false);
this.splitEnvironmentalSourceSet.finalizeValueOnRead();
remapperExtensions = project.getObjects().listProperty(RemapperExtensionHolder.class);
remapperExtensions.finalizeValueOnRead();
// Enable dep iface injection by default
interfaceInjection(interfaceInjection -> {
interfaceInjection.getEnableDependencyInterfaceInjection().convention(true).finalizeValueOnRead();
});
}
@Override
public DeprecationHelper getDeprecationHelper() {
return deprecationHelper;
}
@Override
public RegularFileProperty getAccessWidenerPath() {
return accessWidener;
}
@Override
public RegularFileProperty getFabricModJsonPath() {
return fabricModJsonPath;
}
@Override
public NamedDomainObjectContainer<DecompilerOptions> getDecompilerOptions() {
return decompilers;
}
@Override
public void decompilers(Action<NamedDomainObjectContainer<DecompilerOptions>> action) {
action.execute(decompilers);
}
@Override
public ListProperty<JarProcessor> getGameJarProcessors() {
return jarProcessors;
}
@Override
public ListProperty<MinecraftJarProcessor<?>> getMinecraftJarProcessors() {
return minecraftJarProcessors;
}
@Override
public void addMinecraftJarProcessor(Class<? extends MinecraftJarProcessor<?>> clazz, Object... parameters) {
getMinecraftJarProcessors().add(getProject().getObjects().newInstance(clazz, parameters));
}
@Override
public Dependency officialMojangMappings() {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot use Mojang mappings in a non-obfuscated environment");
}
if (layeredSpecBuilderScope.get()) {
throw new IllegalStateException("Use `officialMojangMappings()` when configuring layered mappings, not the extension method `loom.officialMojangMappings()`");
}
return layered(LayeredMappingSpecBuilder::officialMojangMappings);
}
@Override
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot configure layered mappings in a non-obfuscated environment");
}
if (hasEvaluatedLayeredMappings) {
throw new IllegalStateException("Layered mappings have already been evaluated");
}
LayeredMappingSpecBuilderImpl builder = new LayeredMappingSpecBuilderImpl();
layeredSpecBuilderScope.set(true);
action.execute(builder);
layeredSpecBuilderScope.set(false);
final LayeredMappingSpec builtSpec = builder.build();
final LayeredMappingsFactory layeredMappingsFactory = layeredMappingsDependencyMap.computeIfAbsent(builtSpec, LayeredMappingsFactory::new);
return layeredMappingsFactory.createDependency(getProject());
}
@Override
public void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action) {
action.execute(runConfigs);
}
@Override
public NamedDomainObjectContainer<RunConfigSettings> getRunConfigs() {
return runConfigs;
}
@Override
public ConfigurableFileCollection getLog4jConfigs() {
return log4jConfigs;
}
@Override
public void mixin(Action<MixinExtensionAPI> action) {
action.execute(getMixin());
}
@Override
public ManifestLocations getVersionsManifests() {
return versionsManifests;
}
@Override
public Property<String> getCustomMinecraftMetadata() {
return customMetadata;
}
@Override
public SetProperty<String> getKnownIndyBsms() {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot configure known indyBsms in a non-obfuscated environment");
}
return knownIndyBsms;
}
@Override
public String getModVersion() {
List<FabricModJson> fabricModJsons = FabricModJsonHelpers.getModsInProject(getProject());
if (fabricModJsons.isEmpty()) {
throw new RuntimeException("Could not find a fabric.mod.json file in the main sourceset");
}
return fabricModJsons.getFirst().getModVersion();
}
@Override
public Property<Boolean> getEnableTransitiveAccessWideners() {
return transitiveAccessWideners;
}
@Override
public Property<Boolean> getEnableModProvidedJavadoc() {
return modProvidedJavadoc;
}
protected abstract Project getProject();
protected abstract LoomFiles getFiles();
@Override
public Property<String> getIntermediaryUrl() {
return intermediary;
}
@Override
public Property<String> getProductionNamespace() {
return productionNamespace;
}
@Override
public Property<Boolean> getUseIntermediateMappings() {
return useIntermediateMappings;
}
@Override
public Property<String> getDefaultMixinRemapType() {
return defaultMixinRemapType;
}
@Override
public IntermediateMappingsProvider getIntermediateMappingsProvider() {
if (LoomGradleExtension.get(getProject()).disableObfuscation()) {
throw new UnsupportedOperationException("Cannot get intermediate mappings provider in a non-obfuscated environment");
}
return intermediateMappingsProvider.get();
}
@Override
public void setIntermediateMappingsProvider(IntermediateMappingsProvider intermediateMappingsProvider) {
this.intermediateMappingsProvider.set(intermediateMappingsProvider);
}
@Override
public <T extends IntermediateMappingsProvider> void setIntermediateMappingsProvider(Class<T> clazz, Action<T> action) {
T provider = getProject().getObjects().newInstance(clazz);
configureIntermediateMappingsProviderInternal(provider);
action.execute(provider);
setIntermediateMappingsProvider(provider);
}
@Override
public File getMappingsFile() {
if (notObfuscated()) {
return null;
}
return LoomGradleExtension.get(getProject()).getMappingConfiguration().tinyMappings.toFile();
}
@Override
public GenerateSourcesTask getDecompileTask(DecompilerOptions options, boolean client) {
final String decompilerName = options.getFormattedName();
final String taskName;
if (areEnvironmentSourceSetsSplit()) {
taskName = "gen%sSourcesWith%s".formatted(client ? "ClientOnly" : "Common", decompilerName);
} else {
taskName = "genSourcesWith" + decompilerName;
}
return (GenerateSourcesTask) getProject().getTasks().getByName(taskName);
}
protected abstract <T extends IntermediateMappingsProvider> void configureIntermediateMappingsProviderInternal(T provider);
@Override
public void disableDeprecatedPomGeneration(MavenPublication publication) {
net.fabricmc.loom.configuration.MavenPublication.excludePublication(publication);
}
@Override
public Property<MinecraftJarConfiguration<?, ?, ?>> getMinecraftJarConfiguration() {
return minecraftJarConfiguration;
}
@Override
public Property<Boolean> getRemapJsrAnnotationsToJetBrains() {
return remapJsrAnnotationsToJetBrains;
}
@Override
public Property<Boolean> getRuntimeOnlyLog4j() {
return runtimeOnlyLog4j;
}
@Override
public Property<Boolean> getRuntimeOnlyLwjglGraphics() {
return runtimeOnlyLwjglGraphics;
}
@Override
public Property<Boolean> getSplitModDependencies() {
return splitModDependencies;
}
@Override
public void splitEnvironmentSourceSets() {
splitMinecraftJar();
splitEnvironmentalSourceSet.set(true);
// We need to lock these values, as we setup the new source sets right away.
splitEnvironmentalSourceSet.finalizeValue();
minecraftJarConfiguration.finalizeValue();
MinecraftSourceSets.get(getProject()).evaluateSplit(getProject());
}
@Override
public boolean areEnvironmentSourceSetsSplit() {
return splitEnvironmentalSourceSet.get();
}
@Override
public InterfaceInjectionExtensionAPI getInterfaceInjection() {
return interfaceInjectionExtension;
}
@Override
public void mods(Action<NamedDomainObjectContainer<ModSettings>> action) {
action.execute(getMods());
}
@Override
public NamedDomainObjectContainer<ModSettings> getMods() {
return mods;
}
@Override
public NamedDomainObjectList<RemapConfigurationSettings> getRemapConfigurations() {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot get remap configurations in a non-obfuscated environment");
}
return remapConfigurations;
}
@Override
public RemapConfigurationSettings addRemapConfiguration(String name, Action<RemapConfigurationSettings> action) {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot add remap configuration in a non-obfuscated environment");
}
final RemapConfigurationSettings configurationSettings = getProject().getObjects().newInstance(RemapConfigurationSettings.class, name);
// TODO remove in 2.0, this is a fallback to mimic the previous (Broken) behaviour
configurationSettings.getSourceSet().convention(SourceSetHelper.getMainSourceSet(getProject()));
action.execute(configurationSettings);
RemapConfigurations.applyToProject(getProject(), configurationSettings);
remapConfigurations.add(configurationSettings);
return configurationSettings;
}
@Override
public void createRemapConfigurations(SourceSet sourceSet) {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot create remap configurations in a non-obfuscated environment");
}
RemapConfigurations.setupForSourceSet(getProject(), sourceSet);
}
@Override
public <T extends RemapperParameters> void addRemapperExtension(Class<? extends RemapperExtension<T>> remapperExtensionClass, Class<T> parametersClass, Action<T> parameterAction) {
if (notObfuscated()) {
throw new UnsupportedOperationException("Cannot add remapper extension in a non-obfuscated environment");
}
final ObjectFactory objectFactory = getProject().getObjects();
final RemapperExtensionHolder holder;
if (parametersClass != RemapperParameters.None.class) {
T parameters = objectFactory.newInstance(parametersClass);
parameterAction.execute(parameters);
holder = objectFactory.newInstance(RemapperExtensionHolder.class, parameters);
} else {
holder = objectFactory.newInstance(RemapperExtensionHolder.class, RemapperParameters.None.INSTANCE);
}
holder.getRemapperExtensionClass().set(remapperExtensionClass.getName());
remapperExtensions.add(holder);
}
@Override
public Provider<String> getMinecraftVersion() {
return getProject().provider(() -> LoomGradleExtension.get(getProject()).getMinecraftProvider().minecraftVersion());
}
@Override
public FileCollection getNamedMinecraftJars() {
final ConfigurableFileCollection jars = getProject().getObjects().fileCollection();
jars.from(getProject().provider(() -> LoomGradleExtension.get(getProject()).getMinecraftJars(MappingsNamespace.NAMED)));
return jars;
}
private boolean notObfuscated() {
return LoomGradleExtension.get(getProject()).disableObfuscation();
}
// This is here to ensure that LoomGradleExtensionApiImpl compiles without any unimplemented methods
private final class EnsureCompile extends LoomGradleExtensionApiImpl {
private EnsureCompile() {
super(null, null);
throw new RuntimeException();
}
@Override
public DeprecationHelper getDeprecationHelper() {
throw new RuntimeException("Yeah... something is really wrong");
}
@Override
protected Project getProject() {
throw new RuntimeException("Yeah... something is really wrong");
}
@Override
protected LoomFiles getFiles() {
throw new RuntimeException("Yeah... something is really wrong");
}
@Override
protected <T extends IntermediateMappingsProvider> void configureIntermediateMappingsProviderInternal(T provider) {
throw new RuntimeException("Yeah... something is really wrong");
}
@Override
public MixinExtension getMixin() {
throw new RuntimeException("Yeah... something is really wrong");
}
@Override
public void nestJars(TaskProvider<? extends Jar> jarTask, FileCollection jars) {
throw new RuntimeException("Yeah... something is really wrong");
}
}
}