11buildscript {
22 ext {
3+ groovyallVersion = ' 3.0.9'
4+ springbootVersion = " 2.6.2"
5+ spockCoreVersion = " 2.0-groovy-3.0"
6+ spockReportsVersion = ' 2.1-groovy-3.0'
7+
38 nexus_url = " ${ project.findProperty('nexus_url') ?: System.getenv('NEXUS_HOST')} "
49 nexus_user = " ${ project.findProperty('nexus_user') ?: System.getenv('NEXUS_USERNAME')} "
510 nexus_pw = " ${ project.findProperty('nexus_pw') ?: System.getenv('NEXUS_PASSWORD')} "
611 no_nexus = (project. findProperty(' no_nexus' ) ?: System . getenv(' NO_NEXUS' ) ?: false ). toBoolean()
712 if (! no_nexus && (nexus_url == " null" || nexus_user == " null" || nexus_pw == " null" )) {
813 throw new GradleException (" property no_nexus='false' (or not defined) but at least one of the properties nexus_url, nexus_user or nexus_pw is not configured. Please configure those properties!" )
914 }
10-
11- def folderRel = (String )(" ${ project.findProperty('nexus_folder_releases') ?: System.getenv('NEXUS_FOLDER_RELEASES')} " )
12- nexusFolderReleases = folderRel == " null" ? " maven-releases" : folderRel
13-
14- def folderSnaps = (String )(" ${ project.findProperty('nexus_folder_snapshots') ?: System.getenv('NEXUS_FOLDER_SNAPSHOTS')} " )
15- nexusFolderSnapshots = folderSnaps == " null" ? " maven-snapshots" : folderSnaps
16-
17- snippetsDir = file(' build/generated-snippets' )
1815 }
1916
2017 repositories {
@@ -51,32 +48,21 @@ buildscript {
5148 }
5249}
5350
54- buildscript {
55- ext {
56- joobyVersion = " 1.6.6"
57- }
58-
59- dependencies {
60- classpath " org.jooby:jooby-gradle-plugin:$joobyVersion "
61- }
62- }
63-
6451plugins {
65- id " com.github.johnrengelman.shadow"
66- id " com.google.osdetector" version " 1.6.2"
67- id " io.spring.dependency-management" version " 1.0.8.RELEASE"
52+ id " groovy"
53+ id ' com.adarshr.test-logger' version ' 3.1.0'
54+ id ' jacoco'
55+ id ' org.springframework.boot' version " ${ springbootVersion} "
56+ id ' com.bmuschko.docker-spring-boot-application' version ' 7.1.0'
57+ id " io.gatling.gradle" version " 3.7.3"
6858}
69-
70- apply plugin : " application"
71- apply plugin : " com.github.johnrengelman.shadow"
72- apply plugin : " groovy"
73- apply plugin : " jooby"
74- apply plugin : " jacoco"
59+ // related to gatling and Springboot
60+ ext[' netty.version' ] = ' 4.0.51.Final'
7561
7662repositories {
63+ mavenCentral()
7764 if (no_nexus) {
7865 println (" using repositories 'jcenter' and 'mavenCentral', because property no_nexus=$no_nexus " )
79- jcenter()
8066 mavenCentral()
8167 } else {
8268 println (" using nexus repositories" )
@@ -107,74 +93,143 @@ repositories {
10793}
10894
10995group = ' org.ods'
110- version = ' 0.1'
111- mainClassName = " app.App"
112- sourceCompatibility = 1.8
96+ version = ' 1.0'
11397
114- dependencyManagement {
115- imports {
116- mavenBom " org.jooby:jooby-bom: $j oobyVersion "
98+ java {
99+ toolchain {
100+ languageVersion . set( JavaLanguageVersion . of( 11 ))
117101 }
118102}
119103
104+ compileGroovy {
105+ groovyOptions. javaAnnotationProcessing = true
106+ }
107+
120108dependencies {
121- implementation " com.github.ben-manes.caffeine:caffeine:2.7.0"
122- implementation " com.github.jknack:handlebars:4.1.2"
123- implementation " commons-io:commons-io:2.11.0"
124- implementation " io.github.openfeign:feign-core:10.2.3"
125- implementation " io.github.openfeign:feign-gson:10.2.3"
126- implementation " io.github.openfeign:feign-okhttp:10.2.3"
127- implementation " net.lingala.zip4j:zip4j:1.3.3"
128- implementation " org.apache.httpcomponents:httpclient:4.5.8"
129- implementation " org.codehaus.groovy:groovy-all:2.5.7"
130- implementation " org.jooby:jooby-jackson"
131- implementation " org.jooby:jooby-netty"
132-
133- implementation " io.netty:netty-transport-native-epoll:${ dependencyManagement.importedProperties['netty.version']} :${ osdetector.classifier.contains('linux') ? 'linux-x86_64' : ''} "
134- implementation " io.netty:netty-tcnative-boringssl-static:${ dependencyManagement.importedProperties['boringssl.version']} "
109+ implementation (group : ' org.codehaus.groovy' , name : ' groovy-all' , version : groovyallVersion){
110+ exclude group : " org.codehaus.groovy" , module : " groovy-test-junit5"
111+ }
135112
113+ implementation " org.springframework.boot:spring-boot-starter:${ springbootVersion} "
114+ implementation " org.springframework.boot:spring-boot-starter-web:${ springbootVersion} "
115+ implementation " org.springframework.boot:spring-boot-starter-cache:${ springbootVersion} "
116+
117+ implementation(" javax.inject:javax.inject:1" )
118+ implementation(" javax.cache:cache-api:1.1.1" )
119+
120+ implementation ' com.fasterxml.jackson.core:jackson-databind'
121+ implementation ' com.github.ben-manes.caffeine:caffeine:3.0.5'
122+ implementation ' com.github.jknack:handlebars:4.3.0'
123+ implementation ' commons-io:commons-io:2.11.0'
124+ implementation ' io.github.openfeign:feign-core:11.8'
125+ implementation ' io.github.openfeign:feign-gson:11.8'
126+ implementation ' io.github.openfeign:feign-okhttp:11.8'
127+ implementation ' net.lingala.zip4j:zip4j:2.9.1'
128+ implementation ' org.apache.httpcomponents:httpclient:4.5.13'
136129 implementation " org.apache.pdfbox:pdfbox:2.0.24"
137130
138- testImplementation " junit:junit:4.12 "
139- testImplementation " com.github.stefanbirkner:system-rules:1.19.0 " // for managing environment variables
140- testImplementation " com.github.tomakehurst:wiremock:2.23.2 " // for mocking HTTP server reponses
141- testImplementation " io.rest-assured:rest-assured:4.0.0 " // for validating REST services
142- testImplementation " org.spockframework:spock-core :1.3-groovy-2.5 "
131+ testImplementation " org. junit.jupiter :junit-jupiter-api "
132+ testImplementation " org.junit.jupiter:junit-jupiter-engine "
133+ testImplementation( " uk.org.webcompere:system-stubs-core:1.2.0 " )
134+ testImplementation " org.testcontainers:spock:1.16.2 "
135+ testImplementation( " org.testcontainers:testcontainers :1.16.2 " )
143136
144- testImplementation " cglib:cglib-nodep:3.3.0" // for mocking classes
145- testImplementation " org.objenesis:objenesis:3.1"
146- }
137+ testImplementation(" org.spockframework:spock-core:${ spockCoreVersion} " )
138+ testImplementation (" com.athaydes:spock-reports:$spockReportsVersion " ){ transitive = false }
139+ testImplementation " org.spockframework:spock-spring:${ spockCoreVersion} "
140+ testImplementation " org.springframework.boot:spring-boot-starter-test:${ springbootVersion} "
147141
148- import com.github.jengelman.gradle.plugins.shadow.transformers.NewGroovyExtensionModuleTransformer
142+ testImplementation " com.github.stefanbirkner:system-rules:1.19.0"
143+ testImplementation ' com.github.tomakehurst:wiremock:2.27.2'
144+ testImplementation ' io.rest-assured:rest-assured:4.4.0'
149145
150- shadowJar {
151- mergeServiceFiles()
152- mergeGroovyExtensionModules()
153- transform(NewGroovyExtensionModuleTransformer )
146+ gatlingImplementation ' org.awaitility:awaitility:4.1.1'
147+ gatlingImplementation ' io.rest-assured:rest-assured:4.4.0'
154148}
155149
156150test {
157- outputs. dir snippetsDir
158-
159- // Use overrides in conf/application.test.conf in ConfigFactory.load()
160- // TODO: setting application.env should be enough, but apparently isn't
161- systemProperty " application.env" , " test"
162- systemProperty " config.resource" , " application.test.conf"
163-
164151 testLogging {
165152 showStandardStreams = true
153+ exceptionFormat = ' full'
166154 }
155+ filter {
156+ includeTestsMatching " *Spec"
157+ }
158+ systemProperty ' com.athaydes.spockframework.report.outputDir' , ' build/reports/spock'
159+ maxHeapSize = " 2048m"
160+ jvmArgs " -XX:MaxPermSize=256m"
161+ useJUnitPlatform()
167162
168163 finalizedBy jacocoTestReport
169164}
170165
166+ task dockerTest (type : Test ) {
167+ dependsOn(test)
168+ group(" verification" )
169+ filter {
170+ includeTestsMatching " *IT"
171+ }
172+ systemProperty ' com.athaydes.spockframework.report.outputDir' , ' build/reports/spock'
173+ useJUnitPlatform()
174+ }
175+
171176jacocoTestReport {
177+ dependsOn test
172178 reports {
173179 xml. enabled true
180+ html. enabled true
181+ }
182+ }
183+
184+ jacocoTestCoverageVerification {
185+ dependsOn jacocoTestReport
186+ violationRules {
187+ rule {
188+ limit {
189+ minimum = 0.7
190+ }
191+ }
174192 }
175193}
176194
177- /* * We diverge from the default resources structure to adopt the Jooby standard: */
178- sourceSets. main. resources {
179- srcDirs = [" conf" , " public" ]
195+ import com.bmuschko.gradle.docker.tasks.image.*
196+ task buildImage (type : DockerBuildImage ) {
197+ inputDir = file(" src/main/resources" )
198+ images. add(' docgen-base:latest' )
199+ }
200+
201+ docker {
202+ springBootApplication {
203+ baseImage = ' docgen-base:latest'
204+ ports = [9090 , 8080 ]
205+ images = [' ods-document-generation-svc:local' ]
206+ jvmArgs = [" -XX:+UseCompressedOops" , " -XX:+UseG1GC" , " -XX:MaxGCPauseMillis=100" ]
207+ }
180208}
209+ buildImage. dependsOn(bootJar)
210+ dockerBuildImage. dependsOn(buildImage)
211+ dockerTest. dependsOn(dockerBuildImage)
212+
213+ import com.bmuschko.gradle.docker.tasks.container.*
214+
215+ task createDocGenServer (type : DockerCreateContainer ) {
216+ dependsOn dockerBuildImage
217+ targetImageId dockerBuildImage. getImageId()
218+ hostConfig. portBindings = [' 8080:8080' ]
219+ hostConfig. autoRemove = true
220+ }
221+
222+ task startDocGenServer (type : DockerStartContainer ) {
223+ dependsOn createDocGenServer
224+ targetContainerId createDocGenServer. getContainerId()
225+ }
226+
227+ task stopDocGenServer (type : DockerStopContainer ) {
228+ targetContainerId createDocGenServer. getContainerId()
229+ }
230+
231+ gatlingRun. group(" verification" )
232+ gatlingRun. dependsOn(dockerTest, startDocGenServer)
233+ gatlingRun. finalizedBy(stopDocGenServer)
234+
235+ check. dependsOn(jacocoTestCoverageVerification, gatlingRun)
0 commit comments