Search code examples
xmlspring-bootmavenmaven-plugindependency-properties

Read properties from .properties file present on internet in project's .xml file [NOT in POM file] to update version of module


I have one .properties file present on the internet/online (you can say it's an external file). I want to read the properties (versions) from it to update the modules' versions in my .XML file. I searched about the PropertyPlaceholderConfigurer, but it is deprecated. Is there any other way for this?

Properties file:

github.dd-core=6.5.2

XML file:

<modules>
  <module>
      <name>dd-core-6.5.2</name>
      <artifactid>com.dd-core</artifactid>
      <version>6.5.2</version>
  </module>
</modules>

Expected Result: In version tag, instead of 6.5.2 I want to use property github.dd-core to update the version at runtime/dynamically. Thank you.


Solution

  • Did you try the solutions offered here? PropertyPlaceHolderConfigurer Alternative

    Otherwise you can perhaps look into the properties plugin, it claims to do a similar thing: https://www.mojohaus.org/properties-maven-plugin/index.html

    The properties loaded from files or URLs can be used to filter resources differently for different environments. Those using Spring's PropertyPlaceholderConfigurer can see how these goals can be useful. Note that the URL format accepts Spring's classpath: style pseudo-URL syntax.

    Specifically: https://www.mojohaus.org/properties-maven-plugin/read-project-properties-mojo.html

    The read-project-properties goal reads property files and URLs and stores the properties as project properties. It serves as an alternate to specifying properties in pom.xml. It is especially useful when making properties defined in a runtime resource available at build time.