-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
161 lines (134 loc) · 4.7 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'http://repo.spring.io/plugins-release' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.21.RELEASE")
classpath 'org.hidetake:gradle-ssh-plugin:1.1.3'
}
}
plugins {
id 'java-library'
id 'com.sourcemuse.mongo' version '1.0.0'
id 'org.hidetake.ssh' version "1.1.3"
id 'org.springframework.boot' version '1.5.21.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'application'
}
group 'uk.ac.ebi.subs'
version '1.7.0-SNAPSHOT'
mainClassName = "uk.ac.ebi.subs.SamplesAgentApplication"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://www.ebi.ac.uk/spot/nexus/repository/maven-releases'}
maven { url 'https://www.ebi.ac.uk/spot/nexus/repository/maven-snapshots'}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
compile("uk.ac.ebi.subs:subs-processing-model:2.15.0-SNAPSHOT")
compile("uk.ac.ebi.subs:subs-messaging:0.6.0-SNAPSHOT")
compile ('uk.ac.ebi.biosamples:biosamples-spring-boot-starter:4.1.16-SNAPSHOT') {
changing = true
exclude group: 'org.springframework.boot'
}
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")
compile("org.springframework.boot:spring-boot-configuration-processor")
testCompile("org.springframework.boot:spring-boot-starter-test") {
exclude group: 'org.hamcrest'
}
testCompile("org.hamcrest:java-hamcrest:2.0.0.0")
}
task('externalCiTest', type: Test) {
useJUnit {
excludeCategories 'uk.ac.ebi.subs.agent.utils.BioSamplesDependentTest'
}
testLogging {
exceptionFormat = 'full'
}
}
compileJava.dependsOn(processResources)
springBoot {
executable = true
buildInfo()
}
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"
}
}
processTestResources {
filesMatching('application.properties') {
expand(project.properties)
}
}
task printClasspath doLast {
configurations.compile.each { println it }
}
ext.gradle_env = hasProperty('env') ? env : 'dev'
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"
File jarDeployDir = new File("/data/$gradle_env/$project.name/jar",uploadJarFileName)
sshRun(jarDeployDir)
}
ssh.settings {
knownHosts = allowAnyHosts
}
}
private Object sshRun(File jarDeployFile) {
def uploadJarFileName = name + "-" + version + "." + System.currentTimeMillis() + ".jar"
File jarDeployDir = jarDeployFile.getParentFile()
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, jarDeployFile.absolutePath)
println "creating symbolic link to $jar.archiveName"
def result = execute "ln -s -f $jarDeployFile.absolutePath $jarDeployDir/$jar.baseName" + ".jar", ignoreError: true
println result
println "updating permissions of $jarDeployDir/$jar.archiveName"
execute "chmod u+x $jarDeployDir/*", ignoreError: false
}
}
}