Skip to content

Commit 2c933e0

Browse files
committed
Initial build updates
Use a JAVA_HOME pointing to 21 or above. Set individual env vars BC_JDK[8,11,17,21] to also include testing on those VMs.
1 parent ea64413 commit 2c933e0

File tree

11 files changed

+100
-69
lines changed

11 files changed

+100
-69
lines changed

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,7 @@ subprojects {
226226
maxHeapSize = "1536m"
227227
testLogging.showStandardStreams = false
228228

229-
javaLauncher = javaToolchains.launcherFor {
230-
languageVersion = JavaLanguageVersion.of(8)
231-
}
229+
jvmArgs = ['-Dtest.java.version.prefix=any']
232230

233231
finalizedBy jacocoTestReport
234232

@@ -241,6 +239,7 @@ subprojects {
241239
}
242240

243241

242+
244243
dependencies {
245244
checkstyle files("$rootDir/config/checkstyle/lib/methodchecker-1.0.0.jar")
246245
checkstyle 'com.puppycrawl.tools:checkstyle:9.0'
@@ -275,11 +274,11 @@ subprojects {
275274
}
276275
}
277276

278-
tasks.withType(JavaCompile).configureEach {
279-
javaCompiler = javaToolchains.compilerFor {
280-
languageVersion = JavaLanguageVersion.of(21)
281-
}
282-
}
277+
// tasks.withType(JavaCompile).configureEach {
278+
// javaCompiler = javaToolchains.compilerFor {
279+
// languageVersion = JavaLanguageVersion.of(21)
280+
// }
281+
// }
283282

284283
}
285284

ci/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ source ci/common.sh
1212
export BC_JDK8=`openjdk_8`
1313
export BC_JDK11=`openjdk_11`
1414
export BC_JDK17=`openjdk_17`
15+
export BC_JDK21=`openjdk_21`
16+
1517

1618
export JAVA_HOME=`openjdk_21`
1719
export PATH=$JAVA_HOME/bin:$PATH

core/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ jar.archiveBaseName = "bccore-$vmrange"
1313
test {
1414
forkEvery = 1;
1515
maxParallelForks = 8;
16+
jvmArgs = ['-Dtest.java.version.prefix=any']
1617
}
1718

19+
compileJava {
20+
options.release = 8
21+
}
22+
23+
1824
publishing {
1925
publications {
2026
maven(MavenPublication) {
2127
groupId = 'org.bouncycastle'
2228
artifactId = "bccore-$vmrange"
23-
2429
from components.java
25-
2630
}
2731
}
2832
}

