Skip to content

Commit

Permalink
Cleanup from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Cervator committed Apr 2, 2020
1 parent d3e3cd0 commit 935895b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 77 deletions.
35 changes: 13 additions & 22 deletions config/gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,21 @@ publishing {
url = "http://artifactory.terasology.org/artifactory/$publishRepo"
println "Changing PUBLISH repoKey set via Gradle property to $publishRepo"
} else {
// In this case we are going to fletch the publish repo together from a few things
// First if we have an override from the environment to use a different target publish org
// Support override from the environment to use a different target publish org
String deducedPublishRepo = System.getenv()["PUBLISH_ORG"]
if (deducedPublishRepo == null || deducedPublishRepo == "") {
// If not then default
deducedPublishRepo = "terasology"
}
String releaseRepoFragment = "-release-local"
String snapshotRepoFragment = "-snapshot-local"

// Secondly we're going to find out if we're doing a release or a snapshot - this gets a little more complicated
// Check the active Git branch and some module logic to see whether we're doing a release or snapshot
String gitBranch = System.getenv()["BRANCH_NAME"]
if (gitBranch != null && gitBranch != "" && gitBranch.equals("master")) {
// Okay we're in an environment where a branch name is set to 'master' so we might be doing a release
// This is the funny part. Modules aren't ready globally to accept master branch == release, so check a prop that defaults to bypass
if (project.hasProperty("bypassModuleReleaseManagement")) {
if (bypassModuleReleaseManagement == "true") {
println "Release management not enabled for " + project.name + ", using snapshot repo despite building 'master' branch"
deducedPublishRepo += snapshotRepoFragment
} else {
println "Release management *is* enabled for " + project.name + ", using release repo since building 'master' branch"
deducedPublishRepo += releaseRepoFragment
}
} else {
println "We're working on a 'master' branch with defaults so using the release publish repo"
deducedPublishRepo += releaseRepoFragment
}
if (isMaster(gitBranch) && !shouldBypassModuleRelease()) {
deducedPublishRepo += "-release-local"
} else {
// No master branch so we for sure are just doing snapshots
println "We're not working with a branch name set that's 'master' so assuming we're publishing snapshots"
deducedPublishRepo += "-snapshot-local"
}

println "The final deduced publish repo is $deducedPublishRepo"
url = "http://artifactory.terasology.org/artifactory/$deducedPublishRepo"
}
Expand All @@ -73,3 +56,11 @@ publishing {
}
}

def isMaster(gitBranch) {
return gitBranch != null && gitBranch != "" && gitBranch.equals("master");
}

// Mildly awkward: Modules aren't ready globally to accept master branch == release, so make it opt-in by checking a prop that defaults to bypass
def shouldBypassModuleRelease() {
return project.hasProperty("bypassModuleReleaseManagement") && bypassModuleReleaseManagement == "true";
}
23 changes: 12 additions & 11 deletions modules/BiomesAPI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ version = moduleConfig.version
import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Check for an outright -SNAPSHOT in the loaded version - for ease of use we want to get rid of that everywhere, so warn about it and remove for the variable
def undesiredSnapshotTag = version.endsWith("-SNAPSHOT")
println "BiomesAPI version before the snapshot check: " + version
if (undesiredSnapshotTag) {
println "Taking off undesired -SNAPSHOT"
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}

