-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
128 lines (106 loc) · 3.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.21.RELEASE")
}
}
plugins {
id 'java-library'
id 'org.springframework.boot' version '1.5.21.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'org.hidetake.ssh' version "1.1.3"
id 'application'
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
group 'uk.ac.ebi.subs'
version '2.10.2-SNAPSHOT'
mainClassName = "uk.ac.ebi.subs.ena.EnaAgentApplication"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
ext.gradle_env = hasProperty('env') ? env : 'dev'
springBoot {
executable = true
buildInfo()
}
dependencies {
compile ("uk.ac.ebi.subs:subs-ena-core-service:2.10.2-SNAPSHOT")
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework.boot:spring-boot-starter-amqp")
compile 'de.codecentric:spring-boot-admin-starter-client:1.5.7'
compile("de.siegmar:logback-gelf:1.1.0")
testCompile("org.springframework.boot:spring-boot-starter-test"){
exclude group: "com.vaadin.external.google", module:"android-json"
}
}
processTestResources {
filesMatching('application.yml') {
expand(project.properties)
}
}
ssh.settings {
user = 'sub_adm'
}
if (project.hasProperty('sshKeyFile')) {
ssh.settings.identity = new File(sshKeyFile)
}
if (project.hasProperty('sshPassphrase')) {
ssh.settings.passphrase = sshPassphrase
}
task printJarName {
doLast {
println "$jar.archivePath.name"
}
}
task printJarFullPath {
doLast {
println "$jar.archivePath.absolutePath"
}
}
def devDeployHostName = hasProperty(project.name + "DevDeployTarget") ? getProperty(project.name + "DevDeployTarget") : 'localhost'
def testDeployHostName = hasProperty(project.name + "TestDeployTarget") ? getProperty(project.name + "TestDeployTarget") : 'localhost'
def prodDeployHostName = hasProperty(project.name + "ProdDeployTarget") ? getProperty(project.name + "ProdDeployTarget") : 'localhost'
remotes {
submission_dev {
role('dev')
host = devDeployHostName
}
submission_test {
role('test')
host = testDeployHostName
}
submission_prod {
role('prod')
host = prodDeployHostName
}
}
task deployJar(type: SshTask, dependsOn: 'assemble') {
doLast {
def uploadJarFileName = project.name + "-" + project.version + "." + System.currentTimeMillis() + ".jar"
sshRun("/data/$gradle_env/$project.name/jar", uploadJarFileName)
}
ssh.settings {
knownHosts = allowAnyHosts
}
}
private Object sshRun(String jarDeployDir, String uploadJarFileName) {
ssh.run {
session(remotes.role(gradle_env)) {
execute "/homes/sub_adm/create_dirs.sh $gradle_env $project.name", ignoreError: false
println "Uploading jar $jar.archivePath.name to $jarDeployDir/$uploadJarFileName area on $remote"
put(jar.archivePath.absolutePath, "$jarDeployDir/$uploadJarFileName")
println "creating symbolic link to $jar.archiveName"
def result = execute "ln -s -f $jarDeployDir/$uploadJarFileName $jarDeployDir/$jar.baseName" + ".jar", ignoreError: true
println result
println "updating permissions of $jarDeployDir/$jar.archiveName"
execute "chmod u+x $jarDeployDir/*", ignoreError: false
}
}
}