mail/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ artifacts {
8989
test {
9090
forkEvery = 1;
9191
maxParallelForks = 8;
92+
jvmArgs = ['-Dtest.java.version.prefix=any']
9293
}
9394

9495
compileJava9Java.dependsOn([":prov:jar", ":util:jar",":pkix:jar"])

mls/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ artifacts {
188188
archives sourcesJar
189189
}
190190

191+
test {
192+
jvmArgs = ['-Dtest.java.version.prefix=any']
193+
}
194+
191195
compileJava9Java.dependsOn([":prov:jar", ":util:jar",":pkix:jar"])
192196

193197
publishing {

pg/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ test {
110110
forkEvery = 1;
111111
maxParallelForks = 8;
112112
maxHeapSize = "3g";
113+
jvmArgs = ['-Dtest.java.version.prefix=any']
113114
}
114115

115116
compileJava9Java.dependsOn([":prov:jar", ":util:jar"])

pkix/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ artifacts {
9797
test {
9898
forkEvery = 1;
9999
maxParallelForks = 8;
100+
jvmArgs = ['-Dtest.java.version.prefix=any']
100101
}
101102

102103
compileJava9Java.dependsOn([":prov:jar", ":util:jar"])

prov/build.gradle

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -231,28 +231,12 @@ publishing {
231231

232232

233233
test {
234-
jvmArgs = ['-Dtest.java.version.prefix=1.8']
235-
dependsOn("test21")
236-
}
237-
238-
if (System.getenv("BC_JDK8") != null) {
239-
System.out.println("${project.name}: Adding test8 as dependency for test task because BC_JDK8 is defined")
240-
test.dependsOn("test8")
241-
}
242-
243-
if (System.getenv("BC_JDK11") != null) {
244-
System.out.println("${project.name}: Adding test11 as dependency for test task because BC_JDK11 is defined")
245-
test.dependsOn("test11")
246-
}
247-
248-
if (System.getenv("BC_JDK17") != null) {
249-
System.out.println("${project.name}: Adding test15 as dependency for test task because BC_JDK17 is defined")
250-
test.dependsOn("test15")
234+
jvmArgs = ['-Dtest.java.version.prefix=any']
251235
}
252236

253237

254238
task test8(type: Test) {
255-
239+
onlyIf {System.getenv("BC_JDK8") != null}
256240
dependsOn(jar)
257241

258242
testClassesDirs = sourceSets.test.output.classesDirs
@@ -283,7 +267,7 @@ task test8(type: Test) {
283267
}
284268

285269
task test11(type: Test) {
286-
270+
onlyIf {System.getenv("BC_JDK11") != null}
287271
dependsOn(jar)
288272

289273
testClassesDirs = sourceSets.test11.output.classesDirs
@@ -300,7 +284,7 @@ task test11(type: Test) {
300284
languageVersion = JavaLanguageVersion.of(11)
301285
}
302286

303-
jvmArgs = ['-Dtest.java.version.prefix=11.']
287+
jvmArgs = ['-Dtest.java.version.prefix=11']
304288

305289

306290
finalizedBy jacocoTestReport
@@ -316,7 +300,7 @@ task test11(type: Test) {
316300
task test15(type: Test) {
317301

318302
// This is testing the 1.15 code base
319-
303+
onlyIf {System.getenv("BC_JDK17") != null}
320304
dependsOn jar
321305

322306
testClassesDirs = sourceSets.test15.output.classesDirs
@@ -333,7 +317,7 @@ task test15(type: Test) {
333317
languageVersion = JavaLanguageVersion.of(17)
334318
}
335319

336-
jvmArgs = ['-Dtest.java.version.prefix=17.']
320+
jvmArgs = ['-Dtest.java.version.prefix=17']
337321

338322

339323
finalizedBy jacocoTestReport
@@ -349,7 +333,7 @@ task test15(type: Test) {
349333
task test21(type: Test) {
350334

351335
// This is testing the 21 code base
352-
336+
onlyIf {System.getenv("BC_JDK21") != null}
353337
dependsOn jar
354338

355339
testClassesDirs = sourceSets.test21.output.classesDirs
@@ -379,5 +363,26 @@ task test21(type: Test) {
379363
}
380364
}
381365

366+
if (System.getenv("BC_JDK8") != null) {
367+
System.out.println("${project.name}: Adding test8 as dependency for test task because BC_JDK8 is defined")
368+
test.dependsOn("test8")
369+
}
370+
371+
if (System.getenv("BC_JDK11") != null) {
372+
System.out.println("${project.name}: Adding test11 as dependency for test task because BC_JDK11 is defined")
373+
test.dependsOn("test11")
374+
}
375+
376+
if (System.getenv("BC_JDK17") != null) {
377+
System.out.println("${project.name}: Adding test15 as dependency for test task because BC_JDK17 is defined")
378+
test.dependsOn("test15")
379+
}
380+
381+
if (System.getenv("BC_JDK21") != null) {
382+
System.out.println("${project.name}: Adding test21 as dependency for test task because BC_JDK21 is defined")
383+
test.dependsOn("test21")
384+
}
385+
386+
382387

383388

prov/src/test/java/org/bouncycastle/test/JVMVersionTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
/**
66
* This test asserts the java version running the tests starts with
77
* a property value passed in as part of test invocation.
8-
*
8+
* <p>
99
* -Dtest.java.version.prefix must match the start of System.getProperty("java.version")
1010
* So:
11-
* if -Dtest.java.version.prefix=17 and System.getProperty("java.version") = 17.0.4.1
12-
* Then this test will pass.
11+
* if -Dtest.java.version.prefix=17 and System.getProperty("java.version") = 17.0.4.1
12+
* Then this test will pass.
1313
*/
1414
public class JVMVersionTest extends TestCase
1515
{
1616

1717
private static final String expectedVersionPropName = "test.java.version.prefix";
18-
19-
public void testAssertExpectedJVM() {
18+
19+
public void testAssertExpectedJVM()
20+
{
2021

2122
//
2223
// This project produces a multi-release jar, and we need to test it on different jvm versions
@@ -30,13 +31,18 @@ public void testAssertExpectedJVM() {
3031
//
3132

3233
String version = System.getProperty("java.version");
33-
assertNotNull(String.format("property %s is not set, see comment in test for reason why.",expectedVersionPropName),System.getProperty(expectedVersionPropName));
34-
34+
assertNotNull(String.format("property %s is not set, see comment in test for reason why.", expectedVersionPropName), System.getProperty(expectedVersionPropName));
3535

3636

3737
String expectedPrefix = System.getProperty(expectedVersionPropName);
3838

39-
TestCase.assertTrue(String.format("JVM Version: '%s' did not start with '%s' see comment in test",version,expectedPrefix), version.startsWith(expectedPrefix));
39+
if ("any".equals(expectedPrefix))
40+
{
41+
TestCase.assertTrue(true);
42+
return;
43+
}
44+
45+
TestCase.assertTrue(String.format("JVM Version: '%s' did not start with '%s' see comment in test", version, expectedPrefix), version.startsWith(expectedPrefix));
4046

4147
}
4248

tls/build.gradle

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,10 @@ publishing {
173173
}
174174

175175

176-
test {
177-
jvmArgs = ['-Dtest.java.version.prefix=1.8']
178-
dependsOn("test21")
179-
}
180-
181-
if (System.getenv("BC_JDK8") != null) {
182-
System.out.println("${project.name}: Adding test8 as dependency for test task because BC_JDK8 is defined")
183-
test.dependsOn("test8")
184-
}
185-
186-
if (System.getenv("BC_JDK11") != null) {
187-
System.out.println("${project.name}: Adding test11 as dependency for test task because BC_JDK11 is defined")
188-
test.dependsOn("test11")
189-
}
190176

191-
if (System.getenv("BC_JDK17") != null) {
192-
System.out.println("${project.name}: Adding test15 as dependency for test task because BC_JDK17 is defined")
193-
test.dependsOn("test15")
194-
}
195177

196178
task test8(type: Test) {
197-
179+
onlyIf {System.getenv("BC_JDK8") != null}
198180
testClassesDirs = sourceSets.test.output.classesDirs
199181
classpath = sourceSets.test.runtimeClasspath + files(jar.archiveFile)
200182

@@ -222,9 +204,8 @@ task test8(type: Test) {
222204
}
223205
}
224206

225-
226207
task test11(type: Test) {
227-
208+
onlyIf {System.getenv("BC_JDK11") != null}
228209
dependsOn(jar)
229210

230211
testClassesDirs = sourceSets.test11.output.classesDirs
@@ -241,7 +222,7 @@ task test11(type: Test) {
241222
languageVersion = JavaLanguageVersion.of(11)
242223
}
243224

244-
jvmArgs = ['-Dtest.java.version.prefix=11.']
225+
jvmArgs = ['-Dtest.java.version.prefix=11']
245226

246227

247228
finalizedBy jacocoTestReport
@@ -257,7 +238,7 @@ task test11(type: Test) {
257238
task test15(type: Test) {
258239

259240
// This is testing the 1.15 code base
260-
241+
onlyIf {System.getenv("BC_JDK17") != null}
261242
dependsOn jar
262243

263244
testClassesDirs = sourceSets.test15.output.classesDirs
@@ -274,7 +255,7 @@ task test15(type: Test) {
274255
languageVersion = JavaLanguageVersion.of(17)
275256
}
276257

277-
jvmArgs = ['-Dtest.java.version.prefix=17.']
258+
jvmArgs = ['-Dtest.java.version.prefix=17']
278259

279260

280261
finalizedBy jacocoTestReport
@@ -290,7 +271,7 @@ task test15(type: Test) {
290271
task test21(type: Test) {
291272

292273
// This is testing the 21 code base
293-
274+
onlyIf {System.getenv("BC_JDK21") != null}
294275
dependsOn jar
295276

296277
testClassesDirs = sourceSets.test21.output.classesDirs
@@ -320,4 +301,26 @@ task test21(type: Test) {
320301
}
321302
}
322303

304+
if (System.getenv("BC_JDK8") != null) {
305+
System.out.println("${project.name}: Adding test8 as dependency for test task because BC_JDK8 is defined")
306+
test.dependsOn("test8")
307+
}
308+
309+
if (System.getenv("BC_JDK11") != null) {
310+
System.out.println("${project.name}: Adding test11 as dependency for test task because BC_JDK11 is defined")
311+
test.dependsOn("test11")
312+
}
313+
314+
if (System.getenv("BC_JDK17") != null) {
315+
System.out.println("${project.name}: Adding test15 as dependency for test task because BC_JDK17 is defined")
316+
test.dependsOn("test15")
317+
}
318+
319+
if (System.getenv("BC_JDK21") != null) {
320+
System.out.println("${project.name}: Adding test21 as dependency for test task because BC_JDK21 is defined")
321+
test.dependsOn("test21")
322+
}
323+
324+
325+
323326
compileJava9Java.dependsOn([":prov:jar", ":util:jar",":pkix:jar"])

0 commit comments

Comments
 (0)