bytedeco/javacv

How to exclude unnecessary JavaCV modules from the dependencies of a modular (JPMS) project?

Open

#2323 opened on Mar 11, 2025

View on GitHub
 (4 comments) (0 reactions) (1 assignee)Java (6,985 stars) (1,583 forks)batch import
enhancementhelp wantedquestion

Description

Non-modular (non-JPMS) project

My non-modular (i.e., non-JPMS) project consumes JavaCV for video frame extraction, so it requires essentially the ffmpeg module only. Therefore, its maven configuration (pom.xml) excludes any unnecessary artifact from dependencies (for the sake of simplicity, here it is listed only tesseract):

<dependency>
  <groupId>org.bytedeco</groupId>
  <artifactId>javacv</artifactId>
  <version>1.5.11</version>
  <exclusions>
    . . .
    <exclusion>
      <groupId>org.bytedeco</groupId>
      <artifactId>tesseract</artifactId>
    </exclusion>
    . . .
  </exclusions>
</dependency>

So far, so good: all works as expected in non-modular definition.

Modular (JPMS) project

Now I'm moving my project to modular (JPMS) definition, adding to module-info.java the corresponding JavaCV dependency:

module mymodule {
  . . .
  requires org.bytedeco.javacv;
  . . .
}

As I run maven for testing, the surefire plugin miserably fails with an ERROR:

 java.lang.module.FindException: Module org.bytedeco.tesseract not found, required by org.bytedeco.javacv

If I remove the dependency exclusions from my maven configuration, surefire is obviously happy:

<dependency>
  <groupId>org.bytedeco</groupId>
  <artifactId>javacv</artifactId>
  <version>1.5.11</version>
</dependency>

The problem now is that I don't want to bloat my deployments with unnecessary JavaCV modules: how can I exclude those unnecessary JavaCV modules from the maven dependencies of my modular project?

Contributor guide