-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
executable file
·57 lines (45 loc) · 1.44 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
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 {
mavenCentral()
}
dependencies {
classpath libraries.kotlinGradle
classpath "org.junit.platform:junit-platform-gradle-plugin:$versions.junitPlatform"
}
}
allprojects {
repositories {
mavenCentral()
jcenter() // Remove when jcommander is transitioned to mavenCentral
}
version = VERSION_NAME
group = GROUP
}
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')
}
}