简体   繁体   English

如何定义superpom的路径?

[英]how to define path to superpom?

Any maven experts out there? 有任何行家专家吗? I inherited a huge maven project and am trying to get it to compile. 我继承了一个庞大的Maven项目,并试图使其进行编译。 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. 我转至最高一级的pom.xml,它位于主目录的下一级,位于主目录中。 Then I issue command "mvn validate". 然后我发出命令“ MVN验证”。 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? 我注意到一个与主项目处于同一级别的vsd-superpom文件夹,因此我猜主项目需要指向某个地方? Looking at the pom.xml I see 看一下pom.xml我看到了

<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? 我将vsd-superpom文件夹放在哪里,以便找到它? I don't understand why it tries to download it. 我不明白为什么要尝试下载它。 I don't see anything in pom.xml that tells it to do that. 我在pom.xml中看不到任何指示它执行此操作的操作。

Apache Maven has a two level strategy to resolve and distribute files, which we call artifacts. Apache Maven有两级策略来解析和分发文件,我们称其为工件。 The first level is called the local repository, which is the artifact cache on your system, by default located at ${user.home}/.m2/repository. 第一级称为本地存储库,它是系统上的工件缓存,默认情况下位于$ {user.home} /。m2 / repository。 When executing Maven, it'll first look in this local cache for artifacts. 执行Maven时,它将首先在此本地缓存中查找工件。 If the artifact cannot be found here, Maven will access the remote repositories to find the artifact. 如果无法在此处找到工件,则Maven将访问远程存储库以找到工件。 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 请参阅Apache Maven安装插件文档

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. 因此,如果您的超级pom独立于项目的其余部分,则可以直接从超级pom文件夹调用mvn install ,以便将其放置在本地存储库中。 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 | ... 通常,顶级项目pom定义项目依赖项,并且足以调用mvn verify | compile | ... 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) 如果顶级pom依赖于super pom,则必须首先安装super pom(或定义一个pom,其中包含submodules super pom和项目的其余部分)

Common project structure what I have seen (and used) is: 我已经看到(并使用)的常见项目结构是:

  • foo-parent 富父母
    • pom.xml - parent POM for my modules with parent ../pom.xml pom.xml -我与父母模块父POM ../pom.xml
  • foo-module foo模块
    • pom.xml - module POM with parent ../foo-parent/pom.xml pom.xml -模块POM与父母../foo-parent/pom.xml
  • ...other modules... ...其他模块...
  • pom.xml - multimodule POM without a parent pom.xml没有父级的多模块POM

Now if I want to build foo-module I need to be in the top-level folder and run: 现在,如果我要构建foo-module ,则需要进入顶层文件夹并运行:

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 ). 但是,您可以指定仅对某些子模块( -pl )及其依赖项( -am-am

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM