-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
371 lines (281 loc) · 11.6 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
plugins {
id 'groovy'
id 'java'
id 'java-library'
id 'java-gradle-plugin'
id 'maven-publish'
alias libs.plugins.git.version
alias libs.plugins.versions
// id 'com.vaadin'
// id 'io.spring.dependency-management' version '1.1.0'
}
wrapper {
gradleVersion = '8.7'
}
group = 'com.adva'
version = { com.palantir.gradle.gitversion.VersionDetails details ->
if (details.branchName && !(details.branchName as String).blank && details.branchName != 'master') {
return "${details.branchName.replaceAll '/', '-'}-g${details.gitHash}"
}
final matcher = details.lastTag =~ /^v?(?<major>\d+)\.(?<minor>\d+)(\.(?<micro>\d+))?$/
if (!matcher) { // ==> tag does not represent a version number ...
return "${details.lastTag}-g${details.gitHash}"
}
final majorNumber = (matcher.group 'major') as Integer
final minorNumber = (matcher.group 'minor') as Integer
final microNumber = (matcher.group 'micro') as Integer
final version
final publishingProperty /// used for configuring deployment -- see: com.adtran.topline.java-conventions.gradle & CI config
if (details.commitDistance > 0) {
/// ==> not on tagged commit ...
/// suffixes after -SHAPSHOT don't work with https://muc-artifactory.rd.advaoptical.com/artifactory/at-snapshot-local
version = "${majorNumber}.${minorNumber}.${microNumber + 1}-SNAPSHOT" // -${details.commitDistance}"
publishingProperty = 'snapshot'
} else {
version = "${majorNumber}.${minorNumber}.${microNumber}"
publishingProperty = 'release'
}
project.ext[publishingProperty] = version
return version
}(project.versionDetails()) /// Provided by com.palantir.git-version plugin
projectDir.toPath() resolve 'testemu' resolve 'gradle.properties' toFile() setText """
# Please do not commit this file. It is auto-(re)generated by every ../build.gradle execution
netEmuVersion = ${project.version}
"""
java { /** Updated to use JavaPluginExtension instead of Gradle 8+ deprecated JavaPluginConvention - according to:
https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#java_convention_deprecation
*/
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
final operatingSystem = DefaultNativePlatform.currentOperatingSystem
/*
ext.jepDir = [
"python", "-c", "print(__import__('os').path.dirname(__import__('importlib.util').util.find_spec('jep').origin))"
].execute().text.trim()
*/
repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://vaadin.com/nexus/content/repositories/vaadin-addons'
}
// maven("https://repo.spring.io/plugins-release")
// jcenter()
/*
flatDir {
dirs "opendaylight-mdsal/binding/yang-binding/target"
}
*/
/*
flatDir {
dirs "opendaylight-netconf/netconf/tools/netconf-testtool/target"
}
*/
/*
flatDir {
dirs jepDir
}
*/
}
/*
dependencyManagement {
imports {
mavenBom "com.vaadin:vaadin-bom:${project.vaadinVersion}"
}
}
*/
configurations.all { /// Exclude transitive dependencies not available anymore and/or superceded by other modules ...
exclude group: 'com.bea.xml', module: 'jsr173-ri' /// Superceded by javax.xml:jsr173
}
dependencies {
implementation gradleApi()
implementation localGroovy()
// implementation 'org.apache.groovy:groovy:4.0.17'
api libs.vaadin
implementation libs.maven
implementation libs.classgraph
// implementation 'org.reflections:reflections:0.10.2'
implementation libs.activation
implementation libs.jaxb.api
/** Can't use jaxb-runtime 3.x versions before finding a compatible jaxb-api. In combination w/the above, 3.x leads to:
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
*/
implementation libs.jaxb.runtime
/** Can't use jersey 3.x versions because of incompatibility w/org.opendaylight.netconf:restconf-nb-rfc8040 due to
conflicting javax.ws.rs dependencies.
*/
implementation libs.jersey.grizzly2
implementation libs.jersey.hk2
// implementation "org.glassfish.jersey.Model:jersey-Model-sse:3.0.0"
implementation libs.handlebars
implementation libs.auto.service
implementation libs.dagger.api
implementation libs.poet
implementation libs.assisted.inject.annotations
annotationProcessor libs.auto.service
annotationProcessor libs.dagger.compiler
annotationProcessor libs.assisted.inject.processor
annotationProcessor libs.lombok
compileOnly libs.lombok
annotationProcessor libs.metainf.services
compileOnly libs.metainf.services
api libs.jsr173
// api "com.bea.xml:jsr173-ri:1.0"
// api "com.ea.async:ea-async:1.2.3"
api libs.future.converter
api libs.typetools
api libs.streamex
// To avoid java.lang.NoClassDefFoundError: org/glassfish/jersey/server/model/Parameter$Source
// when using com.adva.netemu.northbound.RestconfService in derived projects
// api "org.glassfish.jersey.core:jersey-common:2.32"
// api 'io.jooby:jooby-netty:2.16.1'
// annotationProcessor 'io.jooby:jooby-apt:2.16.1'
/// Needed by auto-generated MD-SAL Java code from YANG modules
api libs.findbugs
api libs.eclipse.annotation
/** Add all transitive dependencies of customized OpenDaylight modules, so their _#-ADVA releases can be bundled with NETEMU
-- except when Gradle task :dependencies in executed, since its used to determine those transitive dependencies ...
(The check for executed task was adapted from https://discuss.gradle.org/t/how-to-get-current-tasks-info/24997/2)
*/
if ('dependencies' !in project.gradle.startParameter.taskNames) {
/** Dependencies file should be re-created on every dependencies update, by runnging:
groovy opendaylight-dependencies.groovy > openconfig-dependencies.txt
*/
for (final dependency in (file 'opendaylight-dependencies.txt' readLines() collect { it.trim() } findAll { it })) {
if (dependency =~ /org\.opendaylight\.(yangtools|mdsal|netconf):/) { compileOnly "${dependency}_1-ADVA" }
else { api dependency }
}
}
/** And now define the customized OpenDaylight modules as mere compile dependencies, so during compilation & runtime of
NETEMU-dependent projects, those modules are not searched for in Maven repositories, but their contents (classes, etc.)
are simply accessed through NETEMU's own JAR (see :jar task configuration for details on bundling) ...
*/
/// opendaylight-yangtools ...
// compileOnly libs.rfc7952.data.util
compileOnly libs.yang.data.api
compileOnly libs.yang.data.codec.gson
compileOnly libs.yang.data.codec.xml
compileOnly libs.yang.data.impl
compileOnly libs.yang.data.util
compileOnly libs.yang.maven.plugin
compileOnly libs.yang.repo.fs
compileOnly libs.yang.parser.impl
/// opendaylight-mdsal ...
compileOnly libs.binding.dom.adapter
compileOnly libs.binding.dom.codec
compileOnly libs.binding.java.api.generator
compileOnly libs.dom.inmemory.datastore
compileOnly libs.yang.binding
/// opendaylight-netconf ...
compileOnly libs.client
compileOnly libs.netty.util
compileOnly libs.testtool
compileOnly libs.restconf.nb
// api "black.ninia:jep:3.9.0"
testImplementation libs.spock // 'org.spockframework:spock-core:2.4-M1-groovy-3.0'
}
jar { /// Bundle NETEMU's JAR with customized OpenDaylight modules -- technique adapted from https://stackoverflow.com/a/66910803
from {
configurations.compileClasspath.findAll { it.name.endsWith '-ADVA.jar' } collect { zipTree it }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven { /** URL selection strategy adapted from
https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:snapshot_and_release_repositories
*/
if (project.hasProperty 'release') {
url = project.findProperty 'artifactoryReleaseUrl'
}
if (project.hasProperty 'snapshot') {
url = project.findProperty 'artifactorySnapshotUrl'
}
if (project.hasProperty 'artifactoryToken') {
credentials {
username = project.findProperty 'artifactoryUser'
password = project.findProperty 'artifactoryToken'
}
}
}
}
}
compileJava {
options.fork = true
for (final javacPackage in ['code', 'util']) {
/** Adapted from https://github.com/projectlombok/lombok/issues/2681#issuecomment-805252645
*/
options.forkOptions.jvmArgs += ['--add-opens', "jdk.compiler/com.sun.tools.javac.${javacPackage}=ALL-UNNAMED"
as String] /// GString not supported as JVM fork argument
options.compilerArgs += ['--add-exports', "jdk.compiler/com.sun.tools.javac.${javacPackage}=ALL-UNNAMED"]
}
}
test {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
}
}
tasks.register 'mvnInstallYangtools', Exec, {
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + [
'groovy', 'mvn-yangtools.groovy', '--batch-mode', '--projects=-karaf', 'install', '-DskipTests',
'-Dmaven.javadoc.skip=true', '-Dcheckstyle.skip=true', '-Dspotbugs.skip=true']
}
tasks.register 'mvnInstallMdsal', Exec, {
dependsOn mvnInstallYangtools
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + [
'groovy', 'mvn-mdsal.groovy', '--batch-mode', 'install', '-DskipTests',
'-Dmaven.javadoc.skip=true', '-Dcheckstyle.skip=true', '-Dspotbugs.skip=true']
}
tasks.register 'mvnInstallNetconf', Exec, {
dependsOn mvnInstallYangtools
dependsOn mvnInstallMdsal
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + [
'groovy', 'mvn-netconf.groovy', '--batch-mode', 'install', '-DskipTests',
'-Dmaven.javadoc.skip=true', '-Dcheckstyle.skip=true', '-Dspotbugs.skip=true']
}
tasks.register 'mvnInstallOpenDaylightModules', {
dependsOn mvnInstallYangtools
dependsOn mvnInstallMdsal
dependsOn mvnInstallNetconf
}
tasks.register 'mvnCleanYangtools', Exec, {
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + ['groovy', 'mvn-yangtools.groovy', '--batch-mode', 'clean']
}
tasks.register 'mvnCleanMdsal', Exec, {
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + ['groovy', 'mvn-mdsal.groovy', '--batch-mode', 'clean']
}
tasks.register 'mvnCleanNetconf', Exec, {
workingDir rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + ['groovy', 'mvn-netconf.groovy', '--batch-mode', 'clean']
}
tasks.register 'mvnCleanOpenDaylightModules', {
dependsOn mvnCleanYangtools
dependsOn mvnCleanMdsal
dependsOn mvnCleanNetconf
}
tasks.register 'dockerBuildCiContainer', Exec, {
workingDir project.rootDir
commandLine = (operatingSystem.windows ? ['cmd', '/c'] : []) + [
'docker', 'buildx', 'build', '--file', 'ci.Dockerfile', '--tag', 'adtran/netemu-ci:latest', '.']
}
gradlePlugin {
plugins {
netEmuPlugin {
id = 'com.adva.netemu'
implementationClass = 'com.adva.netemu.gradle.NetEmuPlugin'
}
}
}