Skip to content

Commit 38ce4d4

Browse files
aurorasmilesoctylFractal
authored andcommitted
Port outside repo usage elimination
Ports da223671a5e5d0107d502234d7378522db162e3c from WorldEdit to Worldguard and updates Gradle. Co-authored-by: octylFractal <octavia.togami@gmail.com>
1 parent f89b149 commit 38ce4d4

File tree

7 files changed

+66
-4
lines changed

7 files changed

+66
-4
lines changed

build-logic/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ plugins {
44

55
repositories {
66
gradlePluginPortal()
7+
maven {
8+
name = "EngineHub Repository"
9+
url = uri("https://maven.enginehub.org/repo/")
10+
}
711
}
812

913
dependencies {

build-logic/src/main/kotlin/buildlogic.common.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ group = rootProject.group
1010
version = rootProject.version
1111

1212
repositories {
13-
mavenCentral()
1413
maven {
1514
name = "EngineHub"
1615
url = uri("https://maven.enginehub.org/repo/")
1716
}
17+
mavenCentral()
18+
afterEvaluate {
19+
killNonEngineHubRepositories()
20+
}
1821
}
1922

2023
configurations.all {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import org.gradle.api.artifacts.dsl.RepositoryHandler
2+
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
3+
import org.gradle.api.logging.Logging
4+
5+
// The primary point of this is repository up-time. We replace most other repositories with EngineHub's repository.
6+
// This is because we have stronger up-time guarantees for our repository. However, Maven Central and Sonatype are
7+
// clearly even better, so we allow those as well. We also allow Gradle's plugin repository.
8+
private val ALLOWED_PREFIXES = listOf(
9+
"https://maven.enginehub.org",
10+
"https://repo.maven.apache.org/maven2/",
11+
"https://s01.oss.sonatype.org/content/repositories/snapshots/",
12+
"https://plugins.gradle.org",
13+
"file:"
14+
)
15+
private val LOGGER = Logging.getLogger("repositoriesHelper")
16+
17+
fun RepositoryHandler.killNonEngineHubRepositories() {
18+
val toRemove = mutableListOf<MavenArtifactRepository>()
19+
for (repo in this) {
20+
if (repo is MavenArtifactRepository && !ALLOWED_PREFIXES.any { repo.url.toString().startsWith(it) }) {
21+
LOGGER.info("Removing non-EngineHub repository: {}", repo.url)
22+
toRemove.add(repo)
23+
}
24+
}
25+
toRemove.forEach { remove(it) }
26+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
worldedit = "7.3.0"
2+
worldedit = "7.3.9"
33

44
# Minimum versions we apply to make dependencies support newer Java
55
minimumAsm = "9.7"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
pluginManagement {
22
repositories {
33
gradlePluginPortal()
4+
maven {
5+
name = "EngineHub"
6+
url = uri("https://maven.enginehub.org/repo/")
7+
}
48
}
59
}
610
plugins {
711
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
812
}
13+
dependencyResolutionManagement {
14+
repositories {
15+
maven {
16+
name = "EngineHub"
17+
url = uri("https://maven.enginehub.org/repo/")
18+
}
19+
gradle.settingsEvaluated {
20+
// Duplicates repositoriesHelper.kt, since we can't import it
21+
val allowedPrefixes = listOf(
22+
"https://maven.enginehub.org",
23+
"https://repo.maven.apache.org/maven2/",
24+
"file:"
25+
)
26+
27+
for (repo in this@repositories) {
28+
if (repo is MavenArtifactRepository) {
29+
val urlString = repo.url.toString()
30+
check(allowedPrefixes.any { urlString.startsWith(it) }) {
31+
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
938

1039
logger.lifecycle("""
1140
*******************************************

0 commit comments

Comments
 (0)