Skip to content

Commit

Permalink
Add SNAPSHOT to version identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredrummler committed May 4, 2024
1 parent 1bde9c9 commit 871daa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object BuildConfig {
private const val MINOR = 0
private const val PATCH = 1
private const val BUILD_NUMBER = 0
private val IDENTIFIER = build.Version.Identifier.Alpha
private val IDENTIFIER = build.Version.Identifier.SNAPSHOT

private val BUILD_TIME_PATTERN: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHH")

Expand Down
27 changes: 14 additions & 13 deletions buildSrc/src/main/kotlin/build/Version.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/*
* Copyright 2024 GoatBytes.IO
* Copyright (c) 2024 GoatBytes.IO. All rights reserved.
*
* 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
* This file is part of peopledatalabs-kotlin project by GoatBytes.IO and is released under the
* GoatBytes.IO PDL Software License Agreement.
*
* http:https://www.apache.org/licenses/LICENSE-2.0
* For details, see the LICENSE.md file in the root of the project or contact [email protected]
* for a full copy.
*
* 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.
* RESTRICTIONS: This software is provided for internal use only. Unauthorized use, copying,
* modification, or distribution of this software is strictly prohibited. This software is offered
* "AS IS", without warranties of any kind, and subject to the limitations stated in the license
* agreement.
*
*/

Expand All @@ -20,6 +19,7 @@ package build
import build.Version.Identifier.Alpha
import build.Version.Identifier.Beta
import build.Version.Identifier.RC
import build.Version.Identifier.SNAPSHOT

/**
* Represents a base class for different versioning strategies.
Expand All @@ -34,7 +34,7 @@ sealed class Version {

/** Enumerates common pre-release identifiers for software versions. */
enum class Identifier {
Alpha, Beta, RC, Release
Alpha, Beta, RC, Release, SNAPSHOT
}

/**
Expand Down Expand Up @@ -88,17 +88,18 @@ sealed class Version {

private fun preRelease(): String = when (identifier) {
Identifier.Release, null -> ""
SNAPSHOT -> "-SNAPSHOT"
else -> "-${identifier.name.lowercase()}"
}

private fun buildMetadata() = buildString {
when (identifier) {
Alpha, Beta, RC -> metadata?.run {
Alpha, Beta, RC, SNAPSHOT -> metadata?.run {
var separator = "+"
listOf(
buildNumber?.takeIf { it > 0 },
buildTime,
gitBranch?.takeIf { it !in listOf("main", "develop") && !it.contains("/") },
gitBranch?.takeIf { it !in listOf("main") && !it.contains("/") },
gitSha
).mapNotNull { it }.forEach { data ->
append(separator).append(data).also { separator = "." }
Expand Down

0 comments on commit 871daa4

Please sign in to comment.