简体   繁体   English

maven读取包含多个模块的pom.xml并写入文件

[英]maven read pom.xml containing multiple modules and write file

We have "master" pom.xml file and has multiple modules, using maven-antrun-plugin or other plugin, how do we be able to achieve by means of writing a file to all module folders in this master pom.xml?我们有“master”pom.xml文件并且有多个模块,使用maven-antrun-plugin或其他插件,我们如何能够通过将文件写入这个master pom.xml中的所有模块文件夹来实现? Want to store a file containing "${project.version}".想要存储包含“${project.version}”的文件。 For instance, we run mvn clean verify , we want to retrieve the version from this master pom.xml and store as file to all multiple modules.例如,我们运行mvn clean verify ,我们想从这个主 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mp</groupId>
<artifactId>parentApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parentApp</name>
<description>This is just to test pom inheritance</description>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
        <module>../example1</module>
        <module>../example2</module>
        <module>../example3</module>
        <module>../example4</module>
        <module>../example5</module>
..
..

Never mind - we can add exec-maven-plugin to run the bash script to list all multiple modules, for loop - copy the folder to all modules.没关系 - 我们可以添加exec-maven-plugin来运行 bash 脚本以列出所有多个模块,for 循环 - 将文件夹复制到所有模块。

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

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