Skip to content

Commit 3a92b4e

Browse files
committed
Updated version number handling
1 parent 4497f4c commit 3a92b4e

File tree

2 files changed

+15
-39
lines changed

2 files changed

+15
-39
lines changed

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ cache:
1313

1414
stages:
1515
- name: build
16+
- name: snapshotBranch
17+
if: tag IS blank AND branch =~ /^(\d+.)+\d+-SNAPSHOT$/
18+
- name: releaseTag
19+
if: tag IS present
1620

1721
jobs:
1822
include:
1923
- stage: build
20-
script: /bin/sh ./gradlew build bintrayUpload -Dbintray.user=$BINTRAY_USER -Dbintray.key=$BINTRAY_KEY -Dbuild.number=$TRAVIS_BUILD_NUMBER
24+
script: /bin/sh ./gradlew build
25+
- stage: snapshotBranch
26+
script: /bin/sh ./gradlew "-PoverrideVersion=$TRAVIS_BRANCH" build publish bintrayUpload -x test -Dbuild.number=$TRAVIS_BUILD_NUMBER
27+
- stage: releaseTag
28+
script: /bin/sh ./gradlew "-PoverrideVersion=$TRAVIS_TAG" build publish bintrayUpload -x test -Dbuild.number=$TRAVIS_BUILD_NUMBER
29+

build.gradle

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,24 @@
11
plugins {
22
id "io.freefair.lombok" version "4.1.2"
33
id "com.jfrog.bintray" version "1.8.4"
4-
id 'com.intershop.gradle.scmversion' version '6.0.0'
4+
id 'org.ajoberstar.grgit' version "4.0.0"
55
}
66

7+
apply from: "https://raw.githubusercontent.com/fortify-ps/gradle-helpers/master/version-helper.gradle"
8+
79
group 'com.fortify.ssc.parser.owasp.dependencycheck'
810

911
apply plugin: 'java'
1012
sourceCompatibility = 1.8
1113

12-
scm {
13-
version {
14-
type = 'threeDigits'
15-
initialVersion = '1.0.0'
16-
increment = 'MINOR'
17-
}
18-
}
19-
2014
ext {
2115
versionRegex = '(\\d+)(\\.\\d+)*'
2216
jacksonVersion = "2.8.4"
2317
}
2418

25-
def getDateTime() {
26-
new Date().format('yyyyMMddHHmmssSSS')
27-
}
28-
29-
// Get the SSC plugin version based on current SCM version.
30-
// Due to SSC plugin version length restrictions, we cannot
31-
// use the full date/time as part of the version number for
32-
// snapshot versions. As such, we use the number of hours
33-
// since Epoch.
34-
def getPluginVersion() {
35-
def time = System.currentTimeMillis().intdiv(1000)
36-
def hours = time.intdiv(3600)
37-
return scm.version.version \
38-
.replaceFirst(/^(\d+\.)(\d+).+?(-SNAPSHOT)?$/, '$1$2$3') \
39-
.replaceFirst(/-SNAPSHOT/, ".${hours}")
40-
}
41-
42-
// Get the project version; this is used for both the jar file
43-
// name and the version on Bintray. As Bintray version needs to
44-
// be unique, we can't use getPluginVersion() defined above
45-
// (since uploading multiple versions within a single hour would fail).
46-
def getProjectVersion() {
47-
return scm.version.version \
48-
.replaceFirst(/^(\d+\.)(\d+).+?(-SNAPSHOT)?$/, '$1$2$3-release') \
49-
.replaceFirst(/-SNAPSHOT-release/, "-beta-${getDateTime()}")
50-
}
51-
5219
// Project and plugin version based on SCM information
53-
version = getProjectVersion()
54-
def sscPluginVersion = getPluginVersion()
20+
version = getProjectVersionAsBetaOrRelease()
21+
def sscPluginVersion = getProjectVersionAsPlainVersionNumber()
5522

5623
repositories {
5724
mavenLocal()

0 commit comments

Comments
 (0)