'replacer'에 해당되는 글 1건

  1. 2016.10.07 [Maven] maven-replacer-plugin 사용하기.

[Maven] maven-replacer-plugin 사용하기.

ITWeb/개발일반 2016. 10. 7. 14:54

간혹 필요할때가 있어서 포스팅 합니다.

maven project 를 사용하면서 소스코드에서 특정 변수에 대한 치환을 하고 싶을 때 사용하시면 됩니다.

최근에 javascript 파일에 대한 v=@_FINGERPRINT 정보를 추가 하기 위해 사용했습니다.


[참고문서]

https://github.com/beiliubei/maven-replacer-plugin/wiki/Usage-Guide

https://gist.github.com/ekcode/a338ec66c81bcaca1d9d


[pom.xml]

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>front-web-service-${version}</warName>
</configuration>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<filesToInclude>
**/layout.jsp
</filesToInclude>
<replacements>
<replacement>
<token>@_FINGERPRINT</token>
<value>${version}</value>
</replacement>
</replacements>
</configuration>
</plugin>


역시 구글링 하면 많은 예제 코드들이 나옵니다.

: