I am creating my custom-exception dependency which uses org.springframework.web as its dependency.
so I will be using custom-exception as dependency in a master-project which also has org.springframework.web as one of its dependency.
so my concern is how do i write pom.xml file for custom-exception so that I can include it in master-project without getting any conflicts.
Any extra information regarding dependency versioning and scope will be appreciated.
This is the first time I am creating maven dependency
Related
I am working on a maven project, there is a dependency in the pom added, but I don't know where it is used in the code, so if it is not used I want to delete it.
so how can I tell where this dependency is used?
note that the dependency I am mentioning is under
its name is maven-assembly-plugin
I have jackson-core-2.9.0 in the list of External Libraries, but I cant find where I added this lib in the project
You must understand how maven dependency works.
If you add any dependency to your pom.xml which is direct dependency to your project.
Then those direct dependencies have direct dependencies of their own and those dependencies have direct dependencies of their own and so on until there are no direct dependencies, these are called transitive dependencies of your project.
Use mvn dependency:tree to display all you your dependencies in tree structure to find which direct dependency has jackson-core-2.9.0 as dependency.
Note: more than one direct dependency can have jackson-core-2.9.0(or any other dependency) as dependency
i've encountered a weird dependency convergency error while maven-enforcer-plugin is complaining about dependency convergency error on my direct dependency.
For example:
A -- B:1.0
|
-- C:1.0
|
-- B:1.1
A is my project and i specify B:1.0 as A's direct dependency in A's pom file. However, A also depends on C:1.0, which has a transitive dependency on B:1.1. Now maven is complaining about convergency error on B:1.0 and B:1.1.
In my understanding, once i specified a direct dependency in the master pom, we will stick to the version all the way for our project?
In this example, it should be B:1.0 that will be used by the project.
Am i understanding it incorrectly?
Thanks
To resolve convergence Errors, put the chosen dependency version into <dependencyManagement>.
A direct dependency will not resolve this kind of error.
In my pom.xml ,even though i have not declared a dependency for commons logging and slf4j i can see them being automatically getting downloaded by maven.Is there a way to specify globally in pom.xml for the exclusion of these jars?
This is because your included a dependency in your pom.xml which is dependent on commons logging and sl4j. This is transitive dependency mechanism used by maven.
Go to Dependency Heirarchy Tab in eclipse to find out which dependency is downloading the logging dependencies.
Then you need use the <exclusions>{dependency}</exclusions> to exclude the dependency.
This maven page has good information on how to exclude transitive dependencies.
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).