-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
141 lines (123 loc) · 4.81 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
plugins {
id 'org.springframework.boot' version '2.5.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'groovy'
id "com.github.johnrengelman.processes" version "0.5.0"
id "org.springdoc.openapi-gradle-plugin" version "1.3.2"
id "org.openapi.generator" version "5.1.1"
id "de.undercouch.download" version "4.1.1"
id "idea"
id 'jacoco'
}
subprojects {
apply plugin: 'java'
}
apply plugin: "com.github.johnrengelman.processes"
apply plugin: "org.springdoc.openapi-gradle-plugin"
apply plugin: 'org.openapi.generator'
group = 'me.strava.activitymerger'
version = '0.1'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
sourceSets {
sourceSets.main.groovy.srcDirs = ['src/main/groovy']
sourceSets.test.groovy.srcDirs = ['src/test/groovy']
sourceSets.main.java.srcDirs = ['src-api/src/main/java']
sourceSets.test.java.srcDirs = []
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation project(':src-api')
implementation("org.openapitools:openapi-generator-gradle-plugin:5.1.1") {
exclude module: "slf4j-simple"
}
implementation('org.codehaus.groovy.modules.http-builder:http-builder:0.7')
implementation('org.codehaus.groovy:groovy-all:2.4.15')
implementation('org.springdoc:springdoc-openapi-groovy:1.5.2')
implementation('org.springdoc:springdoc-openapi-ui:1.5.2')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.codehaus.groovy:groovy')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.spockframework:spock-core:1.3-groovy-2.4')
testImplementation(group: 'org.spockframework', name: 'spock-spring', version: '1.3-groovy-2.4')
testImplementation(group: 'org.codehaus.groovy', name: 'groovy-json', version: '2.4.15')
}
test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
finalizedBy jacocoTestReport
jacoco {
excludes += ["**/io.swagger/**"]
}
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.enabled = true
}
}
task coverageLimit() {
doLast{
File file = new File("$buildDir/reports/jacoco/test/jacocoTestReport.xml")
file.write(file.text.replace('<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.1//EN" "report.dtd">', ''))
def content = new XmlParser().parse(file)
def limits = content.package.findAll { it.@name.startsWith("me/strava/activitymerger/") }
.collect {[(it.@name), it.counter.find{it.@type == 'LINE'}]}.collect {[(it[0]), Double.valueOf(it[1].@covered)/(Double.valueOf(it[1].@covered) + Double.valueOf(it[1].@missed))]}
def thresh = 0.7
println "#" * 40
println "Code Coverage reults:"
println "-" * 40
limits.each {println it[0] + ": " + it[1]}
def warns = limits.findAll {it[1] < thresh}
if (warns) throw new Exception("Code coverage is too bad ($thresh): $warns")
println "#" * 40
}
}
openApi {
outputDir.set(file("${project.getRootDir()}/docs/api-definition"))
outputFileName.set("api-definition.yaml")
waitTimeInSeconds.set(15)
apiDocsUrl.set("http://localhost:8080/v3/api-docs")
}
openApiGenerate {
generatorName = "asciidoc"
inputSpec = "${project.getRootDir()}/docs/api-definition/api-definition.yaml".toString()
outputDir = "${project.getRootDir()}/docs/api".toString()
configOptions = [
dateLibrary : "java8",
appDescription : "A Groovy App to merge Strava activities.",
appName : project.name,
useIntroduction: "true"
]
}
task downloadStravaApi(type: Download) {
src 'https://developers.strava.com/swagger/swagger.json'
dest "$buildDir/generated/strava-api-definition/api.json"
overwrite true
acceptAnyCertificate true
}
task downloadSwaggerJar(type: Download) {
src 'https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar'
dest "$buildDir/generated/strava-api-definition/swagger.jar"
overwrite true
acceptAnyCertificate true
}
task runSwaggerCodeGen(type: Exec, dependsOn: ['downloadSwaggerJar', 'downloadStravaApi']) {
commandLine "java", "-jar", "$buildDir\\generated\\strava-api-definition\\swagger.jar", "generate", "-l", "java", "-i", "$buildDir\\generated\\strava-api-definition\\api.json", "-o", "${project.getRootDir()}\\src-api"
}
//bootRun.dependsOn(['build'])
build.dependsOn(['openApiGenerate', 'runSwaggerCodeGen'])
tasks.openApiGenerate.dependsOn('generateOpenApiDocs')
//coverageLimit.dependsOn(['jacocoTestReport'])
//check.dependsOn(['coverageLimit'])