You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/09/26 10:42:41 UTC

[plc4x] 02/02: chore(build): Updated the build to be compatible with Java 19

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit dd2dd7691dffa7bdd8058eee2f1811ff0bddca1f
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Sep 26 12:42:23 2022 +0200

    chore(build): Updated the build to be compatible with Java 19
---
 README.md                                                  |  6 ++++--
 .../org/apache/plc4x/java/modbus/ModbusEncodeTest.java     |  9 ++++++++-
 plc4j/integrations/pom.xml                                 | 14 +++++++++++++-
 pom.xml                                                    |  3 ++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 39d5fe37b..122bd0e5f 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ the language of choice.
 
 ### Java
 
-NOTE: Currently the Java version which supports building of all parts of Apache PLC4X is at least Java 11
+NOTE: Currently the Java version which supports building of all parts of Apache PLC4X is at least Java 11 (Currently with Java 19 the Apache Kafka integration module is excluded from the build as the plugins it requires are incompatible with this version)
 
 See the PLC4J user guide on the website to start using PLC4X in your Java application:
 [https://plc4x.apache.org/users/getting-started/plc4j.html](https://plc4x.apache.org/users/getting-started/plc4j.html)
@@ -139,7 +139,9 @@ If you don't want to bother setting up the environment on your normal system and
 ### Getting Started
 
 You must have at least Java 11 installed on your system and connectivity to Maven Central
-(for downloading external third party dependencies). Maven 3.6 is required to build, so be sure it's installed and available on your system. 
+(for downloading external third party dependencies). Maven 3.6 is required to build, so be sure it's installed and available on your system.
+
+NOTE: When using Java 19 currently the Apache Kafka integration module is excluded from the build as one of the plugins it requires has proven to be incompatible with this version. 
 
 NOTE: There is a convenience Maven-Wrapper installed in the repo, when used, this automatically downloads and installs Maven. If you want to use this, please use `./mvnw` or `mvnw` instead of the normal `mvn` command.
 
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java
index c9d103f4f..fe1ab6321 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.plc4x.java.modbus;
 
+import org.apache.plc4x.java.api.value.PlcValue;
 import org.apache.plc4x.java.modbus.base.field.ModbusFieldHoldingRegister;
 import org.apache.plc4x.java.modbus.base.field.ModbusFieldCoil;
 import org.apache.plc4x.java.spi.values.IEC61131ValueHandler;
@@ -137,7 +138,13 @@ public class ModbusEncodeTest {
         Float[] object = {1.1f,1000.1f,100000.1f,3.4028232E38f,-3.4028232E38f,-1f,10384759934840.0f};
         ModbusFieldHoldingRegister holdingregister = ModbusFieldHoldingRegister.of("holding-register:7:REAL");
         PlcList list = (PlcList) IEC61131ValueHandler.of(holdingregister, object);
-        Assertions.assertEquals("[1.1,1000.1,100000.1,3.4028233E38,-3.4028233E38,-1.0,1.03847601E13]", list.toString());
+        //! When using Java 19 it seems the toString method uses a different precision than the previous versions,
+        //! so we need to check differently in this case.
+        for (int i = 0; i < list.getLength(); i++) {
+            PlcValue plcValue = list.getIndex(i);
+            Float referenceValue = object[i];
+            Assertions.assertEquals(referenceValue, plcValue.getFloat());
+        }
     }
 
     @Test
diff --git a/plc4j/integrations/pom.xml b/plc4j/integrations/pom.xml
index 1eb4e73de..3d7fd4263 100644
--- a/plc4j/integrations/pom.xml
+++ b/plc4j/integrations/pom.xml
@@ -35,10 +35,22 @@
 
   <modules>
     <module>apache-camel</module>
-    <module>apache-kafka</module>
     <module>apache-nifi</module>
     <module>apache-calcite</module>
     <module>opcua-server</module>
   </modules>
 
+  <!-- ! the kafka maven plugin currently seems to have issues with Java 19 -->
+  <profiles>
+    <profile>
+      <id>java-version-not-19</id>
+      <activation>
+        <jdk>[1.8, 19)</jdk>
+      </activation>
+      <modules>
+        <module>apache-kafka</module>
+      </modules>
+    </profile>
+  </profiles>
+
 </project>
diff --git a/pom.xml b/pom.xml
index ebd2f4834..be016b5e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -134,7 +134,8 @@
     <hamcrest.version>2.2</hamcrest.version>
     <httpclient.version>4.5.13</httpclient.version>
     <httpcore.version>4.4.15</httpcore.version>
-    <jackson.version>2.13.4</jackson.version>
+    <!-- ! 2.13.4 has a known CVE and 2.14.0-rc1 seems to fix that, even if not finally released -->
+    <jackson.version>2.14.0-rc1</jackson.version>
     <woodstox-core.version>6.3.1</woodstox-core.version>
     <!-- When updating this to the latest version, we're getting errors in the opcua server tests -->
     <jaxb.version>4.0.1</jaxb.version>