1
- import org.apache.tools.ant.filters.ReplaceTokens
2
-
3
-
4
1
apply plugin : ' java'
5
2
apply plugin : ' signing'
6
3
apply plugin : ' maven-publish'
7
4
apply plugin : ' io.codearte.nexus-staging'
8
-
9
-
10
-
11
- import org.apache.tools.ant.filters.ReplaceTokens
5
+ apply from : ' ../metadata-integration/java/versioning.gradle'
12
6
13
7
14
8
repositories {
@@ -31,53 +25,6 @@ dependencies {
31
25
testCompile externalDependency. testng
32
26
}
33
27
34
- def detailedVersionString = " 0.0.0-unknown-SNAPSHOT"
35
- def snapshotVersion = false
36
- if (project. hasProperty(" releaseVersion" )) {
37
- version = releaseVersion
38
- detailedVersionString = releaseVersion
39
- } else {
40
- try {
41
- // apply this plugin in a try-catch block so that we can handle cases without .git directory
42
- apply plugin : " com.palantir.git-version"
43
- def details = versionDetails()
44
- detailedVersionString = gitVersion()
45
- version = details. lastTag
46
- version = version. startsWith(" v" )? version. substring(1 ): version
47
- def suffix = details. isCleanTag? " " : " -SNAPSHOT"
48
- snapshotVersion = ! details. isCleanTag
49
- }
50
- catch (Exception e) {
51
- e. printStackTrace()
52
- // last fall back
53
- version = detailedVersionString
54
- }
55
- }
56
- // trim version if it is of size 4 to size 3
57
- def versionParts = version. tokenize(" ." )
58
- if (versionParts. size() > 3 ) {
59
- // at-least 4 part version
60
- // we check if the 4th part is a .0 in which case we want to create a release
61
- if (versionParts[3 ] != ' 0' ) {
62
- snapshotVersion = true
63
- }
64
- versionParts = versionParts[0 .. 2 ]
65
- version = versionParts[0 .. 2 ]. join(' .' )
66
- }
67
-
68
- if (snapshotVersion) {
69
- if (versionParts[versionParts. size()-1 ]. isInteger()) {
70
- version = versionParts[0 .. versionParts. size()-2 ]. join(' .' ) + ' .' + (versionParts[versionParts. size()-1 ]. toInteger()+1 ). toString() + " -SNAPSHOT"
71
- } else {
72
- // we are unable to part the last token as an integer, so we just append SNAPSHOT to this version
73
- version = versionParts[0 .. versionParts. size()-1 ]. join(' .' ) + ' -SNAPSHOT'
74
- }
75
- }
76
-
77
- processResources {
78
- filter(ReplaceTokens , tokens :[fullVersion : detailedVersionString])
79
- }
80
-
81
28
82
29
publishing {
83
30
publications {
0 commit comments