From my experience, minimize your direct Maven dependencies. Try to use
services as much as possible. For example. eclipselink should be a
runtime, not a compile time dependency and should be injected as service:
module-info.java:
requires jakarta.persistence;
uses jakarta.persistence.spi.PersistenceProvider;
pom.xml:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>4.0.1</version>
<scope>runtime</scope>
</dependency>
Basically, strip the dependencies back to nothing and only add the ones
that stop the compilation from failing or the code from running, one mod
at a time.
Some of your dependencies may fail to load because they are not fully
modular yet. Your options then are:
a) make your application non-modular, for now. This still works for most
things apart from Java FX. Doing non-modular FX is like urinating into a
stiff breeze.
b) use moditect to patch the non-modular dependencies, until modular
ones are available. It's a hack, but it works surprisingly well.
On 11/11/2023 15:42, Bradley Willcott wrote:
Hi John.
Check out this site:
https://www.digitalocean.com/community/tutorials/maven-dependency-tree-resolving-conflicts.
It should give you what you need to know.
Regards,
Brad.
On 11/11/23 06:20, John Manko wrote:
This might not be a purely Netbeans issue, but maybe NB has some
tooling to assist, or someone can answer a quick question.
I'm in the middle of converting Java 8 project to Java 17/21 (A
little late in the game, I know! I'm beholden to other forces beyond
my control.), and I have a library module with a module-info like such:
module com.my.lib {
requires com.google.common;
requires com.google.gson;
requires eclipselink;
requires jakarta.jakartaee.api;
requires java.logging;
requires java.sql;
requires jersey.client;
requires jersey.media.multipart;
requires org.apache.pdfbox;
requires org.apache.fontbox;
exports com.my.package;
}
I get the following error message in Netbeans:
module com.my.lib reads package jakarta.faces.context from both
jakarta.faces.api and jakarta.jakartaee.web.api
What am I'm doing wrong here? Is there any tooling in NB to help
create the module-info based on declared maven dependencies?
Below is are pom.xml deps (test deps removed):
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>4.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>3.1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>3.1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>