5

I am converting a legacy java app to a modular one. It is a Gradle project, and the dependencies look like this:

dependencies {
    implementation 'org.jopendocument:jOpenDocument:1.3'
    implementation 'xom:xom:1.3.2'
}

In the App class, my imports are:

import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;
import org.jopendocument.dom.spreadsheet.MutableCell;
import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;

I want to create a module-info.java file. But when I do, my app won't compile because the requires directives are wrong in the module-info file.

module weapongeneration4dusty.main {
    requires xom;
    requires jOpenDocument;
    exports com.hymerfania.rptools.maptool.meta.tablegeneration;
}

The module names xom and jOpenDocument are insufficient. But I don't know what they should be for these dependencies, nor how to reconfigure Gradle; if that's what I need to do.

When I omit either requires statement, the corresponding imports fail to resolve. I have not looked in the JAR files. But I don't think either artifact is modular.

I'm using Gradle 5.6.2 and I'm targeting Java 11.

deduper
  • 1,944
  • 9
  • 22
Charlweed
  • 1,517
  • 2
  • 14
  • 22
  • If `xom` and `jOpenDocument` are unnamed modules, you don't need to put `requires xom` there. Check if they have module-info files – user Jun 21 '20 at 20:34
  • If I omit the requires statements, app does not compile because the imports cannot be resolved. I'll edit the question to point that out. Thanks! – Charlweed Jun 21 '20 at 23:06
  • 1
    I just upgraded the gradlew to 6.5, and now I get split packages errors "error: the unnamed module reads package org.w3c.dom from both jOpenDocument and xml.apis" That is probably progress, but I can only guess about how to fix this new problem. First I will try to concoct a "exclude group" statement in the build.gradle. But I am completely in the dark. – Charlweed Jun 21 '20 at 23:49
  • 1
    Possibly related https://stackoverflow.com/questions/44697738/how-to-resolve-module-reads-package-error-in-java9 and https://stackoverflow.com/questions/42358084/package-conflicts-with-automatic-modules-in-java-9 – Naman Jun 22 '20 at 04:14
  • How did you eventually resolve your split package problem @Charlweed? An identical issue was resolved [*with this answer*](https://stackoverflow.com/questions/64072627/understanding-errors-with-jpms-modules/64124282#64124282). – deduper Sep 30 '20 at 18:16

0 Answers0