Skip to content

Commit

Permalink
Merge pull request #2581 from EngineHub/ot/debt/what-is-a-repository
Browse files Browse the repository at this point in the history
Completely eliminate usage of other repos
  • Loading branch information
octylFractal authored Jul 24, 2024
2 parents 9fae677 + c81c217 commit f5eefc0
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 73 deletions.
4 changes: 0 additions & 4 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ repositories {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
}
maven {
name = "SpongePowered"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}
}

dependencies {
Expand Down
15 changes: 15 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ configure<buildlogic.CommonJavaExtension> {
banSlf4j = false
}

paperweight {
injectPaperRepository = false
}

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
mavenCentral()
afterEvaluate {
killNonEngineHubRepositories()
}
}

dependencies {
"implementation"(project(":worldedit-bukkit"))
constraints {
Expand Down
8 changes: 0 additions & 8 deletions build-logic/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ plugins {
group = rootProject.group
version = rootProject.version

repositories {
mavenCentral()
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
}

configurations.all {
resolutionStrategy {
cacheChangingModulesFor(1, TimeUnit.DAYS)
Expand Down
37 changes: 37 additions & 0 deletions build-logic/src/main/kotlin/repositoriesHelper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.logging.Logging

// The primary point of this is repository up-time. We replace most other repositories with EngineHub's repository.
// This is because we have stronger up-time guarantees for our repository. However, Maven Central and Sonatype are
// clearly even better, so we allow those as well. We also allow Gradle's plugin repository.
private val ALLOWED_PREFIXES = listOf(
"https://maven.enginehub.org",
"https://repo.maven.apache.org/maven2/",
"https://s01.oss.sonatype.org/content/repositories/snapshots/",
"https://plugins.gradle.org",
"file:"
)
private val LOGGER = Logging.getLogger("repositoriesHelper")

fun RepositoryHandler.killNonEngineHubRepositories() {
val toRemove = mutableListOf<MavenArtifactRepository>()
for (repo in this) {
if (repo is MavenArtifactRepository && !ALLOWED_PREFIXES.any { repo.url.toString().startsWith(it) }) {
LOGGER.info("Removing non-EngineHub repository: {}", repo.url)
toRemove.add(repo)
}
}
toRemove.forEach { remove(it) }
}

fun RepositoryHandler.verifyEngineHubRepositories() {
for (repo in this) {
if (repo is MavenArtifactRepository) {
val urlString = repo.url.toString()
check(ALLOWED_PREFIXES.any { urlString.startsWith(it) }) {
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
}
}
}
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ version=7.3.5-SNAPSHOT

org.gradle.jvmargs=-Xmx1500M
org.gradle.parallel=true

loom_fabric_repository=https://maven.enginehub.org/artifactory/fabricmc/
loom_libraries_base=https://maven.enginehub.org/artifactory/minecraft/
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
44 changes: 40 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,50 @@ pluginManagement {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
maven {
name = "SpongePowered"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("fabric-loom") version "1.6.12"
}
dependencyResolutionManagement {
repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
ivy {
url = uri("https://repo.enginehub.org/language-files/")
name = "EngineHub Language Files"
patternLayout {
artifact("[organisation]/[module]/[revision]/[artifact]-[revision](+[classifier])(.[ext])")
setM2compatible(true)
}
metadataSources {
artifact()
}
content {
includeModuleByRegex(".*", "worldedit-lang")
}
}
gradle.settingsEvaluated {
// Duplicates repositoriesHelper.kt, since we can't import it
val allowedPrefixes = listOf(
"https://maven.enginehub.org",
"https://repo.maven.apache.org/maven2/",
"file:"
)

for (repo in this@repositories) {
if (repo is MavenArtifactRepository) {
val urlString = repo.url.toString()
check(allowedPrefixes.any { urlString.startsWith(it) }) {
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
}
}
}
}
}
}

logger.lifecycle("""
Expand Down
15 changes: 0 additions & 15 deletions verification/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ plugins {
id("me.champeau.gradle.japicmp")
}

repositories {
maven {
name = "EngineHub Repository (Releases Only)"
url = uri("https://maven.enginehub.org/artifactory/libs-release-local/")
}
maven {
name = "EngineHub Repository (Snapshots Only)"
url = uri("https://maven.enginehub.org/artifactory/libs-snapshot-local/")
content {
excludeGroup("com.sk89q.worldedit")
}
}
mavenCentral()
}

val resetAcceptedApiChangesFiles by tasks.registering {
group = "API Compatibility"
description = "Resets ALL the accepted API changes files"
Expand Down
7 changes: 0 additions & 7 deletions worldedit-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ platform {
includeClasspath = true
}

repositories {
maven {
name = "Spigot"
url = uri("https://hub.spigotmc.org/nexus/content/groups/public")
}
}

val localImplementation = configurations.create("localImplementation") {
description = "Dependencies used locally, but provided by the runtime Bukkit implementation"
isCanBeConsumed = false
Expand Down
14 changes: 0 additions & 14 deletions worldedit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ plugins {
id("buildlogic.core-and-platform")
}

repositories {
ivy {
url = uri("https://repo.enginehub.org/language-files/")
name = "EngineHub Language Files"
patternLayout {
artifact("[organisation]/[module]/[revision]/[artifact]-[revision](+[classifier])(.[ext])")
setM2compatible(true)
}
metadataSources {
artifact()
}
}
}

configurations {
register("languageFiles")
}
Expand Down
10 changes: 2 additions & 8 deletions worldedit-fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ tasks.withType<RunGameTask>().configureEach {
}

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
getByName("Mojang") {
content {
includeGroupAndSubgroups("com.mojang")
}
afterEvaluate {
verifyEngineHubRepositories()
}
}

Expand Down
13 changes: 6 additions & 7 deletions worldedit-neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ val apiClasspath = configurations.create("apiClasspath") {
}

repositories {
val toRemove = mutableListOf<MavenArtifactRepository>()
for (repo in project.repositories) {
if (repo is MavenArtifactRepository && repo.url.toString() == "https://maven.neoforged.net/releases/") {
toRemove.add(repo)
}
}
toRemove.forEach { remove(it) }
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
mavenCentral()
killNonEngineHubRepositories()
afterEvaluate {
killNonEngineHubRepositories()
}
}

dependencies {
Expand Down Expand Up @@ -72,6 +70,7 @@ subsystems {
parchment {
minecraftVersion = libs.versions.parchment.minecraft.get()
mappingsVersion = libs.versions.parchment.mappings.get()
addRepository = false
}
decompiler {
maxMemory("3G")
Expand Down
18 changes: 14 additions & 4 deletions worldedit-sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ commonJava {
banSlf4j = false
}

repositories {
mavenCentral()
}

minecraft {
injectRepositories(false)
version(libs.versions.sponge.minecraft.get())
}

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
mavenCentral()
verifyEngineHubRepositories()
afterEvaluate {
verifyEngineHubRepositories()
}
}

sponge {
injectRepositories(false)
apiVersion(libs.versions.sponge.api.asProvider().get())
license("GPL-3.0-or-later")
plugin("worldedit") {
Expand Down

0 comments on commit f5eefc0

Please sign in to comment.