Impact of exclusion in the context of jar packaging(simple/fat jar using shade plugin). What i mean here, how can it be verified by extracting the jar.
When a dependency is excluded, it is removed from the dependency tree at that point. You can check this with mvn dependency:tree. It might still come in through other ways (e.g. as transitive dependency of some other dependency). You can check that with mvn dependency:list.
Related
We have splunk-library-javalogging as compile-dependency and added com.squareup.okhttp3/okhttp as a test-dependency. okhttp is also a compile-dependency of the splunk-appender.
Using spring-boot-maven-plugin we realized the okhttp-Dependency is no longer included, when added as a test-dependency. Removing it, it is included again.
So it seems scoping okhttp as test overrides the transitive compile-dependency (excluding it from the jar) - and this doesn't feel correct!?
This does not feel correct, but it is unfortunately the case.
Maven determines the scopes first, then creates the classpaths. And direct dependencies override transitive ones.
It would be smarter to create the compile classpath by just ignoring test scoped dependency entries, but this is not how Maven does it.
Quintessence: Only add a test dependency if the dependency is not already in mvn dependency:list.
I have a simple pom.xml which have only JUnit dependency and exec-maven-plugin.
But when I say "mvn install" I see lot of dependencies downloading.
Are this mandatory dependencies by maven?
I am listing a few here :
ClassWorlds
Commons-logging-api
log4j
backport-util-concurrent
Are this mandatory dependencies by maven
Yes, those are transitive dependencies.
This allows you to avoid needing to discover and specify the libraries that your own dependencies require, and including them automatically
See "Resolving conflicts using the dependency tree"
A project's dependency tree can be expanded to display dependency conflicts. For example, to find out why Commons Collections 2.0 is being used by the Maven Dependency Plugin, we can execute the following in the project's directory:
mvn dependency:tree -Dverbose -Dincludes=commons-collections
Is there a maven command using which I could find out list of all bundles who directly or transitively depend on a given bundle?
mvn dependency:tree
should give you that
Apache Velocity needs commons-collections-3.2.1.
In my pom file I have added a velocity dependency. Everything works, but when I look in the overall pom file:
$ mvn help:effective-pom
I do not see an commons-collections entry.
I had expected it should be there. Or not?
No, not if you don't specify it directly. effective-pom shows the pomfile factored in with the eventually inherited definitions from the parent pom (ie. dependencyManagement, pluginManagement, properties and so on) and the profile.
To see the full list of dependencies, including transitive dependencies, you need maven-dependency-plugin, and
mvn dependency:tree
The effective-pom does not show you all the transitive dependencies, only the POM as it will be, given whatever parents, profiles etc. you have.
You may want to try mvn dependency:tree, which will show you the projects' direct and transitive dependencies as a tree, and notice that commons-collections will be somewhere under Velocity.
Cheers,
I've spent a lot of time and my head is blowing up already so I'll be very thankful for any help.
I'm migrating Netbeans Platform application from ant to maven, and so I'm changing all the jars in my version control repo to maven dependencies. I've found needed artifact in main maven repo and I've added it as a dependency with a help of Netbeans, but it's of type POM and was placed in Non-classpath Dependencies and I have no idea how to use it as it wasn't added to classpath etc…
Can someone explain what are these POM dependencies and how to use them?
Thank you in advance!!
EDIT
here is dependency definition in pom.xml
<dependency>
<groupId>com.kitfox.svg</groupId>
<artifactId>svg-salamander</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
Adding a pom dependency only pulls down transitive dependencies, that is jar dependencies defined as dependencies in the pom. The pom does not get added on the classpath for obvious reasons, but the transitive dependencies reachable from pom will be added to classpath.
What you ideally need to do is have dependencies of type jar Default dependency type is jar and you can simply define dependencies without any type element in the dependency section.
If you have located the jar files you need in Maven Cental, then you simply need to provide groupId artifactId and version for each one of those in dependencies section.
Personally I cannot think of any case when one would need to add pom type dependency. I usually use pom packaging for parent module in a project (specify common project configuration like plugin versions, common dependencies, like log4j for example, repositories, properties etc.) and for utility package module (the one that assembles the project and does some other necessary things).
Judging from my experience (I did it several times), when migrating project from ant to maven you should take all the jar files that your project used to depend on and convert them into maven dependencies (groupId:artifactId:version). Most probably all of these dependencies will not have any <type> (e.g. be jars).