재성이가 보내준 메이븐 책을 읽다가 예전에 생각만 하고 실행에 옮기지 못했던 일이 하나 떠올랐다.  pom.xml 파일의 작성 방식을 바꾸는 일이다.

메이븐의 pom.xml을 직접 다뤄본 경험이 있는 사람이라면 의존 라이브러리가 늘어나고 플러그인 설정이 복잡해지면서 급격하게 양이 증가하는 pom.xml 파일에 당황해본 경험이 있을 것이다. 메이븐의 기본 관례와 페이즈를 그대로 준수하고 플러그인의 기본 설정을 바꾸지 않고 사용하는 경우라면 그나마 낫다. 하지만 의존 라이브러리 갯수가 늘어나는 데다 엉망으로 설정된 의존성 전이를 맞추느라 <exclusion>을 가득 차워야 하고, 플러그인의 기본 설정을 바꿔쓰고, 여러가지 추가 플러그인을 적용하다 보면 pom.xml이 수 백라인으로 늘어나는 것을 경험하는 것은 어렵지 않다.

Spring ROO가 만들어 주는 프로젝트는 메이븐 기반으로 되어있다. ROO 배포판에 있는 샘플 프로젝트인 clininc은 스프링과 하이버네이트 기본 기능만 사용하는 매우 간단한 웹 애플리케이션이다. 그런데 이 clinic 프로젝트의 pom.xml은 503라인이나 된다. 메이븐을 수 년간 써오면서 나름 pom.xml 파일에 익숙한 나 조차도 한 눈에 빌드 내용을 파악하기가 쉽지 않다. 프로젝트 pom.xml에는 나오지 않는 기본 설정(effective pom을 봐야 알 수 있는)까지 의식하면서 봐야 하는 이유도 있지만, 스크롤 하면서 앞 뒤의 내용을 살펴야 하는 불편 때문이기도 하다.

메이븐 pom.xml을 살펴보면 XML을 설정 파일로 사용하는 다른 제품들과 확연하게 드러나는 특징을 발견할 수 있다. 메이븐 pom.xml에서는 애트리뷰트 없이 엘리먼트만 사용한다는 점이다. pom.xml에는 메이븐 개발자들이 가진 똥고집 수준의 강력한 XML 문서 작성 철학이 적용되어있다. 엘리먼트만 사용해서 XML 문서를 작성하면 간단한 문서의 경우에 깔끔해 보인다는 장점도 있다. 파싱하기도 더 편할지 모르겠다. 하지만 문서의 길이가 대폭적으로 증가하고, 그 때문에 가독성이 떨어진다는 단점이 있다. 물론 엘리먼트만 사용해서 문서를 작성하는 것이 더 낫다고 생각하는 사람도 있을 것이다. 반대로 애트리뷰트로 세부 설정을 빼주는 것을 선호하는 개발자들도 많다. 

예를 들어보자. 

다음은 전형적인 메이븐의 의존 라이브러리 설정이다. 하나만 놓고 보면 나쁘지는 않다. 하지만 의존 라이브러리가 수 십개쯤 되는 프로젝트라면 여러 페이지를 스크롤 해야 전체 라이브러리의 종류가 어떤 것인지 파악할 수 있을 것이다.

 

<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
<scope>provided</scope>
</dependency>

 

애트리뷰트를 이용해서 작성할 수 있다면 어떨까? 그렇다면 다음과 같이 한 줄이면 충분할 것이다.

 

<dependency groupId=”org.hsqldb” artifactId=”hsqldb” version=”1.8.0.10″ scope=”provided” />

 

실제로 메이븐의 <dependency>와 비슷한 역할을 하는 Ant/Ivy의 <dependency>는 다음과 같이 애트리뷰터를 사용해서 간결하게 작성할 수 있다.

 

<dependency org=”com.jamonapi” name=”com.springsource.com.jamonapi” rev=”2.4.0″ conf=”optional, jamon->compile”/>

 

Ivy의 경우 적지 않은 라이브러리를 사용하는 프로젝트라도 한 눈에 사용하는 라이브러리의 목록을 다 파악할 수 있고, 쉽게 편집이 가능하다.

