Netbeans: maven dependencies of type pom

10,669

Solution 1

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

Solution 2

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.

Share:
10,669

Related videos on Youtube

Uko
Author by

Uko

I'm a software developer / computer science researcher who just loves everything related to the software engineering. Although I'm continuously learning something new and different, my main field of interest is software evolution. I know key concepts of oop, tdd, bdd, java, eclipse, c, ruby… But my main question remains the same: „How do you create a living system that is going to evolve and not begin dying slowly after the release (or even before)?“

Updated on June 17, 2022

Comments

  • Uko
    Uko about 2 years

    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>
    
    • rlegendi
      rlegendi
      Doesn't removing the <type>pom</type> line solves the issue?
  • Uko
    Uko over 11 years
    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
  • Andrew Logvinov
    Andrew Logvinov over 11 years
    @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 B
    Andrew B about 10 years
    In the maven book, they recommend grouping common dependencies in a pom - books.sonatype.com/mvnref-book/reference/…
  • Big Kahuna
    Big Kahuna over 7 years
    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.