Repository: deepjavalibrary/djl
Pull request #2230 (2022-12-15 05:37:25)

[ci] Upgrade testng to 7.7.0
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/basicdataset/build.gradle b/basicdataset/build.gradle
index eac450c4d..b0771cf0f 100644
--- a/basicdataset/build.gradle
+++ b/basicdataset/build.gradle
@@ -4,9 +4,6 @@ dependencies {
 
     // Add following dependency to your project for COCO dataset
     // runtimeOnly "com.twelvemonkeys.imageio:imageio-jpeg:3.5"
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 
     testImplementation project(":testing")
diff --git a/build.gradle b/build.gradle
index ec0e16c8f..ba56a4a96 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,12 +32,17 @@ def javaProjects() {
 
 configure(javaProjects()) {
     apply plugin: 'java-library'
-    sourceCompatibility = 1.8
-    targetCompatibility = 1.8
-    compileJava.options.encoding = "UTF-8"
-    compileTestJava.options.encoding = "UTF-8"
-    if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
-        compileJava.options.compilerArgs.addAll(["--release", "8"])
+    compileJava {
+        options.encoding = "UTF-8"
+        sourceCompatibility = JavaVersion.VERSION_1_8
+        targetCompatibility = JavaVersion.VERSION_1_8
+        options.compilerArgs << "--release" << "8" << "-proc:none" << "-Xlint:all,-options,-static" << "-Werror"
+    }
+    compileTestJava {
+        options.encoding = "UTF-8"
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static,-removal" << "-Werror"
     }
 
     apply plugin: 'eclipse'
@@ -60,13 +65,6 @@ configure(javaProjects()) {
     test {
         // tensorflow mobilenet and resnet require more cpu memory
         maxHeapSize = "4096m"
-        doFirst {
-            if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
-                jvmArgs = [
-                        '--add-opens', "java.base/jdk.internal.loader=ALL-UNNAMED"
-                ]
-            }
-        }
 
         useTestNG() {
             // suiteXmlFiles << new File(rootDir, "testng.xml") //This is how to add custom testng.xml
@@ -78,6 +76,9 @@ configure(javaProjects()) {
         }
 
         doFirst {
+            jvmArgs = [
+                    '--add-opens', "java.base/jdk.internal.loader=ALL-UNNAMED"
+            ]
             systemProperties System.getProperties()
             systemProperties.remove("user.dir")
             // systemProperty "ai.djl.logging.level", "debug"
@@ -97,14 +98,6 @@ configure(javaProjects()) {
         }
     }
 
-    compileJava {
-        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static" << "-Werror"
-    }
-
-    compileTestJava {
-        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static,-removal" << "-Werror"
-    }
-
     jar {
         manifest {
             attributes(
diff --git a/docs/quick_start.md b/docs/quick_start.md
index c59352e75..f352a3915 100644
--- a/docs/quick_start.md
+++ b/docs/quick_start.md
@@ -10,7 +10,7 @@ You can also view our 1.5 hour long (in 8 x ~10 minute segments) DJL 101 tutoria
 
 ## Prerequisites
 
-* You need a Java Development Kit (JDK) installed on your system. We recommend using JDK 8, but any later version also works. For more information, see [Setup](development/setup.md).
+* You need a Java Development Kit (JDK) installed on your system. We recommend using JDK 11, but any later version also works. For more information, see [Setup](development/setup.md).
 * You need git installed on your system to clone the DJL repository.
 
 ## Try DJL
diff --git a/engines/ml/lightgbm/build.gradle b/engines/ml/lightgbm/build.gradle
index 86f5945d9..8cfb37726 100644
--- a/engines/ml/lightgbm/build.gradle
+++ b/engines/ml/lightgbm/build.gradle
@@ -5,9 +5,6 @@ dependencies {
     api "com.microsoft.ml.lightgbm:lightgbmlib:${lightgbm_version}"
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
 }
diff --git a/engines/ml/xgboost/build.gradle b/engines/ml/xgboost/build.gradle
index 36dd5f6c6..d736d4b96 100644
--- a/engines/ml/xgboost/build.gradle
+++ b/engines/ml/xgboost/build.gradle
@@ -27,9 +27,6 @@ dependencies {
     exclusion project(":api")
     exclusion "commons-logging:commons-logging:${commons_logging_version}"
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
     if (isGpu) {
diff --git a/engines/mxnet/mxnet-engine/build.gradle b/engines/mxnet/mxnet-engine/build.gradle
index a17c18618..f953817db 100644
--- a/engines/mxnet/mxnet-engine/build.gradle
+++ b/engines/mxnet/mxnet-engine/build.gradle
@@ -7,9 +7,6 @@ dependencies {
     testImplementation project(":model-zoo")
     testImplementation(project(":testing"))
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/mxnet/mxnet-model-zoo/build.gradle b/engines/mxnet/mxnet-model-zoo/build.gradle
index c0c3d8ed2..c87026e18 100644
--- a/engines/mxnet/mxnet-model-zoo/build.gradle
+++ b/engines/mxnet/mxnet-model-zoo/build.gradle
@@ -8,9 +8,6 @@ dependencies {
     testImplementation project(":model-zoo")
     testImplementation(project(":testing"))
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/onnxruntime/onnxruntime-engine/build.gradle b/engines/onnxruntime/onnxruntime-engine/build.gradle
index 162663344..b82b22f9f 100644
--- a/engines/onnxruntime/onnxruntime-engine/build.gradle
+++ b/engines/onnxruntime/onnxruntime-engine/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api "com.microsoft.onnxruntime:onnxruntime:${onnxruntime_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testImplementation project(":engines:pytorch:pytorch-engine")
 
diff --git a/engines/paddlepaddle/paddlepaddle-engine/build.gradle b/engines/paddlepaddle/paddlepaddle-engine/build.gradle
index 06b03aa02..7df5439f2 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-engine/build.gradle
@@ -3,9 +3,6 @@ group "ai.djl.paddlepaddle"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation(project(":testing"))
 }
diff --git a/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle b/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
index 8e7bf3aa9..33adff4a0 100644
--- a/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
@@ -3,9 +3,7 @@ group 'ai.djl.paddlepaddle'
 
 dependencies {
     api project(":engines:paddlepaddle:paddlepaddle-engine")
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
+
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
     testRuntimeOnly project(":extensions:opencv")
diff --git a/engines/tensorflow/tensorflow-engine/build.gradle b/engines/tensorflow/tensorflow-engine/build.gradle
index 4166ef21d..1f3c0728c 100644
--- a/engines/tensorflow/tensorflow-engine/build.gradle
+++ b/engines/tensorflow/tensorflow-engine/build.gradle
@@ -5,9 +5,6 @@ dependencies {
     api project(":engines:tensorflow:tensorflow-api")
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/tensorflow/tensorflow-model-zoo/build.gradle b/engines/tensorflow/tensorflow-model-zoo/build.gradle
index 02e10135b..b8e9412ec 100644
--- a/engines/tensorflow/tensorflow-model-zoo/build.gradle
+++ b/engines/tensorflow/tensorflow-model-zoo/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":engines:tensorflow:tensorflow-engine")
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/tflite/tflite-engine/build.gradle b/engines/tflite/tflite-engine/build.gradle
index bc548b1ae..03cce9293 100644
--- a/engines/tflite/tflite-engine/build.gradle
+++ b/engines/tflite/tflite-engine/build.gradle
@@ -3,10 +3,6 @@ group "ai.djl.tflite"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation(project(":testing"))
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
 }
diff --git a/examples/pom.xml b/examples/pom.xml
index f079672ea..f996872ea 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -8,8 +8,8 @@
     <version>0.21.0-SNAPSHOT</version>
 
     <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
         <djl.version>0.21.0-SNAPSHOT</djl.version>
         <exec.mainClass>ai.djl.examples.inference.ObjectDetection</exec.mainClass>
     </properties>
@@ -72,7 +72,7 @@
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <version>7.5</version>
+            <version>7.7.0</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/extensions/audio/build.gradle b/extensions/audio/build.gradle
index 266cb9dd4..4cadf47b9 100644
--- a/extensions/audio/build.gradle
+++ b/extensions/audio/build.gradle
@@ -25,9 +25,6 @@ dependencies {
     runtimeOnly "org.bytedeco:ffmpeg:5.0-1.5.7:linux-x86_64"
     runtimeOnly "org.bytedeco:ffmpeg:5.0-1.5.7:windows-x86_64"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
     testRuntimeOnly project(":engines:pytorch:pytorch-engine")
diff --git a/extensions/fasttext/build.gradle b/extensions/fasttext/build.gradle
index b3c16cfb4..c772abb1c 100644
--- a/extensions/fasttext/build.gradle
+++ b/extensions/fasttext/build.gradle
@@ -4,10 +4,6 @@ dependencies {
     api project(":api")
     api project(":basicdataset")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     // ModelZoo requires at least one engine in the class path
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation(project(":testing"))
diff --git a/extensions/hadoop/build.gradle b/extensions/hadoop/build.gradle
index 38a2760c3..c480a2835 100644
--- a/extensions/hadoop/build.gradle
+++ b/extensions/hadoop/build.gradle
@@ -12,7 +12,6 @@ dependencies {
     testImplementation "org.mockito:mockito-core:${mockito_version}"
     testImplementation(project(":testing"))
 
-    testImplementation "org.testng:testng:${testng_version}"
     testRuntimeOnly "junit:junit:${junit_version}" // hadoop-client test depends on junit
 }
 
diff --git a/extensions/opencv/build.gradle b/extensions/opencv/build.gradle
index 05dddad24..6c29f026a 100644
--- a/extensions/opencv/build.gradle
+++ b/extensions/opencv/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api "org.openpnp:opencv:4.5.1-2"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
 
diff --git a/extensions/sentencepiece/build.gradle b/extensions/sentencepiece/build.gradle
index 7dd054cff..1b9e2b313 100644
--- a/extensions/sentencepiece/build.gradle
+++ b/extensions/sentencepiece/build.gradle
@@ -3,10 +3,6 @@ group "ai.djl.sentencepiece"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation(project(":testing"))
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
diff --git a/extensions/spark/build.gradle b/extensions/spark/build.gradle
index 325f2a5cf..1f496df04 100644
--- a/extensions/spark/build.gradle
+++ b/extensions/spark/build.gradle
@@ -10,9 +10,6 @@ dependencies {
     api "org.apache.spark:spark-sql_2.12:${spark_version}"
     api "org.apache.spark:spark-mllib_2.12:${spark_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
 
diff --git a/extensions/tablesaw/build.gradle b/extensions/tablesaw/build.gradle
index 2e71879f9..85051e3d0 100644
--- a/extensions/tablesaw/build.gradle
+++ b/extensions/tablesaw/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api project(":basicdataset")
     api "tech.tablesaw:tablesaw-core:${tablesaw_version}"
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
diff --git a/extensions/timeseries/build.gradle b/extensions/timeseries/build.gradle
index f4aea7010..a19872062 100644
--- a/extensions/timeseries/build.gradle
+++ b/extensions/timeseries/build.gradle
@@ -6,10 +6,6 @@ dependencies {
     api "tech.tablesaw:tablesaw-core:${tablesaw_version}"
     api "tech.tablesaw:tablesaw-jsplot:${tablesaw_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
 
diff --git a/extensions/tokenizers/build.gradle b/extensions/tokenizers/build.gradle
index d49146778..3a2f4313d 100644
--- a/extensions/tokenizers/build.gradle
+++ b/extensions/tokenizers/build.gradle
@@ -3,9 +3,6 @@ group "ai.djl.huggingface"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation project(":testing")
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
diff --git a/gradle.properties b/gradle.properties
index 856c25bad..6930a6271 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -43,6 +43,6 @@ tablesaw_version=0.43.1
 spark_version=3.2.2
 
 antlr_version=4.9.3
-testng_version=7.5
+testng_version=7.7.0
 junit_version=4.13.2
 mockito_version=4.8.0
diff --git a/integration/build.gradle b/integration/build.gradle
index 97fe0a499..0cb57bb6a 100644
--- a/integration/build.gradle
+++ b/integration/build.gradle
@@ -4,14 +4,11 @@ plugins {
 }
 
 dependencies {
-    api "commons-cli:commons-cli:${commons_cli_version}"
-    api "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
-    api project(":basicdataset")
-    api project(":model-zoo")
-    api project(":testing")
-    api("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
+    implementation "commons-cli:commons-cli:${commons_cli_version}"
+    implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
+    implementation project(":basicdataset")
+    implementation project(":model-zoo")
+    implementation project(":testing")
 
     runtimeOnly project(":engines:mxnet:mxnet-model-zoo")
     runtimeOnly project(":engines:pytorch:pytorch-model-zoo")
@@ -32,6 +29,14 @@ dependencies {
     }
 }
 
+java {
+    compileJava {
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs.removeAll(["--release", "8"])
+    }
+}
+
 task copyDependencies(type: Copy) {
     into "build/dependencies"
     from configurations.runtimeClasspath


Test patch:
diff --git a/testing/build.gradle b/testing/build.gradle
index 9b2081f35..286600d4c 100644
--- a/testing/build.gradle
+++ b/testing/build.gradle
@@ -1,4 +1,14 @@
 dependencies {
     api project(":api")
-    api "org.testng:testng:${testng_version}"
+    api("org.testng:testng:${testng_version}") {
+        exclude group: "junit", module: "junit"
+    }
+}
+
+java {
+    compileJava {
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs.removeAll(["--release", "8"])
+    }
 }