forked from rehlds/rehlds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
55 lines (47 loc) · 1.55 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import versioning.GitVersioner
import versioning.RehldsVersionInfo
import org.joda.time.DateTime
apply plugin: 'maven-publish'
apply from: 'shared.gradle'
group = 'rehlds'
apply plugin: 'idea'
idea {
project {
languageLevel = 'JDK_1_7'
}
}
def gitInfo = GitVersioner.versionForDir(project.rootDir)
RehldsVersionInfo versionInfo
if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') {
def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
if (!m.find()) {
throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}")
}
versionInfo = new RehldsVersionInfo(
majorVersion: m.group(1) as int,
minorVersion: m.group(2) as int,
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
localChanges: gitInfo.localChanges,
commitDate: gitInfo.commitDate,
commitSHA: gitInfo.commitSHA,
commitURL: gitInfo.commitURL
)
} else {
versionInfo = new RehldsVersionInfo(
majorVersion: project.majorVersion as int,
minorVersion: project.minorVersion as int,
maintenanceVersion: project.maintenanceVersion as int,
suffix: 'dev',
localChanges: gitInfo ? gitInfo.localChanges : true,
commitDate: gitInfo ? gitInfo.commitDate : new DateTime(),
commitSHA: gitInfo ? gitInfo.commitSHA : "",
commitURL: gitInfo ? gitInfo.commitURL : "",
commitCount: gitInfo ? (gitInfo.commitCount as int) : null
)
}
project.ext.rehldsVersionInfo = versionInfo
project.version = versionInfo.asMavenVersion()
apply from: 'publish.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}