- Maven Life-Cycle
- phase1 : complie == 단순 컴파일
- phase2 : test == 단순 테스트
- phase3 : package == 압축파일 생성
- phase4 : install == 압축파일 배포 (Local-Repository)
- phase5 : deploy == 압축파일 배포 (Remote-Repository)
- Maven Scope
- complie : Compile 및 Deploy 에 모두 필요한 Dependency.
- provided : Compile 에는 필요 하지만, Deploy 에는 필요없는 Dependency. 예) /tomcat/lib 에서 제공되는 jar
- runtime : Compile 시엔 필요없지만, Runtime 시엔 필요한 Dependency.
- test : Test 시에만 필요한 Dependency.
- system :현 시스템에 특정 jar를 지정하는 Dependency.
- 예) mvn install:install-file -Dfile=C:\test\test.jar -DgroupId=com.company.project -DartifactId=test -Dversion=1.0.0 -Dpackaging=jar
-
<dependency> <groupId>com.company.project</groupId> <artifactId>test</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/test.jar</systemPath> </dependency> <repository> <id>inner-repo</id> <name>inner-repo</name> <url>file://${project.basedir}/lib/</url> </repository> <dependency> <groupId>com.company.project</groupId> <artifactId>test</artifactId> <version>1.0.0</version> </dependency>
- 음... 잘 안됬음...
- modules
- 큰 프로젝트를 모듈화 하여, 쪼게는 용도.
- 하나의 "부모 pom.xml" 과 여러게의 "자식 pom.xml" 식으로 구성.
-
<groupId>com.compony.project</groupId> <artifactId>parent</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <modules> <module>aaa</module> <module>bbb</module> <module>ccc</module> </modules> ...
- 하위 특정 모듈만 패키징 가능.
- 예) (부모 pom.xml) clean package -pl bbb -am -amd
- Nexus 배포
- 제공받을 수 있는 넥서스에 jar를 배포하기.
- 예) mvn -X deploy:deploy-file -DaltDeploymentRepository=maven-releases
- -DgroupId=com.penta.scpdb
- -DartifactId=ba-scp
- -Dversion=3.0.9.3
- -Dfile=ba-scp-3.0.9.3.jar
- -Dpackaging=jar
- -Dsources=없음
- -Durl=http://nexus.compony.com/repository/test-3rdparty/
- -DrepositoryId=test-3rdparty
- settings.xml
-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>test-release</id> <username>user</username> <password>12345</password> </server> <server> <id>test-snapshot</id> <username>user</username> <password>12345</password> </server> <server> <id>test-3rdparty</id> <username>user</username> <password>12345</password> </server> </servers> <mirrors> <mirror> <id>nexus</id> <mirrorOf>central,public,releases,snapshots</mirrorOf> <mirrorOf>*</mirrorOf> <url>http://nexus.compony.com/repository/maven-public/</url> </mirror> </mirrors> </settings>
-
- build
-
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <finalName>test-first</finalName> </build>
-
- distributionManagement
- 배포를 할 repository 관련 설정
-
<distributionManagement> <repository> <id>nexus</id> <name>Releases</name> <url>http://nexus.compony.com/repository/maven-releases</url> </repository> <snapshotRepository> <id>nexus</id> <name>Snapshot</name> <url>http://nexus.compony.com/repository/maven-snapshots</url> </snapshotRepository> </distributionManagement> <distributionManagement> <repository> <id>test-release</id> <url>http://nexus.compony.com/repository/test-release/</url> </repository> <snapshotRepository> <id>test-snapshot</id> <url>http://nexus.compony.com/repository/test-snapshot/</url> </snapshotRepository> </distributionManagement>
- repositories
- jar를 찾을 repository 관련 설정
-
<repositories> <repository> <id>test-release</id> <url>http://nexus.compony.com/repository/test-release/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>test-snapshot</id> <url>http://nexus.compony.com/repository/test-snapshot/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
- ...
-끝-
'DevOps' 카테고리의 다른 글
Dockerfile (0) | 2020.07.09 |
---|---|
Docker-Swarm (0) | 2020.04.06 |
Kubernetes 란? (0) | 2019.11.04 |
Docker 란? (0) | 2019.11.04 |
git (0) | 2019.05.18 |