Skip to content

Commit

Permalink
Improve how we declare repos for dependencies to make use of new FG f…
Browse files Browse the repository at this point in the history
…eatures and gradle's exclusiveContent filtering
  • Loading branch information
pupnewfster committed Mar 22, 2023
1 parent f46383f commit 4fbf99f
Showing 1 changed file with 28 additions and 65 deletions.
93 changes: 28 additions & 65 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import mekanism.MergeJars
import net.minecraftforge.gradle.common.util.RunConfig
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace

import java.util.function.Consumer

plugins {
id 'org.ajoberstar.grgit' version '5.0.0'
id "com.matthewprenger.cursegradle" version '1.4.0'
Expand Down Expand Up @@ -340,76 +342,37 @@ def setupRunConfig(RunConfig runConfig, boolean supportsGameTests, String direct
}
}

repositories {
maven {
name 'CraftTweaker'
url "https://maven.blamejared.com"
content {
includeGroupByRegex 'com\\.blamejared.*'
includeGroup 'mezz.jei'
}
}
maven {
name 'curios'
url "https://maven.theillusivec4.top/"
content {
includeGroup 'top.theillusivec4.curios'
}
}
maven {
name 'tterrag'
url 'https://maven.tterrag.com/'
content {
includeGroup 'team.chisel.ctm'
}
}
maven {
name 'ComputerCraft'
url "https://squiddev.cc/maven/"
content {
includeGroup 'org.squiddev'
}
}
maven {
name 'CurseMaven'
url 'https://www.cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
name 'Modmaven'
url 'https://modmaven.dev/'
content {
includeGroup 'appeng'
includeGroup 'mcjty.theoneprobe'
void exclusiveRepo(RepositoryHandler handler, String url, String... groups) {
exclusiveRepo(handler, url, filter -> {
for (def group : groups) {
filter.includeGroup(group)
}
}
})
}

configureEach {//ForgeGradle adds these in an afterEvaluate, so we need to catch them as they're added and exclude mod artifacts/groups
if (it instanceof MavenArtifactRepository) {
def url = it.url.toString()
if (url == 'https://maven.minecraftforge.net/' || url == 'https://libraries.minecraft.net/' || url == 'https://repo.maven.apache.org/maven2/') {
try {
it.content {
excludeGroup 'curse.maven'
excludeGroup 'mezz.jei'
excludeGroup 'mcjty.theoneprobe'
excludeGroup 'team.chisel.ctm'
excludeGroup 'appeng'
excludeGroupByRegex 'com\\.blamejared.*'
excludeGroup 'org.squiddev'
excludeGroup 'top.theillusivec4.curios'
}
println("Adding exclusions to ${url}")
} catch (Exception ignored) {
//oh well
}
}
}
//Note: This cannot be static so that fg.repository can be properly accessed
@SuppressWarnings('GrMethodMayBeStatic')
void exclusiveRepo(RepositoryHandler handler, String url, Consumer<InclusiveRepositoryContentDescriptor> filterSetup) {
handler.exclusiveContent {
it.forRepositories(handler.maven {
setUrl(url)
}, fg.repository)//Add FG's repo so we make sure we are able to then find the mapped deps
it.filter { f -> filterSetup.accept(f) }
}
}

repositories { RepositoryHandler handler ->
exclusiveRepo(handler, 'https://maven.blamejared.com', filter -> {
filter.includeGroupByRegex 'com\\.blamejared.*'
filter.includeGroup 'mezz.jei'
})
exclusiveRepo(handler, 'https://maven.theillusivec4.top/', 'top.theillusivec4.curios')
exclusiveRepo(handler, 'https://maven.tterrag.com/', 'team.chisel.ctm')
exclusiveRepo(handler, 'https://squiddev.cc/maven/', 'org.squiddev')
exclusiveRepo(handler, 'https://www.cursemaven.com', 'curse.maven')
exclusiveRepo(handler, 'https://modmaven.dev/', 'appeng', 'mcjty.theoneprobe')
}

test {
useJUnitPlatform()
}
Expand Down

0 comments on commit 4fbf99f

Please sign in to comment.