metafacture / metafacture-fix

Work in progress towards an implementation of the Fix language for Metafacture
Apache License 2.0
6 stars 2 forks source link

Upgrade Gradle wrapper to version 8.x. #283

Closed blackwinter closed 7 months ago

blackwinter commented 1 year ago

Gradle 8.0 has been released, but the upgrade is blocked by xtext/xtext-gradle-plugin#204:

A problem occurred evaluating root project 'metafacture-fix'.
> Failed to apply plugin 'org.xtext.builder'.
   > Could not create task ':metafix:generateXtext'.
      > Cannot use @TaskAction annotation on method XtextGenerate.generate()
because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not
a valid parameter to an action method.

This in turn (semi-)blocks the upgrade in Limetrans due to the inability to run its test matrix against metafacture-fix master.

blackwinter commented 1 year ago

The original issue (xtext/xtext-gradle-plugin#203) has been fixed by xtext/xtext-gradle-plugin#210, but the fix has not been officially released yet. Also, it raises the minimum Java version to 11 (while we're still on 1.8).

blackwinter commented 8 months ago

The Xtext Builder plugin supports Gradle 8.0 since version 4.0.0.

This leaves us with the Java 11 requirement. Can we raise our minimum Java version as well?

blackwinter commented 8 months ago

Raising the minimum Java version to 11 would make working on both metafacture-fix and metafacture-core in parallel more complicated since the latter's build is currently not compatible with Java 11:

diff --git build.gradle build.gradle
index 43fd477a..3974979b 100644
--- build.gradle
+++ build.gradle
@@ -31,7 +31,7 @@ subprojects {
       'guava': '29.0-jre',
       'jackson_databind': '2.15.1',
       'junit': '4.12',
-      'mockito': '2.5.7',
+      'mockito': '2.27.0',
       'slf4j': '1.7.36',
       'wiremock_jre': '2.35.0'
     ]
diff --git metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/ComplexTypeEncoder.java metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/ComplexTypeEncoder.java
index 3d32dde7..193928db 100644
--- metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/ComplexTypeEncoder.java
+++ metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/ComplexTypeEncoder.java
@@ -43,7 +43,7 @@ class ComplexTypeEncoder implements TypeEncoder {

     private static Object createInstance(final Class<?> clazz) {
         try {
-            return clazz.newInstance();
+            return clazz.getDeclaredConstructor().newInstance();
         }
         catch (final Exception e) { // checkstyle-disable-line IllegalCatch
             throw new MetafactureException("Can't instantiate object of class: " + clazz, e);
diff --git metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java
index ff0dac5e..1712c277 100644
--- metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java
+++ metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java
@@ -29,10 +29,11 @@
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
 import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;

 import java.io.IOException;
 import java.io.Reader;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;

 /**
  * Reads an XML file and passes the XML events to a receiver.
@@ -56,9 +57,12 @@ public final class XmlDecoder extends DefaultObjectPipe<Reader, XmlReceiver> {
      */
     public XmlDecoder() {
         try {
-            saxReader = XMLReaderFactory.createXMLReader();
+            final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+            parserFactory.setNamespaceAware(true);
+
+            saxReader = parserFactory.newSAXParser().getXMLReader();
         }
-        catch (final SAXException e) {
+        catch (final ParserConfigurationException | SAXException e) {
             throw new MetafactureException(e);
         }
     }
> Task :metamorph:test

org.metafacture.metamorph.functions.ScriptTest > shouldExecuteJavascriptFunctions STANDARD_ERROR
    Warning: Nashorn engine is planned to be removed from a future JDK release
    Warning: Nashorn engine is planned to be removed from a future JDK release
blackwinter commented 8 months ago

Our version of the Editorconfig Gradle plugin is not compatible with Gradle 8.x. However, upgrading to a compatible version (0.1.0) would raise the minimum Java version to 16, which in turn is not compatible with metafacture-core's Gradle version (6.0; see also metafacture/metafacture-core#484).

So instead, I propose that we disable the Editorconfig plugin until such time as either a Java 11 compatible version gets released or we're comfortable with switching to Java 17 (LTS). We still have editorconfig-checker as an alternative (see #179).