문제

Maven에서 필터링 할 수있는 자원을 복사 할 때 고유 한 스냅 샷 버전을 리소스 파일에 추가하려고합니다.

필터링을 활성화했습니다 :

...
<name>My Application</name>
<version>0.1-SNAPSHOT</version>
...
<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
      <filtering>true</filtering>
      ...
    </resource>
  </resources>
  ...
</build>
.

내 리소스 파일입니다.

application.name=${name}
application.Version=${version}
.

mvn resources:resources를 실행 한 후 결과입니다.

application.name=My Application
application.Version=0.1-SNAPSHOT
.

그러나 내가 실제로 원하는 것은 이것입니다 :

application.name=My Application
application.Version=0.1-20120310.143733-1
.

도움이 되었습니까?

해결책

Since version 2.1.0-M1, Maven supports special syntax to get build timestamp in pom.xml, check out the doc here:

<project>
  ...
  <properties>
    <maven.build.timestamp.format>yyyyMMdd.HHmmss</maven.build.timestamp.format>
  </properties>
  ...
</project>

Alternatively, you can use buildnumber-maven-plugin.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top