Skip to content

Commit

Permalink
Refresh the alternativeResolutionRepo support to test Artifactory mig…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
Cervator committed Dec 1, 2024
1 parent 38cbf5c commit 2c6339b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
26 changes: 24 additions & 2 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
18 changes: 15 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
18 changes: 15 additions & 3 deletions templates/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Check warning on line 25 in templates/build.gradle

View check run for this annotation

Terasology Jenkins.io / Open Tasks Scanner

TODO

NORMAL: MYSTERY: As of November 7th 2011 virtual-repo-live could no longer be relied on for latest snapshots - Pro feature?
Expand Down
15 changes: 13 additions & 2 deletions templates/facades.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down

0 comments on commit 2c6339b

Please sign in to comment.