메이븐의 엘리먼트 전용 XML 문서의 장황스러움은 엉성하게 작성된 전이적 의존 설정과 맞물리면 더 심각해진다. A 프로젝트가 B라는 라이브러리를 사용했을 경우에, B가 다시 의존하는 C,D,E,F,G 중에서 A 프로젝트가 실제 필요한 것은 일부인 경우가 대부분이다. B 라이브러리의 모든 잡다한 기능을 다 사용하는 것이 아니기 때문이다. 그렇다면 마땅히 B 라이브러리의 pom.xml을 작성하는 개발자는 C,D,E,F,G를 optional로 설정해주고, A 프로젝트 개발자가 이 중에서 원하는 것만 등록해서 쓰도록 해야 한다. 스프링의 경우 자신이 의존하는 라이브러리가 100개가 넘지만, commons-logging 빼고는 거의 다 optional로 되어있다. 반면에 간단한 유틸리티인데도 코드 내에서 참고하는 모든 라이브러리를 필수 의존 라이브러리로 잡아놓는 경우가 종종 있다. 그래서 테스트 라이브러리 하나 의존했을 뿐인데, 각종 DB관련 라이브러리가 모두 딸려 오거나, 심지어 jboss, tomcat이 통채로 끌려오는 경우가 있다. 메이븐의 의존성 전이 기능이 도움이 되기 보다는 피해를 주는 경우인데, 이런 폐혜가 많이 알려진 지금도 이런 문제는 자주 발견된다.

그래서 프로젝트의 pom을 작성하는 사람이 <dependency>로 가져오는 라이브러리의 pom.xml을 다시 살펴서 필요없는 라이브러리를 일일이 제외시켜줘야 한다. 

ROO가 만들어준 프로젝트에 포함된 commons-dbcp 라이브러리 설정을 살펴보자.

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>

commons-dbcp가 의존하는 라이브러리 중에서 4가지를 제외시켜주는 것이다. 이 설정 하나에 30줄이나 된다. 의존 라이브러리 전이 문제는 그렇다 치더라도 이 30줄이나 되는 설정을 애트리뷰트로 사용할 수 있게만 해줘도 훨씬 간결해질 것이다. 다음과 같이 고치면 6줄이면 끝이다.

<dependency groupId=”commons-dbcp” artifactId=”commons-dbcp” version=”1.3″>
<exclusion groupId=”commons-logging” artifactId=”commons-logging” />
<exclusion groupId=”commons-pool” artifactId=”commons-pool” /> 
<exclusion groupId=”xerces” artifactId=”xercesImpl” /> 
<exclusion groupId=”xml-apis” artifactId=”xml-apis” /> 
</dependency>

애트리뷰트를 쓰면 더 읽기가 불편하다고 생각하는 삐딱한 눈을 가진 사람이라면 메이븐 스타일에 만족하고 쓰면 되겠다. 하지만 나는 애트리뷰트를 쓰는 게 더 좋다. 

문제는 메이븐은 이런 개발자의 취향을 인정하지 않는다는 것이다. 메이븐은 /src/main/java 같은 디렉토리 구조부터 시작해서 메이븐 개발자들의 독특한 취향을 강요하고 강제한다. 그나마 디렉토리 구조는, 잘 알려져 있지 않긴 하지만 그래도 변경할 여지라도 줬다. 하지만 XML 작성 방법은 개발자들의 수 많은 요구가 있었음에도 3.0.3까지 나온 지금까지 요지부동이다. 

베타 버전이기는 하지만  메이븐 Polyglot 프로젝트가 만들어져서 ruby, scala, atom 등으로 메이븐 POM 파일을 작성하는 방법까지 가능해졌다. 하지만 여전히 XML 작성 방식은 그대로다.

그래서 지난 주말에 잠시 짬을 내서 메이븐 pom.xml을 애트리뷰트를 사용해서 작성할 수 있도록 메이븐을 조금 수정해봤다. 생각보다 어렵지 않게 가능했다. 

올해 들어서 처음 쓰는 블로그는 그 얘기를 해보려고 하는데… 벌써 업무시간이 되었네. 다음에 계속.

Related posts:

  1. Maven POM에 attribute 사용하기 (2)
  2. Maven 재도전기 (1)
  3. Maven 다중 리포지토리와 버전 범위를 사용할 때의 주의점
  4. Maven archetype 설정파일 자동생성기 – ArchetypeXmlWriter
  5. Maven 3.0과 버전 포맷 문제
  6. Maven settings.xml의 비밀번호 암호화
  7. Nexus Maven Repository 1.0 출시
  8. Maven 의존관계 수렁에 빠지다
  9. Spring 3.0 (34) R-941 스프링의 Maven 지원정책은?
  10. Ruby on Maven
  11. Maven: The Definitive Guide 사라지다
  12. Maven의 새로운 가이드북 – Maven: The Definitive Guide
  13. Spring 3.0 (4) – Maven에서 Spring 3.0 최신버전 사용하기
  14. Spring 3.0 (27) R-599 JDK1.5+ Concurrent
  15. Spring 3.0 (8) Core 모듈의 선택 라이브러리 분석

