4

Here's my properties file:

version = ${maven.build.timestamp}

Here's how my pom.xml file looks like:

<properties>
    <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
<build>
    <plugins>
    ...
    </plugins>
    <resources>
        <resource>
            <directory>${project.basedir}/src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

And here's how my directory structure looks like:

.
├── pom.xml
├── src
│   └── main
│       ├── java
│       │   └── ...
│       ├── resources
│       │   └── application.properties

But when I do a mvn clean install and open up the target/classes/application.properties file, the contents of it is still the same: version = ${maven.build.timestamp}

Why isn't the property being properly replaced?

Ben
  • 193
  • 1
  • 11

1 Answers1

3

It's a known issue in Maven (see here). Simplest workaround is to redefine this property in your POM:

<properties>
    <maven.build.timestamp>${maven.build.timestamp}</maven.build.timestamp>
</properties>

Although this could generate an error in IDE like Eclpise it's still working as a maven build. Alternatively you could redefine this property with your own name to avoid IDE warnings.

S. Pauk
  • 5,208
  • 4
  • 31
  • 41