// The only case in which we make module non-snapshots is if release management is enabled and BRANCH_NAME is "master"
if (moduleConfig.isReleaseManaged && env.BRANCH_NAME == "master") {
// This is mildly awkward since we need to bypass by default, yet if release management is on (true) then we set the bypass to false ..
ext.bypassModuleReleaseManagement = false
if (version.contains("-SNAPSHOT")) {
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
} else {
if (!version.contains("-SNAPSHOT")) {
version += "-SNAPSHOT"
} else {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
// In the case where we actually are building a snapshot we load -SNAPSHOT into the version variable, even if it wasn't there in module.txt
version += "-SNAPSHOT"
}

// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
Expand Down
23 changes: 12 additions & 11 deletions modules/BuilderSampleGameplay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ version = moduleConfig.version
import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Check for an outright -SNAPSHOT in the loaded version - for ease of use we want to get rid of that everywhere, so warn about it and remove for the variable
def undesiredSnapshotTag = version.endsWith("-SNAPSHOT")
println "BiomesAPI version before the snapshot check: " + version
if (undesiredSnapshotTag) {
println "Taking off undesired -SNAPSHOT"
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}

// The only case in which we make module non-snapshots is if release management is enabled and BRANCH_NAME is "master"
if (moduleConfig.isReleaseManaged && env.BRANCH_NAME == "master") {
// This is mildly awkward since we need to bypass by default, yet if release management is on (true) then we set the bypass to false ..
ext.bypassModuleReleaseManagement = false
if (version.contains("-SNAPSHOT")) {
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
} else {
if (!version.contains("-SNAPSHOT")) {
version += "-SNAPSHOT"
} else {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
// In the case where we actually are building a snapshot we load -SNAPSHOT into the version variable, even if it wasn't there in module.txt
version += "-SNAPSHOT"
}

// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
Expand Down
23 changes: 12 additions & 11 deletions modules/Core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ version = moduleConfig.version
import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Check for an outright -SNAPSHOT in the loaded version - for ease of use we want to get rid of that everywhere, so warn about it and remove for the variable
def undesiredSnapshotTag = version.endsWith("-SNAPSHOT")
println "BiomesAPI version before the snapshot check: " + version
if (undesiredSnapshotTag) {
println "Taking off undesired -SNAPSHOT"
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}

// The only case in which we make module non-snapshots is if release management is enabled and BRANCH_NAME is "master"
if (moduleConfig.isReleaseManaged && env.BRANCH_NAME == "master") {
// This is mildly awkward since we need to bypass by default, yet if release management is on (true) then we set the bypass to false ..
ext.bypassModuleReleaseManagement = false
if (version.contains("-SNAPSHOT")) {
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
} else {
if (!version.contains("-SNAPSHOT")) {
version += "-SNAPSHOT"
} else {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
// In the case where we actually are building a snapshot we load -SNAPSHOT into the version variable, even if it wasn't there in module.txt
version += "-SNAPSHOT"
}

// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
Expand Down
23 changes: 12 additions & 11 deletions modules/CoreSampleGameplay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ version = moduleConfig.version
import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Check for an outright -SNAPSHOT in the loaded version - for ease of use we want to get rid of that everywhere, so warn about it and remove for the variable
def undesiredSnapshotTag = version.endsWith("-SNAPSHOT")
println "BiomesAPI version before the snapshot check: " + version
if (undesiredSnapshotTag) {
println "Taking off undesired -SNAPSHOT"
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}

// The only case in which we make module non-snapshots is if release management is enabled and BRANCH_NAME is "master"
if (moduleConfig.isReleaseManaged && env.BRANCH_NAME == "master") {
// This is mildly awkward since we need to bypass by default, yet if release management is on (true) then we set the bypass to false ..
ext.bypassModuleReleaseManagement = false
if (version.contains("-SNAPSHOT")) {
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
} else {
if (!version.contains("-SNAPSHOT")) {
version += "-SNAPSHOT"
} else {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
// In the case where we actually are building a snapshot we load -SNAPSHOT into the version variable, even if it wasn't there in module.txt
version += "-SNAPSHOT"
}

// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
Expand Down
23 changes: 12 additions & 11 deletions templates/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ version = moduleConfig.version
import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.internal.logging.text.StyledTextOutput.Style

// Check for an outright -SNAPSHOT in the loaded version - for ease of use we want to get rid of that everywhere, so warn about it and remove for the variable
def undesiredSnapshotTag = version.endsWith("-SNAPSHOT")
println "BiomesAPI version before the snapshot check: " + version
if (undesiredSnapshotTag) {
println "Taking off undesired -SNAPSHOT"
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}

// The only case in which we make module non-snapshots is if release management is enabled and BRANCH_NAME is "master"
if (moduleConfig.isReleaseManaged && env.BRANCH_NAME == "master") {
// This is mildly awkward since we need to bypass by default, yet if release management is on (true) then we set the bypass to false ..
ext.bypassModuleReleaseManagement = false
if (version.contains("-SNAPSHOT")) {
version -= "-SNAPSHOT"
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
} else {
if (!version.contains("-SNAPSHOT")) {
version += "-SNAPSHOT"
} else {
def out = services.get(StyledTextOutputFactory).create("an-ouput")
out.withStyle(Style.FailureHeader).println("WARNING: Module " + project.name + " is explicitly versioned as a snapshot in module.txt, please remove '-SNAPSHOT'")
}
// In the case where we actually are building a snapshot we load -SNAPSHOT into the version variable, even if it wasn't there in module.txt
version += "-SNAPSHOT"
}

// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
Expand Down

0 comments on commit 935895b

Please sign in to comment.