I would like to write out build informations to a property file. I have found Maven resource filtering plugin. And this is how my pom relevant part looks like:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>project.mygroup</groupId>
<artifactId>prject</artifactId>
<version>1.0-20190130-1</version>
</parent>
<artifactId>project-war</artifactId>
<packaging>war</packaging>
<version>1.0-20190130-1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>
yyy-MM-dd HH:mm
</maven.build.timestamp.format>
</properties>
<dependencies>
...
</dependencies>
<build>
<finalName>project</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- Create war from the project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
If start mvn clean package
the build is success, but my build.properties
file under src/main/resources will not contain the build informations.
My property file looks like this:
build.version=${pom.version}
build.date=${timestamp}
build.url=${pom.url}
build.name=${pom.name}
What am I doing wrong? Thank you!