[maven] type - pom

etc tools 2011.05.27 14:36

여러 개의 모듈로 나누어진 maven jar가 있다고 할 때, 여러 개의 모듈을 일일히 dependency를 거니까 상당히 귀찮아진다. 좀 간편하게 하기 위해서 만들어지는 것이 있다.

하나의 프로젝트만 걸고, 그 pom파일에서 정의된 파일만 받아오게 한다.  

ehcache가 대표적인 케이스이다.

http://repo1.maven.org/maven2/net/sf/ehcache/ehcache/2.4.2/
ehcache-2.4.2.pom 20-Apr-2011 15:13 5645 ehcache-2.4.2.pom.asc 20-Apr-2011 15:13 197 ehcache-2.4.2.pom.asc.md5 20-Apr-2011 15:13 32 ehcache-2.4.2.pom.asc.sha1 20-Apr-2011 15:13 40 ehcache-2.4.2.pom.md5 20-Apr-2011 15:13 32 ehcache-2.4.2.pom.sha1 20-Apr-2011 15:13 40

ehcache-2.4.2.pom 파일의 dependency는 다음과 같다. 여러개의 jar를 포함한다. 
<dependencies>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache-core.version}</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-terracotta</artifactId>
<version>${ehcache-terracotta.version}</version>
</dependency>
<!--Add concrete implementation to the assembly only-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>
<!--
Add sources and javadoc to the assembly. These are not classpath dependencies
-->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache-core.version}</version>
<classifier>javadoc</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache-core.version}</version>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>



http://repo1.maven.org/maven2/net/sf/ehcache/ehcache-core/2.4.2/

Index of /maven2/net/sf/ehcache/ehcache-core/2.4.2/


../
ehcache-core-2.4.2-javadoc.jar                     20-Apr-2011 14:47             3046399
ehcache-core-2.4.2-javadoc.jar.asc                 20-Apr-2011 14:47                 197
ehcache-core-2.4.2-javadoc.jar.asc.md5             20-Apr-2011 14:47                  32
ehcache-core-2.4.2-javadoc.jar.asc.sha1            20-Apr-2011 14:47                  40
ehcache-core-2.4.2-javadoc.jar.md5                 20-Apr-2011 14:47                  32
ehcache-core-2.4.2-javadoc.jar.sha1                20-Apr-2011 14:47                  40
ehcache-core-2.4.2-sources.jar                     20-Apr-2011 14:47              804606
ehcache-core-2.4.2-sources.jar.asc                 20-Apr-2011 14:47                 197
ehcache-core-2.4.2-sources.jar.asc.md5             20-Apr-2011 14:47                  32
ehcache-core-2.4.2-sources.jar.asc.sha1            20-Apr-2011 14:47                  40
ehcache-core-2.4.2-sources.jar.md5                 20-Apr-2011 14:47                  32
ehcache-core-2.4.2-sources.jar.sha1                20-Apr-2011 14:47                  40
ehcache-core-2.4.2.jar                             20-Apr-2011 14:47              989884
ehcache-core-2.4.2.jar.asc                         20-Apr-2011 14:47                 197
ehcache-core-2.4.2.jar.asc.md5                     20-Apr-2011 14:47                  32
ehcache-core-2.4.2.jar.asc.sha1                    20-Apr-2011 14:47                  40
ehcache-core-2.4.2.jar.md5                         20-Apr-2011 14:47                  32
ehcache-core-2.4.2.jar.sha1                        20-Apr-2011 14:47                  40
ehcache-core-2.4.2.pom                             20-Apr-2011 14:47               34428
ehcache-core-2.4.2.pom.asc                         20-Apr-2011 14:47                 197
ehcache-core-2.4.2.pom.asc.md5                     20-Apr-2011 14:47                  32
ehcache-core-2.4.2.pom.asc.sha1                    20-Apr-2011 14:47                  40
ehcache-core-2.4.2.pom.md5                         20-Apr-2011 14:47                  32 
ehcache-core-2.4.2.pom.sha1                        20-Apr-2011 14:47                  40
 

 

아래와 같이 사용하면 pom파일에서 정의된 모든 depdencency를 다운받을 수 있다.
 
<dependency>
<groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> <version>2.3.1</version> <type>pom</type> </dependency>

 만약 <type>pom</type>이 없으면, jar없다고 빌드에러가 뜨니. 잘 확인할 것.

=> 개발할 때, 이렇게 모듈처럼 개발하고, parent maven 프로젝트를 만드면 좋을 것 같음. 
Posted by 김용환 '김용환'