Skip to content

Commit

Permalink
feat: Overhaul game version label content and trigger packaging of an…
Browse files Browse the repository at this point in the history
… Omega game zip in our new Jenkins
  • Loading branch information
Cervator committed Jan 16, 2021
1 parent 8a46305 commit 6f32a99
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 64 deletions.
11 changes: 11 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ node ("heavy-java") {
} else {
println "Running on a branch other than 'master' or 'develop' bypassing publishing"
}

// Trigger the Omega dist job to repackage a game zip with modules
if (env.JOB_NAME.equals("Terasology/engine/develop")) {
build job: 'Terasology/Omega/develop', wait: false
} else if (env.JOB_NAME.equals("Terasology/engine/master")) {
build job: 'Terasology/Omega/master', wait: false
} else if (env.JOB_NAME.equals("Nanoware/Terasology/develop")) {
build job: 'Nanoware/Omega/develop', wait: false
} else if (env.JOB_NAME.equals("Nanoware/Terasology/master")) {
build job: 'Nanoware/Omega/master', wait: false
}
}
stage('Analytics') {
sh "./gradlew --console=plain check spotbugsmain javadoc"
Expand Down
21 changes: 4 additions & 17 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,10 @@ ext {
startDateTimeString = dateTimeFormat.format(new Date())
versionInfoFileDir = new File(buildDir, 'classes/org/terasology/version')
versionInfoFile = new File(versionInfoFileDir, 'versionInfo.properties')
versionFileName = 'VERSION'
versionBase = new File(templatesDir, "version.txt").text.trim()
displayVersion = versionBase
}

def convertGitBranch = { gitBranch ->
if (gitBranch != null) {
// Remove "origin/" from "origin/develop"
gitBranch.substring(gitBranch.lastIndexOf("/") + 1)
} else {
""
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Java Section //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -174,7 +164,7 @@ jar {
def manifestClasspath = "$subDirLibs/" + configurations."${sourceSets.main.runtimeClasspathConfigurationName}".collect {
it.getName()
}.join(" $subDirLibs/")
attributes("Class-Path": manifestClasspath, "Implementation-Title": "Terasology-" + project.name, "Implementation-Version": env.BUILD_NUMBER + ", " + convertGitBranch(env.GIT_BRANCH) + ", " + env.BUILD_ID + ", " + displayVersion)
attributes("Class-Path": manifestClasspath, "Implementation-Title": "Terasology", "Implementation-Version": displayVersion + ", engine v" + version + " , build number " + env.BUILD_NUMBER)
}
}
}
Expand Down Expand Up @@ -229,10 +219,10 @@ group = 'org.terasology.engine'

println "Version for $project.name loaded as $version for group $group"

