-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
176 lines (145 loc) · 5.52 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
buildscript {
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
}
}
plugins {
id 'org.springframework.boot'
id 'java'
id "org.owasp.dependencycheck"
id "jacoco"
id 'checkstyle'
id "com.gorylenko.gradle-git-properties" version "2.4.1"
}
//apply from: "dependencyCheck.gradle"
apply plugin: 'io.spring.dependency-management'
group = 'io.element36.cash36'
version = '1.0.0'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
jcenter()
}
ext {
set('springCloudVersion', springCloudVersion)
set('lombokVersion', lombokVersion)
}
springBoot { buildInfo() }
build.doFirst { bootBuildInfo }
compileJava.doFirst { generateGitProperties }
// Disable generate Git Properties via environment - e.g. if we are in a Docker build
ext.generateGitProps=System.getProperty('GENERATE_GIT_PROPERTIES')
ext.generateGitProps=ext.generateGitProps==null?"true":ext.generateGitProps
println "generateGitProps:"+ext.generateGitProps
tasks.withType(com.gorylenko.GenerateGitPropertiesTask).all { enabled = new Boolean(rootProject.ext.generateGitProps) }
configurations {
jaxb // Only for generation purpose
execebics // for the ebics build https://discuss.gradle.org/t/how-to-choose-only-some-dependencies-to-copy-to-a-folder/19629
execebics.transitive = true
}
checkstyle {
toolVersion = '8.44'
project.ext.checkstyleVersion = '8.44'
configFile = file("${projectDir}/google_checks.xml")
showViolations = false
ignoreFailures = false
}
// disable checkstyle on generated source
checkstyleMain.exclude '**/io/element36/cash36/ebics/generated/**'
dependencies {
// java 11 jaxb
implementation 'javax.xml.bind:jaxb-api:'+jaxbVersion
implementation 'javax.activation:activation:1.1.1'
implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.4'
execebics 'io.github.element36-io:ebics-cli:1.5'
implementation 'org.springframework.boot:spring-boot-starter-validation'
testImplementation 'junit:junit'
implementation 'org.springdoc:springdoc-openapi-ui:1.5.8'
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'org.springframework.boot:spring-boot-starter-parent:2.4.0'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'org.apache.commons:commons-exec:1.3'
implementation 'commons-io:commons-io:2.6'
implementation 'org.projectlombok:lombok:'+lombokVersion
annotationProcessor 'org.projectlombok:lombok:'+lombokVersion
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
// prepare structures to execute ebics jar on command line
task copyToLib(type: Copy) {
println "copy ebics libs to $projectDir/lib"
from configurations.execebics
into "$projectDir/lib"
}
task copyEbicsJar(type: Copy) {
println "copy ebics jar to $projectDir"
from ("$projectDir/lib") {
include "ebics-cli-*.jar"
}
into "$projectDir"
}
String stripVersion(String fileNameWithVersion) {
String ext = fileNameWithVersion.substring(fileNameWithVersion.lastIndexOf("."),fileNameWithVersion.length())
int end = fileNameWithVersion.lastIndexOf("-"); //assumes that: name-version.ext. Will not work with name-version-SNAPSHOT.ext
String fileNameWithoutVersion = fileNameWithVersion.substring(0, end) + ext
return fileNameWithoutVersion
}
build.finalizedBy(copyToLib,copyEbicsJar)
// then gradle -Dkey=value works
bootRun {
systemProperties System.properties
}
dependencies {
jaxb 'javax.xml.bind:jaxb-api:'+jaxbVersion
jaxb 'com.sun.xml.bind:jaxb-xjc:'+jaxbVersion
jaxb 'com.sun.xml.bind:jaxb-impl:'+jaxbVersion
jaxb 'com.sun.xml.bind:jaxb-osgi:'+jaxbVersion
}
// See https://www.iso20022.org/catalogue-messages/iso-20022-messages-archive
task generateSourcesForXsd() {
doLast {
File xsdDir=file("${projectDir}/src/main/resources/xsd/")
xsdDir.listFiles().each {
//File file -> println file.name
String fileName=it.name
String packageName=it.name.replaceFirst(~/\.[^\.]+$/, '')
packageName=packageName.replaceAll("\\.","_")
packageName="io.element36.cash36.ebics.generated."+packageName
println "generating sources for:"+fileName+", packageName:"+packageName
def jaxbTargetDir = file("src/main/java")
if (!jaxbTargetDir.exists()) {
jaxbTargetDir.mkdirs()
}
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath)
ant.xjc(
destdir: "${jaxbTargetDir}",
schema: "${projectDir}/src/main/resources/xsd/"+fileName,
removeOldOutput: 'yes', extension: 'true'
)
{
arg(line: '-nv -disableXmlSecurity -p '+packageName)
}
}
}
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: ['io/element36/cash36/ebics/generated/**','io/element36/cash36/ebics/controller/**']) //no http tests and tests for generatd code
}))
}
reports {
xml.required = false
csv.required = true
}
}