Menu

#68 update to properly support Java modules

Unstable (example)
closed-accepted
None
5
2023-07-08
2023-05-30
Samael
No

This patch updates numerous maven plugins and a few dependencies. More importantly it splits the configuration of maven-jar-plugin into two profiles. If the project is being built with JDK 1.8 then it will continue to use the Automatic-Module-Name but if a newer JDK is used it will instead produce a multi-release jar that includes a module-info for JDK's 9 and above.

I've tested building this on Java 8, 11, and 17 and can confirm that the resulting manifest will still have the required fields that the bundle plugin inserts.

Note that commons.beanutils doesn't properly support Java modules. See: https://issues.apache.org/jira/browse/BEANUTILS-560

1 Attachments

Discussion

  • Scott Conway

    Scott Conway - 2023-06-03

    I will try an take a look at this next week. Please note that if we do accept this we will never release anything but java 8 until it is completely sunset - had a VERY negative backlash years ago when we went to java 7 when java 6 was still supported so my personal policy is that until apache java 8 is sunset completely and the apache commons libraries we use support the next LTR java version I will not move opencsv to a newer version of java.

     
  • Jeff

    Jeff - 2023-06-21

    So are you saying you intend to stay on JAVA 8 until 2030? I'm going to be forced onto JAVA 17 in 2025. Do you know if you use any of the deprecated features JAVA 17 no longer supports?
    Thx

     
  • Scott Conway

    Scott Conway - 2023-06-22

    Well after the blowback years ago when we jumped versions early I am tempted to say yes. But a out I made to a fellow developer several years ago was if any of the apache common libraries we rely on come out with a version on a new LTS version I would consider updated openCSV to that version though after looking at the LTS list (https://endoflife.date/java) I see that Java 8 is indeed going to outlive java 11 and java 17.

    But really I don't know if we use anything that is deprecated in Java 17. I know Andrew used to build opencsv in later versions of Java but don't know how far he took it. As a test you can remove the upper limit on the required java version in the maven-enforcer plugin and change the source and target version in the maven compiler plugin to 17 and give it a go. Please let me know how that turns out.

    That might be the route to go in the future is by default restrict and compile to java 8 but give profiles to compile in java 11 and java 17 for those who really want/need the newer version. That way we can build with those versions similar to how Andrew used to test to make sure we are not messing up forward compatibility.

    Like I said try a build with everything set to java 17 and let me know how it goes.

    Thanks!

    Scott :)

     
    • Andrew Rucker Jones

      I have tested opencsv with Java 8 through 19. No problems.

       
  • Samael

    Samael - 2023-06-27

    just wanted to clarify, with this patch Java 1.8 is still supported. It should be built with a later JDK such as Java 11 but the bulk of the source will compile to Java 1.8 byte code, only the module-info.java file will be compiled with the newer JDK. It is a multi-release jar.

     
  • Scott Conway

    Scott Conway - 2023-07-08
    • status: open --> closed-accepted
    • assigned_to: Scott Conway
     
  • Scott Conway

    Scott Conway - 2023-07-08

    I have merged in your patch. I had to back down the version of puppycrawl it was built in Java 11 and actually gives an error if you run mvn clean install site:site using Java 8.

    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.1:site (default-cli) on project opencsv: Execution default-cli of goal org.apache.maven.plugins:maven-site-plugin:3.12.1:site failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-site-plugin:3.12.1:site: java.lang.UnsupportedClassVersionError: com/puppycrawl/tools/checkstyle/api/AuditListener has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    [ERROR] -----------------------------------------------------

    After that I did some checking in the mvn build report and downgraded the asciidoctorj as well (had been throwing warning for a while). I did add comments to each of these versions as an aid in the future because I have been burned by the puppy crawl several times now.

     
    👍
    1

Log in to post a comment.

MongoDB Logo MongoDB