Facebook comments:

to “Maven POM에 attribute 사용하기 (1)”

  1. Hello, you used to write magnificent, but the last several posts have been kinda boring… I miss your tremendous writings. Past several posts are just a little out of track! come on!

  2. I blog often and I truly thank you for your information. This article has truly peaked my interest. I will book mark your site and keep checking for new details about once a week. I subscribed to your RSS feed too.

  3. There’s certainly a great deal to find out about this topic. I really like all of the points you’ve made.

  4. Thanks for your write-up. I also think laptop computers are becoming more and more popular today, and now are often the only form of computer included in a household. This is due to the fact that at the same time actually becoming more and more cost-effective, their working power keeps growing to the point where they are as potent as pc’s from just a few years back.

  5. Only a smiling visitant here to share the love (:, btw outstanding style and design .

  6. Hello.This post was extremely remarkable, especially since I was searching for thoughts on this topic last Saturday.

  7. cialis 20 mg ireland
    To minimize on the amount of candidiasis you have, retain the vaginal region clear. Use unscented cleaning soap on that area and ensure to pat the area dried out when washing is complete. The harmful bacteria that causes the infection grows fastest in moistened, darker locations so make sure to maintain the region clean and free of moisture.
    kamagra gel
    Look around for various credit cards. Interest levels as well as other terms tend to change greatly. Additionally, there are various credit cards, like cards which can be secured which need a down payment to pay charges that happen to be made. Make sure you know what kind of greeting card you happen to be subscribing to, and what you’re offered.
    cialis senza ricetta
    Try and reduce the level of cozy conditions which you have in your house. Go all around to different rooms at home and attempt to gauge the temp in which the pests may want to reside in probably the most. If you find an area which is also popular, make an effort to decrease the general temperatures there.
    kamagra jelly

  8. Hello there, just became alert to your blog through Google, and found that it’s really informative. I’m gonna watch out for brussels. I’ll be grateful if you continue this in future. Many people will be benefited from your writing. Cheers!

  9. Very good post! We are linking to this great article on our website. Keep up the good writing.

  10. [url=https://www.priligybelgique.nu]priligy belgique[/url]
    Avoid the bright white to take care of the acne battle! White-colored sugar, white bread, white-colored pasta, and bright white flour are common enhanced carbohydrates which result in your insulin levels to increase, creating high degrees of men bodily hormones coursing via your veins. This will cause your skin layer to excrete a lot more natural oils and acne microorganisms Enjoys sebum, so you’ll end up with a break out.
    [url=https://www.viagragenericocomprar.es]viagra generico[/url]
    To really save on automobile insurance, be sure the lowest priced automobile insurance clients are also economically capable of addressing any damage to your car. While you could be saving cash every month, if the organization will not produce once you have a car accident, then those funds you stored, and a lot more, will probably be the door spending for your own personel maintenance
    [url=https://www.levitraschweiz.nu]levitra schweiz[/url]
    Once you have created your write-up, it is important to emphasis your interest on marketing your article or else you may have completed all that work for nothing at all. You are able to promote your post on Youtube or discuss a link with it on Facebook. Also, have your mates inform your buddies.
    [url=https://www.viagrahintasuomessa.nu]viagra hinta[/url]

  11. wonderful publish, very informative. I ponder why the other specialists of this sector do not notice this. You must proceed your writing. I’m sure, you have a great readers’ base already!

  12. I was just looking for this information for some time. After 6 hours of continuous Googleing, at last I got it in your site. I wonder what’s the lack of Google strategy that don’t rank this type of informative web sites in top of the list. Generally the top web sites are full of garbage.

  13. That is the proper blog for anyone who desires to search out out about this topic. You realize so much its nearly onerous to argue with you (not that I actually would need…HaHa). You positively put a brand new spin on a topic thats been written about for years. Great stuff, just nice!

  14. Hiya! I simply wish to give an enormous thumbs up for the nice information you have got here on this post. I shall be coming back to your blog for more soon.

  15. generico cialis
    When considering a new residence, there are lots of factors to consider, to make sure that your house owner’s insurance coverage will likely be reduced. As an example, a property close to a fire hydrant can have lower premiums. When your village features a specialist flame section, you will additionally help save. Discount rates are given for home heating, plumbing and electrical methods that happen to be under a 10 years older, at the same time.
    cialis pris
    Always use a toner soon after cleaning your facial skin. A toner will get rid of any debris kept in your deal with that you simply missed when cleansing and this will also get rid of any outstanding deal with facial cleanser residue that could inflame your skin if remaining in contact with it for long periods of your time.
    Vardenafil Ă–sterreich
    To get in customers who may possibly dismiss ads, let them have ways to use their phone’s abilities. For example, you might ask them to take a image of an item and then e-mail it to you personally to get a promotional code. Men and women enjoy playing making use of their phones, and providing them a chance to do that can entice tough to attain buyers.
    levitra generika

  16. I was very pleased to find this great site. I want to to thank you for your time for this fantastic read!! I definitely appreciated every part of it and I have you saved as a favorite to see new stuff on your blog.

  17. hello guys cheers

  18. This is a really good tip particularly to those fresh to the blogosphere. Brief but very precise information… Many thanks for sharing this one. A must read post.

  19. I was very pleased to find this website. I need to to thank you for your time for this wonderful read!! I definitely loved every part of it and I have you book marked to see new stuff in your site.

  20. Just wish to say your article is as surprising. The clearness in your post is just cool and i can assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the rewarding work.

  21. Just want to say your article is as astounding. The clearness in your post is simply cool and i could assume you’re an expert on this subject. Well with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the enjoyable work.

  22. naturally like your web site but you need to take a look at the spelling on quite a few of your posts. Several of them are rife with spelling issues and I to find it very troublesome to tell the reality however I’ll certainly come again again.

  23. Thank you for another great article. The place else could anybody get that kind of information in such a perfect method of writing? I’ve a presentation next week, and I’m on the look for such info.

  24. Very good blog you have here but I was wondering if you knew of any forums that cover the same topics talked about in this article? I’d really like to be a part of community where I can get feed-back from other experienced individuals that share the same interest. If you have any suggestions, please let me know. Bless you!

  25. Normally I do not read article on blogs, but I would like to say that this write-up very pressured me to check out and do it! Your writing style has been amazed me. Thank you, quite great article.

  26. Hello, Neat post. There’s an issue with your web site in internet explorer, may check this… IE still is the marketplace leader and a good section of people will pass over your magnificent writing due to this problem.

  27. Really nice style and great articles , absolutely nothing else we want : D.

  28. You are my breathing in, I own few blogs and very sporadically run out from to post .

  29. Hi, I do believe this is a great blog. I stumbledupon it ;) I’m going to come back once again since I book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide others.

  30. I found your blog website on google and test a couple of of your early posts. Continue to keep up the superb operate. I just further up your RSS feed to my MSN News Reader. Searching for ahead to studying extra from you afterward!?

  31. Aw, this was a very good post. Finding the time and actual effort to generate a very good article… but what can I say… I hesitate a whole lot and don’t manage to get anything done.

  32. Hello my friend! I want to say that this article is amazing, nice written and include approximately all important infos. I would like to see more posts like this.

  33. There are actually a variety of details like that to take into consideration. That is a great level to bring up. I supply the thoughts above as common inspiration however clearly there are questions just like the one you deliver up the place the most important thing can be working in sincere good faith. I don?t know if greatest practices have emerged around issues like that, however I’m sure that your job is clearly recognized as a fair game. Both girls and boys feel the impact of just a moment’s pleasure, for the remainder of their lives.

  34. Generally I do not read article on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been surprised me. Thanks, quite nice article.

  35. I think other web-site proprietors should take this site as an model, very clean and fantastic user friendly style and design, let alone the content. You’re an expert in this topic!

  36. It is truly a great and useful piece of info. I’m glad that you shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.

  37. Wow! This could be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Great. I’m also an expert in this topic so I can understand your effort.

  38. I like this site very much, Its a very nice post to read and obtain info . “Oregano is the spice of life.” by Henry J. Tillman.

  39. Thanks for your write-up on the vacation industry. We would also like contribute that if you are a senior taking into consideration traveling, it truly is absolutely important to buy travel insurance for retirees. When traveling, elderly people are at high risk being in need of a health emergency. Buying the right insurance coverage package on your age group can look after your health and provide peace of mind.

  40. I was wondering if you ever considered changing the layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?

  41. I like what you guys are up too. Such clever work and reporting! Carry on the excellent works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website :)

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2017 Toby's Epril Suffusion theme by Sayontan Sinha