-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathbuild.gradle
More file actions
174 lines (151 loc) · 5.58 KB
/
build.gradle
File metadata and controls
174 lines (151 loc) · 5.58 KB
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
plugins {
id 'java'
id 'jacoco'
id 'maven-publish'
id 'com.github.spotbugs' version '6.0.6'
}
group = 'net.juniper.netconf'
version = '2.2.1.0'
description = 'An API For NetConf client'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.jcraft:jsch:0.1.55'
implementation 'org.slf4j:slf4j-api:2.0.3'
implementation 'com.google.guava:guava:32.0.1-jre'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'org.assertj:assertj-core:3.27.7'
testImplementation 'org.mockito:mockito-core:4.8.1'
testImplementation 'commons-io:commons-io:2.14.0'
testImplementation 'org.xmlunit:xmlunit-assertj:2.9.0'
testImplementation 'org.slf4j:slf4j-simple:2.0.3'
testImplementation 'com.github.spotbugs:spotbugs-annotations:4.7.3'
}
testing {
suites {
test {
// Pulls in both junit-jupiter-api and -engine at version 5.11.1
useJUnitJupiter('5.11.1')
}
}
}
test {
testLogging {
events "passed", "skipped", "failed"
}
}
def netconfPropertySpecs = [
[name: 'netconf.host', env: 'NETCONF_HOST', required: true],
[name: 'netconf.username', env: 'NETCONF_USERNAME', required: true],
[name: 'netconf.password', env: 'NETCONF_PASSWORD', required: true],
[name: 'netconf.port', env: 'NETCONF_PORT', required: false, defaultValue: '830'],
[name: 'netconf.timeout', env: 'NETCONF_TIMEOUT', required: false, defaultValue: '30000']
]
def resolveNetconfProperty = { Map spec ->
if (project.hasProperty(spec.name)) {
return project.property(spec.name).toString()
}
if (System.getProperty(spec.name) != null) {
return System.getProperty(spec.name)
}
if (System.getenv(spec.env) != null) {
return System.getenv(spec.env)
}
return spec.defaultValue
}
tasks.register('integrationTest', org.gradle.api.tasks.testing.Test) {
description = 'Runs live NETCONF integration tests against a configured endpoint.'
group = 'verification'
useJUnitPlatform()
shouldRunAfter test
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
filter {
includeTestsMatching 'net.juniper.netconf.integration.NetconfIntegrationTest'
}
testLogging {
events "passed", "skipped", "failed"
}
doFirst {
def resolvedProperties = [:]
def missingRequiredProperties = []
netconfPropertySpecs.each { spec ->
def value = resolveNetconfProperty(spec)
if (value == null || value.toString().trim().isEmpty()) {
if (spec.required) {
missingRequiredProperties << "${spec.name} (${spec.env})"
}
return
}
resolvedProperties[spec.name] = value.toString()
}
if (!missingRequiredProperties.isEmpty()) {
throw new org.gradle.api.GradleException(
"integrationTest requires live NETCONF connection details. " +
"Provide ${missingRequiredProperties.join(', ')} via -Dnetconf.* " +
"or NETCONF_* environment variables."
)
}
systemProperty 'netconf.integration.enabled', 'true'
resolvedProperties.each { propertyName, propertyValue ->
systemProperty propertyName, propertyValue
}
}
}
tasks.withType(JavaCompile).configureEach {
options.fork = true
options.forkOptions.jvmArgs += [
'--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED'
]
}
spotbugs {
ignoreFailures = true
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name.set("$group:$project.name")
description.set(project.description)
url.set("https://github.com/Juniper/netconf-java")
licenses {
license {
name.set("BSD 2")
url.set("https://opensource.org/licenses/BSD-2-Clause")
}
}
developers {
developer {
id.set("juniper")
name.set("Juniper Networks")
email.set("jnpr-community-netdev@juniper.net")
organization.set("Juniper Networks")
organizationUrl.set("https://github.com/Juniper")
}
}
scm {
connection.set("scm:git:git://github.com/Juniper/netconf-java.git")
developerConnection.set("scm:git:ssh://github.com:Juniper/netconf-java.git")
url.set("https://github.com/Juniper/netconf-java/tree/master")
}
}
}
}
}