JBoss User Group The Agile Dependency Manager 김병곤 fharenheit@gmail.com 20100911 v1.0
소개 JBoss User Group 대표 통신사에서분산컴퓨팅기반개인화시스템구축 Process Designer ETL, Input/Output, Mining Algorithm, 통계 Apache Hadoop/Pig/HBase/Cassandra Distributed Cache Log Aggregator CEP(Complex Event Processing) Mining Algorithm Association Rule, K-Means, CF, SW마에스트로엔터프라이즈분과멘토 Hadoop 멘토링 다수책집필및번역 JBoss Application Server 5, EJB 2/3 Oreilly RESTful Java 번역중 2
최근빌드시스템의변화추세 Apache Ant Apache Ant + Ivy Apache Maven 3
Ant 에서 Ivy 의필요성 프로젝트를구성하는각종라이브러리의관리문제 라이브러리를자동으로다운로드해준다면. 각종라이브러리간종속성문제 이라이브러리가동작하려면다른라이브러리도필요하다! 소스코드에라이브러리가포함되어있는문제 소스코드 Check Out 이너무느리다 CVS/Subversion Repository 가커진다 4
Ivy 란? Tool for Managing Project Dependencies = Apache Maven Dependency Management 5
Project 의 Depedency 6
Ivy 를쓰려면? JDK Apache Ant Internet Line 7
DEMO Ivy 를동작시키기위한최소의파일은? $PROJECT_HOME/ivy.xml (Ivy : Dependency) <ivy-module version="2.0"> <info organisation="org.apache" module="hello-ivy"/> <dependencies> <dependency org="commons-lang" name="commons-lang" rev="2.0"/> <dependency org="commons-cli" name="commons-cli" rev="1.0"/> </dependencies> </ivy-module> Ivy Style $PROJECT_HOME/build.xml (Ant : Build Script) <project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="run">... <target name="resolve" description="--> retrieve dependencies with ivy"> <ivy:retrieve /> </target> </project> <dependency> <groupid>commons-lang</groupid> <artifactid>commons-lang</artifactid> <version>2.0</version> </dependency> Maven Style 8
Repository JAR 파일 (Dependency) 의보관창고 Maven Style Repository 를그대로활용 3가지방식의 Repository Local 자신만사용할수있는 Repository Shared 팀이공유할수있는 Repository Public 외부에공개되어누구나사용할수있는 Repository 사내 Private Repository 를운영하는것이좀더바람직 9
DEMO Atifactory, Nexus Maven Repository 10
Ivy 의 Repository Configuration Local ivy.local.default.root=/opt/ivy/repository/local (Default) ${ivy.default.ivy.user.dir}/local Shared ivy.shared.default.root=/opt/ivy/repository/shared (Default) ${ivy.default.ivy.user.dir}/shared Public ibiblio Maven 2 Public Repository 사용자가추가가능 (Artifactory or Nexus or ) 11
Multiple Resolver Repository에접근하는다양한방법을제공 Third Party 모듈은 Public, 내부구현모듈은 Private 개발한모듈을 Local Repository에두고자하는경우 모듈이분산되어있는경우 $PROJECT_HOME/ivysettings.xml <ivysettings> <settings defaultresolver="chain-example"/> <resolvers> commons-lang-2.0.jar <chain name="chain-example"> <filesystem name="libraries"> <artifact pattern="${ivy.settings.dir}/repository/[artifact]-[revision].[ext]" /> </filesystem> <ibiblio name="ibiblio" m2compatible="true" /> </chain> </resolvers> </ivysettings> 12
DEMO Repository Configuration Custom Repository 사내 Maven Repository 가있다면? <?xml version="1.0" encoding="utf-8"?> <ivysettings> <settings defaultresolver="chained"/> <resolvers> <chain name="chained"> <ibiblio name="java.net2" m2compatible="true" root="http://download.java.net/maven/2/"/> <ibiblio name="jboss" m2compatible="true" root="http://repository.jboss.org/maven2"/> <ibiblio name="ibiblio" m2compatible="true"/> </chain> </resolvers> </ivysettings> 13
DEMO RESTful Java Example Dependency Exclusion 불필요한 Dependency 를빼고싶은경우 <?xml version="1.0" encoding="utf-8"?> <ivy-module version="2.0 xmlns:xsi="hssp://www.w3.org/2001/xmlschema-inssance xsi:nonamespaceschemalocasion="hssp://ans.apache.org/ivy/schemas/ivy.xsd"> <info organisasion="com.jbossug.jaxrs" module="jaxrs-examples"/> <dependencies> <dependency org="log4j" name="log4j" rev="1.2.16 > <exclude org="javax.mail"/> <exclude org="javax.activation"/> <exclude org="org.apache.geronimo.specs"/> </dependency> <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.6 /> </dependencies> </ivy-module> 14
Ivy Integration : Step 1 Ivy Download & Install Ant 내에서 Ivy 를동작하도록하기위한설정 <property name="ivy.jar.dir" value="${basedir}/ivy"/> <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/> <!-- Ivy Download --> <target name="download-ivy" unless="skip.download"> <mkdir dir="${ivy.jar.dir}"/> <echo message="installing ivy..."/> <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar" dest="${ivy.jar.file}" usetimestamp="true"/> </target> <!-- Ivy Installation --> <target name="install-ivy" depends="download-ivy"> <path id="ivy.lib.path"> <fileset dir="${ivy.jar.dir}" includes="*.jar"/> </path> <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> </target> 15
Ivy Integration : Step 2 Dependency Resolve & Build Dependency 를다운로드하고빌드를하기위한설정 <property name="lib.dir" value="${basedir}/lib"/> <path id="lib.path.id"> <pathelement location="${build.dir}" /> <fileset dir="${lib.dir}"> <include name="*.jar" /> </fileset> </path> <target name="resolve"> <ivy:retrieve /> </target> <target name="go" depends="install-ivy, resolve"> <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id"/> <java classname="example.hello"> <classpath> <path refid="lib.path.id"/> </classpath> </java> </target> 16
IvyIDE Eclipse 기반 Ivy 지원도구 ivy.xml 파일에정의한 dependency 를 Eclipse 에서관리 Dependency 를 Java 프로젝트의 CLASSPATH 에추가 각종파일의편집기능및자동완성기능제공 17
IvyIDE 18
IvyIDE 19
IvyIDE 20
참고 Sonatype Nexus 동영상 http://vimeo.com/1875558 IvyIDE http://ant.apache.org/ivy/ivyde Ivy Official Site http://ant.apache.org/ivy 발표자료 (Naver 개발자센터 ) http://dev.naver.com/projects/edward/src http://dev.naver.com/projects/edward/download 21
Q & A Q & A 22