Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop scanning transitive dependencies #208

Open
hgschmie opened this issue Aug 15, 2023 · 2 comments
Open

drop scanning transitive dependencies #208

hgschmie opened this issue Aug 15, 2023 · 2 comments

Comments

@hgschmie
Copy link

Hi,

I have a project which uses a dependency (let's call it otj-pg-embedded for now) which does not use any module info. I want to add this to the plugin (so when it scans my dependencies, it correctly generates the line requires transitive otj.pg.embedded; in my module-info.

However, the dependency tree of that module is a mess. Mainly there is testcontainers hanging off it and scanning those jars results in:

Modules postgresql and jdbc export package org.testcontainers.containers to module org.apache.commons.compress (both of those are badly named testcontainers automatic modules).

In my list of deps in the pom, the test container deps are not listed at all. So I have to do "mvn dependency:tree" in the repo, find the offenders and add them to the exclusion list. This seems inefficient. It would be good to have some option in the pom, e.g.

<configuration>
    <ignoreTransitive>com.opentable.components:otj-pg-embedded</ignoreTransitive>
</configuration>

which allows me to keep the otj-pg-embedded thing on the module path for jdeps but drop everything that hangs off it:

[INFO] +- com.opentable.components:otj-pg-embedded:jar:1.0.1:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.13.0:compile
[INFO] |  +- org.testcontainers:postgresql:jar:1.18.3:compile
[INFO] |  |  \- org.testcontainers:jdbc:jar:1.18.3:compile
[INFO] |  |     \- org.testcontainers:database-commons:jar:1.18.3:compile
[INFO] |  +- org.testcontainers:testcontainers:jar:1.18.3:compile
[INFO] |  |  +- org.apache.commons:commons-compress:jar:1.23.0:compile
[INFO] |  |  +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:compile
[INFO] |  |  |  \- org.jetbrains:annotations:jar:24.0.1:provided
[INFO] |  |  +- com.github.docker-java:docker-java-api:jar:3.3.0:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.7:compile
[INFO] |  |  \- com.github.docker-java:docker-java-transport-zerodep:jar:3.3.0:compile
[INFO] |  |     +- com.github.docker-java:docker-java-transport:jar:3.3.0:compile
[INFO] |  |     \- net.java.dev.jna:jna:jar:5.12.1:compile
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.36:runtime

(obviously unless it gets pulled in through some other context).

The current workaround is cumbersome and prone to break when versions change.

@dwhitla
Copy link

dwhitla commented Oct 9, 2023

I am looking into this on a fork.I propose that moditect not traverse dependencies marked as optional which are not in the dependency graph of the current maven project as this is the situation which most often causes the bug behaviour as well as generating requires for distant dependencies not atually required to either compile or run the resulting code.
The change to implement this will also fix #191, #159 and #122.

@dwhitla
Copy link

dwhitla commented Oct 9, 2023

From the source it seems #191 has already been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants