Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
794 views
in Technique[技术] by (71.8m points)

maven 2 - Adding the current date with Maven2 filtering

I have a Maven2 project, and I need to add, in a properties file, the current version and the current date.

For the current version, I've used ${project.version}, which works correctly.

My question is how can I set the current date (i.e. the date when the build is done by Maven2) in my properties file:

client.version=Version ${project.version}
client.build=???

(in addition, if I can specify the format for the date, it will be really great)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Feature does not work with maven 2.2.1 resource filtering.

See: https://issues.apache.org/jira/browse/MRESOURCES-99

But you could create a custom property in the parent pom:

<properties>
    <maven.build.timestamp.format>yyMMdd_HHmm</maven.build.timestamp.format>
    <buildNumber>${maven.build.timestamp}</buildNumber>
</properties>

Where buildNumber is the new property that can be filtered into the resources.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...