【问题标题】:Defining a custom list of files in pom.xml在 pom.xml 中定义自定义文件列表
【发布时间】:2018-12-17 11:12:10
【问题描述】:

我有一个 pom.xml,它充当子 pom 层次结构的根 POM,每个子 pom 负责部署它自己的相应二进制工件。

我最初想让根 POM 存储这些子 POM 的列表,以便我可以对子 POM 进行一些预处理/后处理。这是房间 pom.xml 的示例:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>company.group1.project1</groupId>
<artifactId>assets</artifactId>
<version>0.4.1</version>
<packaging>pom</packaging>

<parent>
    <groupId>company.shared</groupId>
    <artifactId>repo-info-pom</artifactId>
    <version>1.0.0</version>
</parent>

<deployArtifacts exportType="bin" srcType="txt">
    <artifacts>
        <artifact>
            <artifactId>assetA</artifactId>
            <groupId>company.group1.project1.assets</groupId>
            <version>0.4.1</version>
            <fileFolder>./assetA/</fileFolder>
        </artifact>
        <artifact>
            <artifactId>assetB</artifactId>
            <groupId>company.group1.project1.assets</groupId>
            <version>0.4.1</version>
            <fileFolder>./anotherFolder/assetB</fileFolder>
        </artifact>
            <artifact>
            <artifactId>assetC</artifactId>
            <groupId>company.group1.project1.assets</groupId>
            <version>0.4.1</version>
            <fileFolder>./yet/another/folder/assetC</fileFolder>
        </artifact>
    </artifacts>
</deployArtifacts>

</project>

当然,POM 有自己的 XSD,它拒绝自定义标签,如果我尝试使用它,会出现“格式错误的 POM”错误。

对于我一直在研究的替代方案:

  1. 标签不允许我添加目录信息,除非它是 for when is system,我认为我不应该使用它,因为我确实希望根 POM 也能够引用最终来自存储库的工件。

  2. 该列表仅引用本地项目中的工件,似乎不允许我附加诸如 groupID 或版本号之类的信息。

  3. 作为最后的手段,我正在考虑从根 pom.xml 中删除列表,将其移动到另一个 xml,并让根 pom.xml 将这个新 xml 作为另一个工件与 build-helper -maven 插件。

这是我第一次设置和配置 Maven,所以我想知道还有哪些其他可行的选项。提前感谢您的任何反馈。

【问题讨论】:

    标签: xml maven pom.xml nexus


    【解决方案1】:

    看看https://maven.apache.org/pom.html#Aggregation 似乎符合您的要求。这将使从根目录执行 Maven 并构建/部署其所有子级成为可能。

    【讨论】:

      猜你喜欢
      • 2017-08-08
      • 2012-08-19
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      相关资源
      最近更新 更多