Maven variables substitution in resource files during maven build

POM Resource directive
In the project pom.xml, enclosed within the build section, is a resource declaration which switches on variable substitution of configuration text files during maven build. Where
  • enabling filtering will turn on variable substitution of application properties
  • specified resource directory need not (and preferably not) be part of the source classpath, because the <resource> directive will have maven build process recreate the files in the specified directory into the run-time packaging classpath.

<build>
  .....   
  <resources>
    <resource>
      <directory>appbase</directory>
      <filtering>true</filtering>
    </resource>
  </resources>
  
  ..... 
  
</build>

Variable substitution can also use pom objects and implicit maven properties. e.g.,
  • ${project.name}
  • ${project.version}
  • ${project.packaging}
  • ${project.build.sourceDirectory}
  • ${project.build.scriptSourceDirectory}
  • ${project.build.directory}
  • ${project.baseUri} 
  • ${env.PATH}
  • ${env.HOME}
  • ${env.JAVA_HOME}
  • ${env.M2_HOME}

A more complete list is documented in the following link:
http://books.sonatype.com/mvnref-book/reference/resource-filtering-sect-properties.html

1 comment:

  1. Operators often problem app updates that include new options, together with bug and safety fixes. While some would require you to make use casino.edu.kg of the latest model of the app, some won't. However, regardless of whether you might be} required to, it's all the time a good suggestion to maintain apps updated to keep away from potential exploits. SI Sportsbook first made its highly-anticipated debut within the state of Colorado in 2021 and has since joined only one other state, launching in Virginia on May 26, 2022. Despite its sluggish rollout, the corporate has announced plans to ultimately convey their product to Indiana, Iowa, and New Jersey as nicely.

    ReplyDelete