// This version info file actually goes inside the built jar and can be used at runtime
// This version info file actually goes inside the built jar and can be used at runtime - *if* building in Jenkins (JOB_NAME set)
task createVersionInfoFile {
inputs.property('dateTime', startDateTimeString)
onlyIf { env.BUILD_URL != null }
onlyIf { env.JOB_NAME != null }
doLast {
versionInfoFileDir.mkdirs()
ant.propertyfile(file: versionInfoFile) {
Expand All @@ -241,17 +231,14 @@ task createVersionInfoFile {
ant.entry(key: 'buildTag', value: env.BUILD_TAG)
ant.entry(key: 'buildUrl', value: env.BUILD_URL)
ant.entry(key: 'jobName', value: env.JOB_NAME)
ant.entry(key: 'gitBranch', value: convertGitBranch(env.GIT_BRANCH))
ant.entry(key: 'gitCommit', value: env.GIT_COMMIT)
ant.entry(key: 'dateTime', value: startDateTimeString)
ant.entry(key: 'displayVersion', value: displayVersion)
ant.entry(key: 'engineVersion', value: version)
}
}
}


//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
//TODO: Remove this when gestalt can handle ProtectionDomain without classes (Resources)
task copyResourcesToClasses(type: Copy) {
from sourceSets.main.output.resourcesDir
into sourceSets.main.output.classesDirs.first()
Expand Down
73 changes: 29 additions & 44 deletions engine/src/main/java/org/terasology/version/TerasologyVersion.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.version;

import org.slf4j.Logger;
Expand All @@ -22,8 +10,6 @@
import java.io.InputStream;
import java.util.Properties;

/**
*/
public final class TerasologyVersion {

private static final Logger logger = LoggerFactory.getLogger(TerasologyVersion.class);
Expand All @@ -36,8 +22,7 @@ public final class TerasologyVersion {
private static final String BUILD_ID = "buildId";
private static final String BUILD_TAG = "buildTag";
private static final String BUILD_URL = "buildUrl";
private static final String GIT_BRANCH = "gitBranch";
private static final String GIT_COMMIT = "gitCommit";
private static final String JOB_NAME = "jobName";
private static final String DATE_TIME = "dateTime";
private static final String DISPLAY_VERSION = "displayVersion";
private static final String ENGINE_VERSION = "engineVersion";
Expand All @@ -48,8 +33,7 @@ public final class TerasologyVersion {
private final String buildId;
private final String buildTag;
private final String buildUrl;
private final String gitBranch;
private final String gitCommit;
private final String jobName;
private final String dateTime;
private final String toString;
private final String displayVersion;
Expand All @@ -69,8 +53,7 @@ private TerasologyVersion() {
buildId = properties.getProperty(BUILD_ID, DEFAULT_VALUE);
buildTag = properties.getProperty(BUILD_TAG, DEFAULT_VALUE);
buildUrl = properties.getProperty(BUILD_URL, DEFAULT_VALUE);
gitBranch = properties.getProperty(GIT_BRANCH, DEFAULT_VALUE);
gitCommit = properties.getProperty(GIT_COMMIT, DEFAULT_VALUE);
jobName = properties.getProperty(JOB_NAME, DEFAULT_VALUE);
dateTime = properties.getProperty(DATE_TIME, DEFAULT_VALUE);
displayVersion = properties.getProperty(DISPLAY_VERSION, DEFAULT_VALUE);
engineVersion = properties.getProperty(ENGINE_VERSION, DEFAULT_VALUE);
Expand All @@ -93,13 +76,9 @@ private TerasologyVersion() {
toStringBuilder.append("=");
toStringBuilder.append(buildUrl);
toStringBuilder.append(", ");
toStringBuilder.append(GIT_BRANCH);
toStringBuilder.append("=");
toStringBuilder.append(gitBranch);
toStringBuilder.append(", ");
toStringBuilder.append(GIT_COMMIT);
toStringBuilder.append(JOB_NAME);
toStringBuilder.append("=");
toStringBuilder.append(gitCommit);
toStringBuilder.append(jobName);
toStringBuilder.append(", ");
toStringBuilder.append(DATE_TIME);
toStringBuilder.append("=");
Expand Down Expand Up @@ -139,12 +118,8 @@ public String getBuildUrl() {
return buildUrl;
}

public String getGitBranch() {
return gitBranch;
}

public String getGitCommit() {
return gitCommit;
public String getJobName() {
return jobName;
}

public String getDateTime() {
Expand All @@ -164,23 +139,33 @@ public String getengineVersion() {
* @return prettified version String
*/
public String getHumanVersion() {
// TODO replace with a nicer version later with full version numbering in place
String humanVersion = "";
TerasologyVersion ver = getInstance();

// MOAR CAPS!
// Game-level release name: Alpha-## until we hit Beta - not engine-specific, but defined here for now
if (!ver.getDisplayVersion().trim().equals("")) {
humanVersion = displayVersion.toUpperCase();
}

// Expect tag to start with "jenkins-" and remove that
if (ver.getBuildTag().trim().length() > 8) {
humanVersion += " " + ver.getBuildTag().substring(8);
humanVersion = displayVersion.toUpperCase() + " ";
}

String formattedDate = "";
// Expect a date string but ignore time of day
if (ver.getDateTime().trim().length() > 10) {
humanVersion += " " + ver.getDateTime().substring(0, 10);
formattedDate += ver.getDateTime().substring(0, 10);
}

// Use the job name from Jenkins to determine which flavor we're dealing with (release, dev build, other)
if (jobName.equals("Terasology/engine/master")) {
// This is a release, hopefully stable, but who knows ..
humanVersion += "Release \n(engine v" + engineVersion + ", build " + buildNumber + ", " + formattedDate + ")";
} else if (jobName.equals("Terasology/engine/develop")) {
// This is a dev build, so a snapshot for the given release name
humanVersion += "Preview \n(engine v" + engineVersion + ", dev build " + buildNumber + ", " + formattedDate + ")";
} else if (!jobName.equals("")) {
// This is some other actual build that came from Jenkins
humanVersion += "Special: " + jobName + "\n(engine v" + engineVersion + ", build " + buildNumber + ", " + formattedDate + ")";
} else {
// Likely this didn't come from Jenkins at all
humanVersion += "Custom version - running from source or hand-built";
}

return humanVersion;
Expand Down
1 change: 0 additions & 1 deletion facades/PC/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ tasks.register<Copy>("createVersionFile") {
expand(mapOf(
"buildNumber" to env["BUILD_NUMBER"],
"buildUrl" to env["BUILD_URL"],
"gitBranch" to env["GIT_BRANCH"],
"dateTime" to startDateTimeString,
"displayVersion" to displayVersion
))
Expand Down
1 change: 0 additions & 1 deletion templates/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Terasology - Version
Jenkins:
URL: ${buildUrl}
Build number: ${buildNumber}
GIT branch: ${gitBranch}
Created at: ${dateTime}

http://terasology.org
Expand Down
2 changes: 1 addition & 1 deletion templates/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
alpha
alpha-18

0 comments on commit 6f32a99

Please sign in to comment.