forked from kbase/auth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
239 lines (207 loc) · 8.01 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'war'
id 'jacoco'
id 'maven-publish'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
group = 'com.github.kbase'
repositories {
mavenCentral()
maven {
name = "Clojars"
url = "https://repo.clojars.org/"
}
maven {
name = "JitPack"
url = 'https://jitpack.io'
}
}
// Warning - these values are hard coded in AuthController.java
def JAR_TEMPLATE_DIR = 'kbase_auth2_templates'
def TEMPLATE_LIST_FILE_NAME = "templates.manifest"
task buildGitCommitFile {
doLast {
def commitId = grgit.head().id
// is there a variable for builddir/classes/java/main?
file("$buildDir/classes/java/main/us/kbase/auth2/gitcommit").text = commitId
}
}
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
finalizedBy buildGitCommitFile
}
test {
/*
* TODO TEST Figure out why tests fail without this and remove. Might have something to do
* with the stfuLoggers() call in many of the tests, might kill logging for tests that
* require it
* Although it seems to make Mongo start up correctly as well which is odd
*/
forkEvery = 1
/*
* TODO TEST split tests into mongo wrapper tests & all other tests (incl. integration).
* Set up GHA to run the non-mongo tests with a single version of mongo and run the
* mongo tests with matrixed mongo versions. Combine coverage at the end somehow
*/
systemProperty "AUTH2_TEST_CONFIG", "./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
}
}
javadoc {
options {
links "https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-sync/"
// 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/"
}
}
war {
webXml = file('war/web.xml')
}
configurations {
// can't directly access testImplementation, so extend and access
testimpl.extendsFrom testImplementation
}
task generateTemplateFileList {
doLast {
File directory = file('templates')
// List files in the directory
def files = fileTree(dir: directory).files.collect { it.name }
File outputFile = file("$buildDir/" + TEMPLATE_LIST_FILE_NAME)
outputFile.text = files.join('\n')
}
}
shadowJar {
// Be careful when updating jars - you may want to set the duplicates strategy to WARN
// to see if any of the jars are shadowing the others when building the fat jar, which
// has been the case in the past
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn generateTemplateFileList
archiveAppendix = 'test-shadow'
from sourceSets.test.output
configurations = [project.configurations.testRuntimeClasspath]
enableRelocation true
relocationPrefix 'us.kbase.auth2.shadow'
mergeServiceFiles()
// Include text files from the "templates" directory
from('templates') { into JAR_TEMPLATE_DIR }
from("$buildDir/" + TEMPLATE_LIST_FILE_NAME) { into JAR_TEMPLATE_DIR }
}
task generateManageAuthScript {
dependsOn compileJava
doLast {
def dependencies = configurations.runtimeClasspath.collect { File file ->
file.absolutePath
}
def classpath = dependencies.join(':')
def scriptContent = """#!/bin/sh
CLASSPATH=$classpath
java -cp build/classes/java/main:\$CLASSPATH us.kbase.auth2.cli.AuthCLI \$@
"""
file("$buildDir/manage_auth").text = scriptContent
file("$buildDir/manage_auth").setExecutable(true)
}
}
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
artifactId = "auth2-test-shadow-all"
}
}
}
dependencies {
/* Notes on exclusions:
* Bizarrely, the glassfish verison of inject has a dependency on v1 inject, which
* causes problems when trying to build the fat jar
* There are other spots in the dependency tree where v1 inject exists as well, and
* collides with the newer version.
* Inject v1 has the exact same directories and classes as the 2.5.0-b05 and so is
* shadowed in any case, so removal is presumably safe since the tests pass.
*/
implementation 'commons-codec:commons-codec:1.8'
implementation 'commons-validator:commons-validator:1.5.1'
implementation 'com.google.guava:guava:18.0'
implementation 'org.ini4j:ini4j:0.5.2'
implementation 'com.beust:jcommander:1.48'
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.github.kbase:java_common:0.3.0') {
exclude group: 'net.java.dev.jna' // breaks shadow jar
exclude group: 'org.eclipse.jetty.aggregate' // ugh, java common pollutes everything
exclude group: 'com.fasterxml.jackson.core' // breaks everything if we upgrade
exclude group: 'javax.servlet', module: 'servlet-api' // 2.5 vs 3.1 below
// I have no idea why, but including the auth client in the build causes the shadow
// jar to fail to start correctly. It shouldn't be a problem, but it is
exclude group: 'com.github.kbase', module: 'auth2_client_java'
}
implementation 'ch.qos.logback:logback-classic:1.1.2'
implementation 'org.slf4j:slf4j-api:1.7.25'
// TODO DEPS Need to rework the java common logger to not use syslog4j at all since it's
// abandonware and has a ton of CVEs, even in the newer versions.
implementation "org.syslog4j:syslog4j:0.9.46"
implementation 'com.github.spullara.mustache.java:compiler:0.9.3'
implementation 'com.nulab-inc:zxcvbn:1.2.2'
implementation 'nl.basjes.parse.useragent:yauaa:1.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.5.4'
implementation 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'
implementation('org.glassfish.jersey.containers:jersey-container-servlet:2.23.2') {
exclude group: 'javax.inject', module: 'javax.inject'
}
implementation('org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2') {
exclude group: 'javax.inject', module: 'javax.inject'
}
implementation('org.glassfish.jersey.ext:jersey-mvc-mustache:2.23.2') {
exclude group: 'javax.inject', module: 'javax.inject'
// The servlet namespace changed between 2.4 and 3.X, and so we need to exclude the
// 2.4 namespace to avoid collisions. 3.X is backwards compatible:
// https://docs.oracle.com/cd/E19798-01/821-1752/beagj/index.html
exclude group: 'javax.servlet', module: 'servlet-api'
}
implementation 'javax.persistence:persistence-api:1.0'
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
testImplementation 'commons-io:commons-io:2.4'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.10'
testImplementation 'junit:junit:4.12'
testImplementation('org.mock-server:mockserver-netty:3.10.4') {
exclude group: 'javax.inject', module: 'javax.inject'
// uses an old version of the activation api in a different namespace, so exclude it
// in favor of the new one which is a transitive dependency elsewhere
exclude group: 'javax.activation', module: 'activation'
}
testImplementation 'org.eclipse.jetty:jetty-server:9.3.11.v20160721'
testImplementation 'org.eclipse.jetty:jetty-servlet:9.3.11.v20160721'
testImplementation 'io.github.java-diff-utils:java-diff-utils:2.2.0'
testImplementation 'de.danielbechler:java-object-diff:0.94'
testImplementation 'org.jsoup:jsoup:1.10.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
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 }
}
}