앞에서 mave timestamp 의 TimeZone 변경을 위해서 build-helper-maven-plugin 를 사용했는데 Eclipse 에서 다음과 같이 오류가 난다. 위 오류내용은 다음과 같다. Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin: 1.11:timestamp-property (execution: timestamp-property, phase: validate) Eclipse 는 오류를 표시했지만 maven 은 정상적으로 동작한다. 이는 Ecliplse 의 m2e 커넥터의 lifecycle mapping 정보를 명확하게 해야하는데 이것이 없어서 오류로 표시하는 것이다. 다음 URL 에 관련 내용이 있다. M2E_plugin_execution_not_covered 내용을 보면 <pluginManagement> 를 이용해서 lifecycle-mapping 을 설정해주어야 한다. 위 내용을 기반으로 build-helper-maven-plugin 의 execution 에 대해서 mapping […]
Maven timestamp 에 timezone 변경하기
maven 은 build timestamp 를 변수로 지원한다. 하지만 자세히 보면 이 timestamp 는 UTC timezone 에 맞춰져 있다. maven 에서 timestamp 는 기본적으로 UTC timezone 을 기반으로 한다. 그런데 이것을 다른 timezone 으로 변경할려면 어떻게 해야할까? build-helper-maven-plugin maven 에선 많은 plugin 을 지원한다. build-helper-maven-plugin 은 우리가 필요하는 기능인 timestamp 에 timezone 변경을 지원한다. 변경된 timezone 의 시간을 표시할 변수와 timestamp format, timezone 등을 지정하면 여기서 지정한 변수를 사용할 수 있게 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.11</version> <executions> <execution> <id>timestamp-property</id> <goals> <goal>timestamp-property</goal> </goals> <configuration> <name>current.time</name> <pattern>yyyyMMddHHmmss</pattern> <timeZone>Asia/Seoul</timeZone> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <warName>${project.artifactId}-${current.time}</warName> </configuration> </plugin> |
위와같이 current.time 변수에 한국시간의 timezone 으로 지정한 timestamp […]
war 파일이름에 TimeStamp 찍기
Maven 을 이용하면 자동으로 컴파일을 해주고 war 파일로 만들어 준다. 그런데, 이때에 war 파일에 TimeStamp 를 찍을 수 있다. war 파일명이 project.name-timestamp.war 형식으로 파일을 작성하도록 할수 있다. 방법도 대략 두가지 방법이 있다. maven 자체 기능 maven 3.0 이상이라면 자체 기능을 이용할 수 있다. properties 에 timestamp 와 maven.build.timestamp.format 을 지정하고 build 영역에서 파일명을 지정해주면 된다. 예를들면 다음과 같다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
... <properties> .... <!-- Timestamp of build --> <timestamp>${maven.build.timestamp}</timestamp> <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format> </properties> ... <build> <finalName>${project.artifactId}_${project.version}_${timestamp}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> .... </plugin> </plugins> </build> |
위와같이 설정하고 maven build 를 하면 다음과 같이 출력되는 것을 볼수가 있다.
1 2 3 4 5 6 7 8 9 |
[INFO] --- maven-war-plugin:2.2:war (default-war) @ mybatis_example1_trans --- [INFO] Packaging webapp [INFO] Assembling webapp [mybatis_example1_trans] in [/Users/systemv/Documents/workspace_java/mybatis_example1_trans/target/mybatis_example1_trans-2016070613147] [INFO] Processing war project [INFO] Copying webapp resources [/Users/systemv/Documents/workspace_java/mybatis_example1_trans/src/main/webapp] [INFO] Webapp assembled in [148 msecs] [INFO] Building war: /Users/systemv/Documents/workspace_java/mybatis_example1_trans/target/mybatis_example1_trans-2016070613147.war [INFO] WEB-INF/web.xml already added, skipping [INFO] |
maven-war-plugin 으로 war 파일명 지정 이것은 사실 위 […]