반응형

Maven - Snapshots


(원문 위치 : http://www.tutorialspoint.com/maven/maven_snapshots.htm )

일반적으로 대규모 프로그램은 다수의 모듈로 구성되고 다수의 팀이 동일 프로그램의 다른 모들로 작업하는 것이 일반적인 시나리오이다. 예를 들면 app-ui 프로젝트(app-ui.jar:1.0)으로써 프로그램을 프론트앤드에서 작헙하는 팀이 있고 그 팀은 data-service 프로젝트(data-service.jar:1.0)을 사용하고 있다고 가정해보자.

이제 data-service에서 작업하고 잇는 팀이 bug fix 또는 빠른 속도로 개선(enhencement)하고 있고 거의 하루걸러에 한번씩 원격 저장소로 라이브러리를 릴리즈하는 상황이 발생할 수 있다.

이제 만약 data-service팀이 하루걸러 한번씩 새로운 버전을 업로드하면 아래의 문제가 발생할 것이다.

- data-service팀은 릴리즈하는 매전 app-ui팀에 통지해야 한다.
- app-ui팀은 갱신된 버전을 정기적으로 pom.xml에 갱신해야 한다.

이같은 상황을 통제하기 위해, SNAPSHOT 개념이 동작하기 시작한다.

What is SNAPSHOT?

 SNAPSHOT은 현재 개발 복사본을 나타내는 특별한 버전이다. 정기적인 버전과 다르게, Maven은 매번 빌드를 위해 원격저장소의 새로운 SNAPSHOT을 점검한다. 

이제 data-service 팀은 더 오래된 SNAPSHOT.jar를 대체하는 data-service:1.0-SNAPSHOT을 말하는 매번 갱신된 코드의 SNAPSHOT을 저장소에 릴리즈할 것이다. 

app-ui pom.xml

app-ui프로젝트는 data-service의 1.0-SNAPShOT을 사용한다.
<project xmlns="http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>app-ui</groupId>
   <artifactId>app-ui</artifactId>
   <version>1.0</version>
   <packaging>jar</packaging>
   <name>health</name>
   <url>http://maven.apache.org</url>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   <dependencies>
      <dependency>
      <groupId>data-service</groupId>
         <artifactId>data-service</artifactId>
         <version>1.0-SNAPSHOT</version>
         <scope>test</scope>
      </dependency>
   </dependencies>
</project>

data-service pom.xml

data-service프로젝트는 매 minor change마다 1.0-SNAPSHOT을 릴리즈 한다.
<project xmlns="http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>data-service</groupId>
   <artifactId>data-service</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   <name>health</name>
   <url>http://maven.apache.org</url>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   </project>
비록 SNAPSHOT의 경우 Maven이 자동적으로 일별 기준으로 최종 SNAPSHOT을 가지고 온다. 혹은 어떠한 maven 명령에서 -U switch를 사용하여 maven이 최종 snapshot build를 다운로드하도록 할 수 있다.
mvn clean package -U
콘솔을 열고 C:\ > MVN > app-ui 디렉토리로 가서 아래 mvn명령을 실행하자.
C:\MVN\app-ui>mvn clean package -U
Maven은 data-service의 최종 SNAPSHOT을 다운로드한 후 build를 시작할 것이다.
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building consumerBanking
[INFO]    task-segment: [clean, package]
[INFO] -------------------------------------------------------------------
[INFO] Downloading data-service:1.0-SNAPSHOT
[INFO] 290K downloaded.
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\MVN\app-ui\target
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVN\app-ui\src\main\
resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to C:\MVN\app-ui\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVN\app-ui\src\test\
resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 1 source file to C:\MVN\app-ui\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\MVN\app-ui\target\
surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.companyname.bank.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\MVN\app-ui\target\
app-ui-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: 2015-09-27T12:30:02+05:30
[INFO] Final Memory: 16M/89M
[INFO] ------------------------------------------------------------------------


반응형

+ Recent posts