forked from arejula27/lab2-rpc-over-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
206 lines (186 loc) · 6.6 KB
/
build.gradle.kts
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
import de.undercouch.gradle.tasks.download.Download
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
id("org.springframework.boot") version "2.5.5" apply false
id("io.spring.dependency-management") version "1.0.11.RELEASE" apply false
kotlin("jvm") version "1.5.31" apply false
kotlin("plugin.spring") version "1.5.31" apply false
id("de.undercouch.download") version "4.1.2"
java
}
group = "es.unizar"
version = "0.0.1-SNAPSHOT"
val jaxbVersion by extra { "2.1.7" }
subprojects {
apply(plugin = "java")
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
repositories {
mavenCentral()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
dependencies {
"implementation"("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}
tasks.withType<BootJar> {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
project(":server") {
val generatedJavaDirs = "$buildDir/generated-sources/xjc"
val generatedClassesDirs = "$buildDir/classes/xjc"
val schema = "$projectDir/src/main/resources/ws/translator.xsd"
val jaxb by configurations.creating
dependencies {
"implementation"("org.springframework.boot:spring-boot-starter-web")
"implementation"("org.springframework.boot:spring-boot-starter-web-services")
"implementation"("wsdl4j:wsdl4j")
"runtimeOnly"("org.glassfish.jaxb:jaxb-runtime")
jaxb("com.sun.xml.bind:jaxb-xjc:2.1.7")
"implementation"(files(layout.buildDirectory.dir("classes/xjc")) {
builtBy("genJaxb")
})
}
task("genJaxb") {
val sourcedestdir = file(generatedJavaDirs)
val classesdestdir = file(generatedClassesDirs)
doLast {
sourcedestdir.mkdirs()
classesdestdir.mkdirs()
ant.withGroovyBuilder {
"taskdef"(
"name" to "xjc",
"classname" to "com.sun.tools.xjc.XJCTask",
"classpath" to jaxb.asPath
)
"xjc"(
"destdir" to sourcedestdir,
"schema" to schema,
"package" to "client.translator"
)
"javac"(
"destdir" to generatedClassesDirs,
"source" to 1.8,
"target" to 1.8,
"debug" to true,
"debugLevel" to "lines,vars,source",
"classpath" to jaxb.asPath
) {
"src"("path" to sourcedestdir)
"include"("name" to "**/*.java")
"include"("name" to "*.java")
}
}
}
}
tasks.withType<KotlinCompile> {
dependsOn("genJaxb")
}
java {
sourceSets {
getByName("main").java.srcDirs(generatedJavaDirs)
}
}
}
project(":client") {
val generatedJavaDirs = "$buildDir/generated-sources/xjc"
val generatedClassesDirs = "$buildDir/classes/xjc"
val generatedResourceDirs = "$buildDir/generated-sources/resources"
val metaInfDir = "$generatedResourceDirs/META-INF"
val wsdlDir = "$metaInfDir/wsdl"
val catalogFile = "$metaInfDir/jax-ws-catalog.xml"
val translatorWsdlFile = "$wsdlDir/translator.wsdl"
val translatorResourceWsdl = "wsdl/translator.wsdl"
val serverWsdlLocation = "http://localhost:8080/ws/translator.wsdl"
val jaxb by configurations.creating
dependencies {
"implementation"("org.springframework.boot:spring-boot-starter-web-services") {
exclude("org.springframework.boot", "spring-boot-starter-tomcat")
}
"implementation"("org.springframework.ws:spring-ws-core")
"implementation"("org.glassfish.jaxb:jaxb-runtime")
jaxb("com.sun.xml.bind:jaxb-xjc:2.1.7")
"implementation"(files(layout.buildDirectory.dir("classes/xjc")) {
builtBy("genJaxb")
})
}
/**
* It is common that the remote wsdl location is hardcoded into the code.
* As the wsdl location may be not available, we use the JAXWS catalog to map
* this remote resource to a local copy.
*/
task("create-catalog") {
val file = file(catalogFile)
file.parentFile.mkdirs()
file.writeText(
"""
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="$serverWsdlLocation" uri="$translatorResourceWsdl"/>
</catalog>
""".trimIndent()
)
}
task<Download>("download-wsdl") {
val file = file(translatorWsdlFile)
file.parentFile.mkdirs()
src(serverWsdlLocation)
dest(file)
overwrite(true)
}
task("genJaxb") {
dependsOn("download-wsdl", "create-catalog")
group = BasePlugin.BUILD_GROUP
val sourcedestdir = file(generatedJavaDirs)
val classesdestdir = file(generatedClassesDirs)
doLast {
sourcedestdir.mkdirs()
classesdestdir.mkdirs()
ant.withGroovyBuilder {
"taskdef"(
"name" to "xjc",
"classname" to "com.sun.tools.xjc.XJCTask",
"classpath" to jaxb.asPath
)
"xjc"(
"destdir" to sourcedestdir,
"schema" to serverWsdlLocation,
"package" to "client.translator"
) {
"arg"("value" to "-wsdl")
}
"javac"(
"destdir" to generatedClassesDirs,
"source" to 1.8,
"target" to 1.8,
"debug" to true,
"debugLevel" to "lines,vars,source",
"classpath" to jaxb.asPath
) {
"src"("path" to sourcedestdir)
"include"("name" to "**/*.java")
"include"("name" to "*.java")
}
}
}
}
tasks.withType<KotlinCompile> {
dependsOn("genJaxb")
}
java {
sourceSets {
getByName("main").java.srcDirs(generatedJavaDirs)
getByName("main").resources.srcDirs(generatedResourceDirs)
}
}
}