Skip to content

Commit

Permalink
Add a way to exclude repositories from well known repositories (#18)
Browse files Browse the repository at this point in the history
* Initial ExtraRepositories module

* Switch to excludeWellKnownRepositories and remove MMD repo

* Re-enable includeWellKnownRepositories by default
  • Loading branch information
Cleptomania authored Jul 23, 2024
1 parent 640a6c8 commit 5eb804d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<String> 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"); });
});
});
}
}
}

0 comments on commit 5eb804d

Please sign in to comment.