@@ -22,16 +22,36 @@ ext {
2222 jacksonVersion = " 2.8.4"
2323}
2424
25- def getDate () {
25+ def getDateTime () {
2626 new Date (). format(' yyyyMMddHHmmssSSS' )
2727}
2828
29- // Project version based on SCM information
30- // Reg-ex to generate format <major>.<minor>[.<date>]
31- // With date part only added for snapshot versions
32- version = scm. version. version \
33- .replaceFirst(/ ^(\d +\. )(\d +).+?(-SNAPSHOT)?$/ , ' $1$2$3' ) \
34- .replaceFirst(/ -SNAPSHOT/ , " .00${ getDate()} " )
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/ , " .${ getDateTime()} " )
50+ }
51+
52+ // Project and plugin version based on SCM information
53+ version = getProjectVersion()
54+ def sscPluginVersion = getPluginVersion()
3555
3656repositories {
3757 mavenLocal()
@@ -76,14 +96,14 @@ dependencies {
7696jar {
7797 doFirst {
7898 // check if version matches requirements
79- // if (!version .matches(versionRegex)) {
80- // throw new InvalidUserDataException("Plugin version '$version ' does not match '$versionRegex'")
81- // }
99+ if (! sscPluginVersion . matches(versionRegex)) {
100+ throw new InvalidUserDataException (" Plugin version '$s scPluginVersion ' does not match '$versionRegex '" )
101+ }
82102 }
83103 // replace version placeholders in plugin.xml
84104 filesMatching(' plugin.xml' ) {
85105 filter {
86- it. replaceAll(' <!--VERSION-->.*?<!--/VERSION-->' , version )
106+ it. replaceAll(' <!--VERSION-->.*?<!--/VERSION-->' , sscPluginVersion )
87107 }
88108 }
89109 // include files from compileExport dependencies
0 commit comments