From 2c6339b9ba3f1eef94c60cb331424b6e7fa4dc5a Mon Sep 17 00:00:00 2001 From: Cervator Date: Sat, 30 Nov 2024 23:53:29 -0500 Subject: [PATCH] Refresh the alternativeResolutionRepo support to test Artifactory migration --- build-logic/build.gradle.kts | 26 ++++++++++++++++++++++++-- build.gradle.kts | 18 +++++++++++++++--- templates/build.gradle | 18 +++++++++++++++--- templates/facades.gradle | 15 +++++++++++++-- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index e9511033f9f..19bde11e4cb 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -11,14 +11,36 @@ kotlin { jvmToolchain(17) } +// Since build-logic is special we have to cheat to test/get the alternativeResolutionRepo +val gradlePropertiesFile = file("../gradle.properties") +val alternativeResolutionRepo = if (gradlePropertiesFile.exists()) { + gradlePropertiesFile.readLines().firstOrNull { line -> + line.startsWith("alternativeResolutionRepo=") + }?.substringAfter("alternativeResolutionRepo=") +} else { + null +} + repositories { mavenCentral() google() // gestalt uses an annotation package by Google gradlePluginPortal() maven { - name = "Terasology Artifactory" - url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live") + val repoViaEnv = System.getenv()["RESOLUTION_REPO"] + if (alternativeResolutionRepo != null) { + // If the user supplies an alternative repo via gradle.properties then use that + name = "from alternativeResolutionRepo in gradle.properties" + url = URI(alternativeResolutionRepo) + } else if (repoViaEnv != null && repoViaEnv != "") { + name = "from \$RESOLUTION_REPO" + url = URI(repoViaEnv) + } else { + // Our default is the main virtual repo containing everything except repos for testing Artifactory itself + name = "Terasology Artifactory" + url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live") + //url = URI("https://artifactory.nanoware.us/artifactory/virtual-repo-live") + } } // TODO MYSTERY: As of November 7th 2021 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature? diff --git a/build.gradle.kts b/build.gradle.kts index faa105ee9fa..b929e067ae8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,10 +13,22 @@ buildscript { google() gradlePluginPortal() + // required to provide runtime dependencies to build-logic. maven { - // required to provide runtime dependencies to build-logic. - name = "Terasology Artifactory" - url = uri("https://artifactory.terasology.io/artifactory/virtual-repo-live") + val repoViaEnv = System.getenv()["RESOLUTION_REPO"] + if (rootProject.hasProperty("alternativeResolutionRepo")) { + // If the user supplies an alternative repo via gradle.properties then use that + name = "from alternativeResolutionRepo property" + // Fun Gradle/Kotlin-ism: a general import at the top of a class used in a buildscript block won't help + url = java.net.URI(rootProject.properties["alternativeResolutionRepo"] as String) + } else if (repoViaEnv != null && repoViaEnv != "") { + name = "from \$RESOLUTION_REPO" + url = java.net.URI(repoViaEnv) + } else { + // Our default is the main virtual repo containing everything except repos for testing Artifactory itself + name = "Terasology Artifactory" + url = java.net.URI("https://artifactory.terasology.io/artifactory/virtual-repo-live") + } } // TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature? diff --git a/templates/build.gradle b/templates/build.gradle index 5a4a69661de..3e2613d76a2 100644 --- a/templates/build.gradle +++ b/templates/build.gradle @@ -4,10 +4,22 @@ buildscript { repositories { mavenCentral() google() + + // required to provide runtime dependencies to build-logic. maven { - // required to provide runtime dependencies to build-logic. - name = "Terasology Artifactory" - url = "https://artifactory.terasology.io/artifactory/virtual-repo-live" + def repoViaEnv = System.getenv()["RESOLUTION_REPO"] + if (rootProject.hasProperty("alternativeResolutionRepo")) { + // If the user supplies an alternative repo via gradle.properties then use that + name = "from alternativeResolutionRepo property" + url = URI(rootProject.properties["alternativeResolutionRepo"] as String) + } else if (repoViaEnv != null && repoViaEnv != "") { + name = "from \$RESOLUTION_REPO" + url = URI(repoViaEnv) + } else { + // Our default is the main virtual repo containing everything except repos for testing Artifactory itself + name = "Terasology Artifactory" + url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live") + } } // TODO MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature? diff --git a/templates/facades.gradle b/templates/facades.gradle index 7733b3e024e..227d93e3d6f 100644 --- a/templates/facades.gradle +++ b/templates/facades.gradle @@ -11,8 +11,19 @@ repositories { // MovingBlocks Artifactory instance for libs not readily available elsewhere plus our own libs maven { - name "Terasology Artifactory" - url "https://artifactory.terasology.io/artifactory/repo" + def repoViaEnv = System.getenv()["RESOLUTION_REPO"] + if (rootProject.hasProperty("alternativeResolutionRepo")) { + // If the user supplies an alternative repo via gradle.properties then use that + name = "from alternativeResolutionRepo property" + url = URI(rootProject.properties["alternativeResolutionRepo"] as String) + } else if (repoViaEnv != null && repoViaEnv != "") { + name = "from \$RESOLUTION_REPO" + url = URI(repoViaEnv) + } else { + // Our default is the main virtual repo containing everything except repos for testing Artifactory itself + name = "Terasology Artifactory" + url = URI("https://artifactory.terasology.io/artifactory/virtual-repo-live") + } } }