15

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>
Uko
  • 13,134
  • 6
  • 58
  • 106
  • 1
    Doesn't removing the `pom` line solves the issue? – rlegendi Oct 13 '12 at 10:50
  • @rlegendi when removed `pom` the result was: `Could not transfer artifact com.kitfox.svg:svg-salamander:jar:1.0 from/to junit_4 (http://repo1.maven.org/maven2/): No connector available to access repository junit_4 (http://repo1.maven.org/maven2/) of type test using the available factories WagonRepositoryConnectorFactory -> [Help 1]` – Uko Oct 13 '12 at 12:01

2 Answers2

16

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.

Kalpak Gadre
  • 6,285
  • 2
  • 24
  • 30
3

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).

Andrew Logvinov
  • 21,181
  • 6
  • 52
  • 54
  • Maybe I was misguided. Because I was adding this dependency by search feature in NetBeans and was only given an option to add dependency of type `pom` – Uko Oct 13 '12 at 19:56
  • @Uko I see. In any case, I wouldn't recommend adding `pom` type dependency. You should declare all the libs that your project depends on explicitly. – Andrew Logvinov Oct 14 '12 at 08:23
  • 2
    In the maven book, they recommend grouping common dependencies in a pom - http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html – Andrew B Jun 13 '14 at 10:23
  • I think there is a use case or using pom dependency. You can add common dependencies by composition rather than having to add them via a common parent POM i.e. inheritance. In my personal experience, sometimes the parent POM cannot be changed, so one has to artificially add an intermediary POM to allow common dependencies. That solution is messy and can be replaced by having common dependencies in an arbitrary POM and then including that as a dependency in your POM of choice with a a dependency type of pom. As mentioned before, the inclusion of POM means all transitive dependencies loaded. – Big Kahuna Jan 25 '17 at 12:27