how to define path to superpom?

246 Views Asked by At

Any maven experts out there? I inherited a huge maven project and am trying to get it to compile. Not getting very far. I go to the highest level pom.xml I can find, located in trunk directory, one level down from the main project. Then I issue command "mvn validate". Get the following error:

[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/com/mycompany/neto/vsd/vsd-superpom/1.1.0/vsd-superpom-1.1.0.pom
[INFO] Unable to find resource 'com.mycompany.neto.vsd:vsd-superpom:pom:1.1.0' in repository central (http://repo1.maven.org/maven2)

I noticed a vsd-superpom folder at the same level as the main project so I'm guessing the main project needs to point to it somewhere? Looking at the pom.xml I see

<parent>
    <groupId>com.mycompany.neto.vsd</groupId>
    <artifactId>vsd-superpom</artifactId>
    <version>1.1.0</version>
</parent>

Where do I put the vsd-superpom folder so that it will be found? I don't understand why it tries to download it. I don't see anything in pom.xml that tells it to do that.

2

There are 2 best solutions below

2
On BEST ANSWER

Apache Maven has a two level strategy to resolve and distribute files, which we call artifacts. The first level is called the local repository, which is the artifact cache on your system, by default located at ${user.home}/.m2/repository. When executing Maven, it'll first look in this local cache for artifacts. If the artifact cannot be found here, Maven will access the remote repositories to find the artifact. Once found it will be stored into the local repository, so it's be available for current and future usage.

see Apache Maven Install Plugin Documentation

So if your super pom is independent of the rest of the project you can simply invoke mvn install from the super pom folder so that it will be placed into your local repository. That will solve your problem.

Usually the top-level project pom defines the project dependencies and it should be enough to invoke mvn verify | compile | ...

If the top-level pom depends on the super pom that you have to install the super pom first (or define a pom that contains the submodules super pom and rest of the project)

0
On

Common project structure what I have seen (and used) is:

  • foo-parent
    • pom.xml - parent POM for my modules with parent ../pom.xml
  • foo-module
    • pom.xml - module POM with parent ../foo-parent/pom.xml
  • ...other modules...
  • pom.xml - multimodule POM without a parent

Now if I want to build foo-module I need to be in the top-level folder and run:

mvn -pl foo-module -am package

In other words you are always building the multi-module project. However you can specify that you are interested only in some submodules (-pl) and their dependencies (-am).