Netbeans: maven dependencies of type pom

2020-02-26 06:05发布

问题:

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>

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



回答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.