简体   繁体   中英

How to get the module name from pom in java

I have a requirement in which based on module names, I need to do some operations. How to fetch the modules name from pom.xml in a java class. My pom.xml has like below :

<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>


<modules>
        <module>name1</module>
        <module>name2</module>    
</modules>

I saw we can get artifactId and version as below from a property file. Here module is a list how to get the modules names from the list. Any help would be appreciated.

version=${project.version}
artifactId=${project.artifactId}

Thanks

You could

  • Define the names as Maven properties.
  • Define a text file in resources which uses these properties.
  • Process this resource file with Maven.
  • Read from the resource file in your jar/war.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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