forked from gojuno/swarmer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
58 lines (45 loc) · 1.54 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
56
57
58
apply from: 'dependencies.gradle'
buildscript {
// Gradle will not find vars defined in an external file when referring to them
// in the buildscript block, unless you link it from the buildscript block, too.
apply from: 'dependencies.gradle'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath "org.junit.platform:junit-platform-gradle-plugin:$versions.junitPlatform"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
allprojects {
repositories {
jcenter()
}
apply plugin: 'com.github.ben-manes.versions'
}
def gitTag() {
def tag = 'git tag --list --points-at HEAD'.execute((List) null, rootProject.projectDir).text.trim()
if (tag.split(System.lineSeparator()).length > 1) {
throw new IllegalStateException("gitTag is accessed but commit has multiple tags: $tag")
}
return tag
}
def projectVersion() {
def tag = gitTag()
if (tag.startsWith('v')) {
return tag.substring(1)
} else if (tag.isEmpty()) {
return "development"
}
return tag
}
def validateTagAndVersion() {
if (gitTag().isEmpty()) {
throw new IllegalStateException('Publishing is not allowed because current commit has no tag')
}
if (projectVersion().isEmpty()) {
throw new IllegalStateException('Publishing is not allowed because current projectVersion is empty')
}
}