Vinod Sidiginamale
Vinod Sidiginamale

Reputation: 241

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

Upvotes: 6

Views: 4777

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35843

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.

Upvotes: 1

Related Questions