-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·86 lines (74 loc) · 1.99 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.3")
}
}
plugins {
id 'com.palantir.docker' version '0.22.1'
}
group = 'kingstonduo'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'
jar {
baseName = 'cassiopeia-data'
version = '1.5'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
processResources {
filesMatching('application.properties') {
expand(project.properties)
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.mockito:mockito-core")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation 'junit:junit:4.12'
}
springBoot {
mainClass = "org.kpmp.Application"
}
task unpack(type: Copy) {
dependsOn bootJar
from(zipTree(tasks.bootJar.outputs.files.singleFile))
into("build/dependency")
}
def getCurrentGitBranch() {
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
def gitBranch = "Unknown branch"
try {
def workingDir = new File("${project.projectDir}")
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir)
result.waitFor()
if (result.exitValue() == 0) {
gitBranch = result.text.trim()
}
} catch (e) {
}
if (gitBranch == "develop" || gitBranch == "master"){
return jar.version
}else{
return gitBranch
}
}
}
docker {
name "kingstonduo/cassiopeia-data:" + getCurrentGitBranch()
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}