How does a jar pull transitive dependencies in Maven? - maven

I am buliding small Spring Boot app - pacakged as jar file (I'm using maven plugins).
I know that there are solutions which allow me to build jar file with all desired dependecies (e.g. maven assembly plugin).
The question is what if I don't pack maven required depedencies using those solutions? Am I correct that I will always get "NoClassDefFoundError" ? So should I always pack my project with all depedencies into jar file or there is another solution to "makes thigns work"?

Related

Update Maven Dependencies Jars

I am new to Maven and have a quick question. I am using the JBoss IDE and have my Maven project set up. I have several jar files in my Maven Dependencies build path that need to be updated to a newer version. I have tried adding the external jars manually, but they do not go within the Maven Dependencies library and the outdated jar remains within that library.
What is the best way to update the jars with the Maven Dependencies library?

Does maven care about file names?

I am trying to install some dependencies using maven in a spring boot project.
I am looking for a jar
org.apache.maven.plugins:maven-resources-plugin:jar:3.1.0
But I wanna know if the jar file should have this name maven-resources-plugin, or if the file name is not important for maven. I mean if maven will automatically know which jar file should use.
I will appreciate any help or feedback.
That is a plugin, not a dependency as such (meaning that Maven needs it for building your project, your code doesn't need it to compile or run).
You should only have to specify the plugins groupId, artifactId and version plus any configuration in your pom.xml, and Maven knows exactly what jar to get and how to use it.
See https://maven.apache.org/plugins/maven-resources-plugin/plugin-info.html for further information.

How to run Maven Javadoc in a project with pom packaging?

I have a project that packages the delivery of a software using the assembly plugin. The packaging of the project is pom.
To make a nicer documentation i am using the dependency plugin to download the sources of the different projects and then using the javadoc plugin to generate a new documentation that merges the javadoc for the different projects into one.
The issue I am having is that maven javadoc will not run if the packaging is pom.
It complains with the message: Not executing Javadoc as the project is not a Java classpath-capable package
However, if I put packaging jar it works. Unfortunately then an empty unwanted jar file is generated.
Is there a way to get the maven javadoc to run with packaging pom?
Cheers,
Javi
The workaround I have found was to set the packaging in the pom to jar and prevent maven jar plugin to generate the jar.

Way to include pom.xml with runtime dependencies within a gradle built and published jar

Is there a simple way to have gradle automatically generated a pom file listing the jar dependencies (both to published jars of other sibling projects and external) and have it included in the jar and published to a maven repo?
There is a lot of documentation on this subject but I am either missing something or it is as complicated as it seems. Can this not be done automatically?

Building/deploying a EJB .jar with its dependencies

I am new to Java EE. I use Maven, Eclipse and jBoss/WildFly.
I have a war project. When I build the project all its dependencies are packaged inside the war file in WEB-INF/lib.
Now I am trying to create a ejb project (I have <packaging>ejb</packaging> in the pom.xml). I want to deploy it as a separate project (not as a part of the war). When I build the ejb project Maven does not package any dependencies in the jar.
How can I package/deploy a ejb .jar with its dependencies?
UPDATE: I'd like to avoid packaging EJBs in an .ear if it is possible. (I do not want to create one more Maven project).
The best solution is package your project as ear. But if don't want use ear, maven assembly plugin can help you to package all needed jars in one file. This solution is only for "proof of concept" variant, and cannot be used in production mode, by licences limitation for example.

Resources