티스토리 뷰

hacking/java

MavenNative2asciiPlugin

iolo 2005. 10. 20. 20:53
?Apache~Maven이 버전2로 오면서 많이 깔끔(?)해졌다. 특히 누더기처럼 지저분하던 gelly가 사라진건 좋은데... 그게 없으면 해결 곤란한 것들이 꽤 있다는 것이 현실적인 문제.

그 중의 하나가... ?Apache~Ant의 도움을 받아야 하는 경우다.

지금 얘기하는 것은 ant의 수많은 타스크 중에서 native2ascii라는 녀석인데, 그 동안은(2.0정식이 나오기 전까지는) maven2팀에서 해결해줄지도 모른다는 기대를 갖고, ant-nodeps에 의존성을 걸고 maven-antrun-plugin을 돌리는 지저분한 방법으로 대충 해결했었다.

<project>
...
        <dependencies>
...
                <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-nodeps</artifactId>
                        <version>1.6.5</version>
                        <scope>compile</scope>
                </dependency>
        </dependencies>
        <build>
...
                <plugins>
...
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <phase>process-resources</phase>
                                                <configuration>
                                                        <tasks>
                                                                <taskdef name="native2ascii"
                                                                        classname="org.apache.tools.ant.taskdefs.optional.Native2Ascii"
                                                                        classpathref="maven.compile.classpath" />

                                                                <delete>
                                                                        <fileset dir="target/classes"
                                                                                includes="**/*.properties" />

                                                                </delete>
                                                                <native2ascii encoding="utf-8"
                                                                        src="src/main/resources" dest="target/classes"
                                                                        includes="**/*.properties" ext=".properties" />

                                                        </tasks>
                                                </configuration>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
 

그런데 오늘 정식 릴리즈된 2.0에도 native2ascii에 대한 아무런 지원이 없음을 확인하고, 공부삼아 대충 플러그인을 하나 만들어 보았다. 이름하여, maven-native2ascii-plugin이다. 쓰는 법은 대충 이렇게 해두면 process-resouces 페이즈에서 native2ascii 변환을 수행한다.

<project>
...
    <build>
...
            <plugin>
                <groupId>com.iowise.maven.plugin</groupId>
                <artifactId>maven-native2ascii-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <reverse>false</reverse>
                            <ext>.properties</ext>
                        </configuration>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
 

흠... 별로 더 간단해지지는 않았지만 :-S 최소한 빌드 타임 라이브러리인 ant-nodeps에 런타임 의존성이 걸리는 일은 피할 수 있다. :-P

'hacking > java' 카테고리의 다른 글

neat flash demo java studio creater  (0) 2005.11.22
swap two variable without using a temporary variable  (0) 2005.10.30
license to cache  (0) 2005.10.05
Java 5.0의 typesafe enum  (0) 2004.07.09
이번엔 Java 5?  (0) 2004.06.29
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
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 27
28 29 30
글 보관함