-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
185 lines (161 loc) · 5.18 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'war'
id 'jacoco'
}
var VER_AUTH2_CLIENT = "0.5.0"
var VER_JAVA_COMMON = "0.3.0"
var DEFAULT_URL = "https://ci.kbase.us/services/user_profile/rpc"
var LOC_UP_SPEC = "$rootDir/UserProfile.spec"
var LOC_DOC_HTML = "$rootDir/docshtml"
repositories {
mavenCentral()
maven {
name = "JitPack"
url = 'https://jitpack.io'
}
maven {
name = "Clojars"
url = "https://repo.clojars.org/"
}
}
compileJava {
// TODO BUILD remove when we no longer support java 8, use `options.release = 11` if needed
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
}
javadoc {
/* We don't actually need the full javadoc for anything, so just hijack this task for
* building the client javadocs. If we ever need the full javadocs make a new task for the
* client java docs
*/
options {
// I don't know why this isn't working, but it's not worth spending time on right now
links "https://docs.oracle.com/javase/8/docs/api/"
links "https://javadoc.jitpack.io/com/github/kbase/auth2_client_java/$VER_AUTH2_CLIENT/javadoc/"
links "https://javadoc.jitpack.io/com/github/kbase/java_common/$VER_JAVA_COMMON/javadoc/"
}
exclude "**/userprofile/MongoController.java"
exclude "**/userprofile/UserProfileServer.java"
}
test {
systemProperty "test.cfg", "./test.cfg"
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
finalizedBy jacocoTestReport
}
// TODO TEST add a test that starts the server in a docker container and checks some simple cmds
jacocoTestReport {
reports {
xml.required = true
csv.required = true
}
}
jar {
// Much like javadoc, we hijack this task to build the client jar, since we don't need
// a service jar
exclude "us/kbase/userprofile/UserProfileServer*.class" // exclude anonymous classes
exclude "us/kbase/userprofile/MongoController*.class" // exclude anonymous classes
archiveAppendix = 'client'
}
war {
webXml = file('war/web.xml')
}
/* SDK compile notes:
* kb-sdk starts a docker container in interactive mode. Gradle's commandLine doesn't allocate
* a tty so the command fails.
* I tried using a ProcessBuilder and
* https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/java/lang/ProcessBuilder.html#inheritIO()
* but that failed also with no useful output.
*
* The current solution is to precede the kb-sdk call with a script call, which either
* allocates a tty or fools kb-sdk into thinking there is one - not quite sure.
* https://man7.org/linux/man-pages/man1/script.1.html
* I tried to redirect the script log file to /dev/null with -O and --log-out but script didn't
* recognize either option, hence the delete.
*
* This is, generally speaking, a janky mess and if someone can find a better way to do this
* that'd be fantastic.
*/
var LOC_SCRIPT_TYPESCRIPT = "$rootDir/typescript"
// TODO GRADLE is there some way to DRY these 3 compile tasks up? Not a huge deal
task sdkCompileHTML {
// We want to check in the HTML so we don't put it in the build dir
var cmd = "kb-sdk compile --html --out $LOC_DOC_HTML $LOC_UP_SPEC"
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
}
}
task sdkCompileLibs {
var cmd = "kb-sdk compile " +
"--out lib " +
"--jsclname javascript/UserProfile/Client " +
"--plclname Bio::KBase::UserProfile::Client " +
"--pyclname biokbase.user_profile.client " +
"--url $DEFAULT_URL " +
LOC_UP_SPEC
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
delete "$rootDir/lib/biokbase/user_profile/authclient.py"
}
}
task sdkCompileJava {
// TODO GRADLE is there a variable for src/main/java?
var cmd = "kb-sdk compile " +
"--java " +
"--javasrc $rootDir/src/main/java/ " +
"--javasrv " +
"--out . " +
"--url $DEFAULT_URL " +
LOC_UP_SPEC
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
}
}
task sdkCompile {
dependsOn sdkCompileHTML
dependsOn sdkCompileJava
dependsOn sdkCompileLibs
}
configurations {
// can't directly access testImplementation, so extend and access
testimpl.extendsFrom testImplementation
}
dependencies {
implementation 'org.ini4j:ini4j:0.5.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.2.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
implementation "com.github.kbase:java_common:$VER_JAVA_COMMON"
implementation "com.github.kbase:auth2_client_java:$VER_AUTH2_CLIENT"
implementation 'javax.annotation:javax.annotation-api:1.2'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'org.mongodb:mongodb-driver-core:4.11.1'
implementation 'org.mongodb:mongodb-driver-sync:4.11.1'
implementation 'org.mongodb:bson-record-codec:4.11.1'
implementation 'org.mongodb:bson:4.11.1'
implementation 'com.google.guava:guava:31.1-jre'
testImplementation 'junit:junit:4.9'
testImplementation 'commons-io:commons-io:2.4'
testImplementation('com.github.kbase:java_test_utilities:0.1.0') {
exclude group: 'com.fasterxml.jackson.core' // upgrading breaks stuff
}
}
task showTestClassPath {
doLast {
configurations.testimpl.each { println it }
}
}