fabric8io / vertx-maven-plugin

Vert.x Maven Plugin - moved to https://github.com/reactiverse/vertx-maven-plugin
https://github.com/reactiverse/vertx-maven-plugin
Apache License 2.0
25 stars 5 forks source link

Some dependencies are not being included in the fat-jar when using vertx:package #144

Closed InfoSec812 closed 6 years ago

InfoSec812 commented 6 years ago

I wrote a small module to provide a custom implementation of Launcher and I want to use it across a group of related applications. The Launcher library has dependencies on vertx-hawkular-metrics, vertx-infinispan, and jgroups-kubernetes. Unfortunately, when I include that library as a dependency in a project via Maven, the vertx:package target does not include vertx-hawkular, vertx-infinispan, or jgroups-kubernetnes in the resultant fat-jar. Any assistance would be greatly appreciated.

cescoffier commented 6 years ago

Can you provide a reproducer? only dependencies from the compile scope are embedded.

InfoSec812 commented 6 years ago

This is the project I am working on: https://github.com/InfoSec812/rhoar-vertx/tree/implement-clustering

Here's what I have been doing from the root of the parent project

mvn clean package install -pl clustered-launcher -DskipTests # Skipping tests to save time
mvn clean package vertx:package -pl noun,adjective,insult,ui -DskipTests
java -jar adjective/target/adjective-1.0.0-SNAPSHOT.jar -Djava.net.preferIPv4Stack=true

And the output I get is:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: io/vertx/ext/hawkular/VertxHawkularOptions
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: io.vertx.ext.hawkular.VertxHawkularOptions
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
InfoSec812 commented 6 years ago

Something interesting I just noticed... In IntelliJ's Maven project panel I see: image But when I run mvn -B dependency:tree the transitive dependencies from my library are not showing up!!!

InfoSec812 commented 6 years ago

Made some progress, but I'm not sure why it's behaving the way that it is... IF I move the jgroups dependency to the parent pom's dependencyManagement section, it seems to resolve the problem. Could just be some weirdness with Plexus module resolution, but I don't know how to prove/disprove that.

cescoffier commented 6 years ago

Yes, it's a maven visibility issues / bugs. The dependency is filtered out.

I've tried your project and it works, did you fix it already?

cescoffier commented 6 years ago

BTW, I've copied the issue to: https://github.com/reactiverse/vertx-maven-plugin/issues/17 where the development of the plugin will continue.

InfoSec812 commented 6 years ago

Yes, I changed how the dependencies were being included from the parent-POM perspective. It's a workaround, but less than ideal.

Deven

On Tue, May 1, 2018 at 6:03 AM, Clement Escoffier notifications@github.com wrote:

Yes, it's a maven visibility issues / bugs. The dependency is filtered out.

I've tried your project and it works, did you fix it already?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fabric8io/vertx-maven-plugin/issues/144#issuecomment-385638544, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGFa3qomtvPTW__LSsmBpmfzBeMHc2Lks5tuDL-gaJpZM4TikE8 .

--

Deven Phillips

Senior Consulting ENgineer, RED HAT OPEN INNOVATION LABS

Red Hat

https://www.redhat.com/

deven.phillips@redhat.com https://red.ht/sig

cescoffier commented 6 years ago

The plugin now has an archive parameter that allows fine-tuning of the content of the jar. You can configure dependency sets that would include/exclude dependencies.

cescoffier commented 6 years ago

Closed by https://github.com/reactiverse/vertx-maven-plugin/issues/17