All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jetbrains.plugin.structure.teamcity.action.TeamCityActionSpecVersionUtils.kt Maven / Gradle / Ivy

Go to download

Library for parsing JetBrains TeamCity actions. Can be used to verify that plugin complies with JetBrains Marketplace requirements.

The newest version!
package com.jetbrains.plugin.structure.teamcity.action

import com.vdurmont.semver4j.Semver

object TeamCityActionSpecVersionUtils {
  const val MAX_MAJOR_VALUE = 10000
  const val VERSION_MINOR_LENGTH = 10000
  const val VERSION_PATCH_LENGTH = 10000

  fun versionAsLong(specVersion: String?): Long? {
    if (specVersion == null) return null

    val semanticVersion = getSemverFromString(specVersion)

    return semanticVersion.run {
      major.toLong() * (VERSION_PATCH_LENGTH * VERSION_MINOR_LENGTH) + minor.toLong() * VERSION_PATCH_LENGTH + patch
    }
  }

  fun getSemverFromString(specVersion: String): Semver {
    return Semver(specVersion, Semver.SemverType.LOOSE)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy