diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java b/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java index 927ca74..4b25611 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java @@ -533,10 +533,24 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe preferPopulated = true, required = false, docComment = """ - Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories. + Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories. """) public boolean includeWellKnownRepositories = true; + /** See annotation */ + @Prop( + name = "excludeWellKnownRepositories", + isSettings = false, + preferPopulated = true, + required = false, + docComment = """ + A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated + list of strings, with the acceptable keys being(case does not matter): + cursemaven + modrinth + """) + public @NotNull String excludeWellKnownRepositories = ""; + /** See annotation */ @Prop( name = "useIC2FromCurseforge", diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java index ac43248..34ae2f6 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java @@ -8,6 +8,9 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; +import java.util.List; + /** Provides various well-known repositories to the buildscript */ public class WellKnownRepositoriesModule implements GTNHModule { @@ -21,26 +24,29 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final RepositoryHandler repos = project.getRepositories(); final ModUtils modUtils = project.getExtensions() .getByType(ModUtils.class); - repos.exclusiveContent(ec -> { - ec.forRepositories(repos.maven(mvn -> { - mvn.setName("CurseMaven"); - mvn.setUrl("https://cursemaven.com"); - })); - ec.filter(f -> { f.includeGroup("curse.maven"); }); - }); - repos.exclusiveContent(ec -> { - ec.forRepositories(repos.maven(mvn -> { - mvn.setName("Modrinth"); - mvn.setUrl("https://api.modrinth.com/maven"); - })); - ec.filter(f -> { f.includeGroup("maven.modrinth"); }); - }); - // MMD maven often goes down with a broken certificate - project.afterEvaluate(p -> { - repos.maven(mvn -> { - mvn.setName("MMD Maven"); - mvn.setUrl("https://maven.mcmoddev.com/"); + + List excludes = Arrays.asList( + gtnh.configuration.excludeWellKnownRepositories.toUpperCase() + .split(" ")); + + if (!excludes.contains("CURSEMAVEN")) { + repos.exclusiveContent(ec -> { + ec.forRepositories(repos.maven(mvn -> { + mvn.setName("CurseMaven"); + mvn.setUrl("https://cursemaven.com"); + })); + ec.filter(f -> { f.includeGroup("curse.maven"); }); + }); + } + + if (!excludes.contains("MODRINTH")) { + repos.exclusiveContent(ec -> { + ec.forRepositories(repos.maven(mvn -> { + mvn.setName("Modrinth"); + mvn.setUrl("https://api.modrinth.com/maven"); + })); + ec.filter(f -> { f.includeGroup("maven.modrinth"); }); }); - }); + } } }