|
28 | 28 | import com.google.gson.JsonSyntaxException; |
29 | 29 |
|
30 | 30 | import groovy.lang.Closure; |
| 31 | +import net.minecraftforge.artifactural.gradle.GradleRepositoryAdapter; |
31 | 32 | import net.minecraftforge.gradle.common.config.MCPConfigV1; |
32 | 33 | import net.minecraftforge.gradle.common.task.ExtractNatives; |
33 | 34 | import net.minecraftforge.gradle.common.util.VersionJson.Download; |
|
37 | 38 | import org.apache.commons.io.IOUtils; |
38 | 39 | import org.gradle.api.Project; |
39 | 40 | import org.gradle.api.Task; |
| 41 | +import org.gradle.api.artifacts.repositories.ArtifactRepository; |
40 | 42 | import org.gradle.api.plugins.JavaPluginConvention; |
41 | 43 | import org.gradle.api.tasks.TaskProvider; |
42 | 44 | import org.gradle.util.GradleVersion; |
@@ -93,6 +95,7 @@ public class Utils { |
93 | 95 | private static final boolean ENABLE_TEST_CERTS = Boolean.parseBoolean(System.getProperty("net.minecraftforge.gradle.test_certs", "true")); |
94 | 96 | private static final boolean ENABLE_TEST_GRADLE = Boolean.parseBoolean(System.getProperty("net.minecraftforge.gradle.test_gradle", "true")); |
95 | 97 | private static final boolean ENABLE_TEST_JAVA = Boolean.parseBoolean(System.getProperty("net.minecraftforge.gradle.test_java", "true")); |
| 98 | + private static final boolean ENABLE_FILTER_REPOS = Boolean.parseBoolean(System.getProperty("net.minecraftforge.gradle.filter_repos", "true")); |
96 | 99 |
|
97 | 100 | public static final Gson GSON = new GsonBuilder() |
98 | 101 | .registerTypeAdapter(MCPConfigV1.Step.class, new MCPConfigV1.Step.Deserializer()) |
@@ -668,6 +671,21 @@ public static void createRunConfigTasks(final MinecraftExtension extension, fina |
668 | 671 | }); |
669 | 672 | } |
670 | 673 |
|
| 674 | + public static void addRepoFilters(Project project) { |
| 675 | + if (!ENABLE_FILTER_REPOS) return; |
| 676 | + |
| 677 | + // Modify Repos already present and when they get added |
| 678 | + project.getRepositories().all(Utils::addMappedFilter); |
| 679 | + } |
| 680 | + |
| 681 | + private static void addMappedFilter(ArtifactRepository repository) { |
| 682 | + // Skip our "Fake" Repos that actually do provide the de-obfuscated Artifacts |
| 683 | + if (repository instanceof GradleRepositoryAdapter) return; |
| 684 | + |
| 685 | + // Exclude Artifacts that are being de-obfuscated via ForgeGradle (_mapped_ in version) |
| 686 | + repository.content(rcd -> rcd.excludeVersionByRegex(".*", ".*", ".*_mapped_.*")); |
| 687 | + } |
| 688 | + |
671 | 689 | public static File getMCDir() |
672 | 690 | { |
673 | 691 | switch (VersionJson.OS.getCurrent()) { |
|
0 commit comments