개발공부/Spring

스프링 그레이들 플랫폼(platform)과 인포스트플랫폼(enforcedPlatform)

원석💎-dev 2023. 6. 18. 21:19
반응형

공식문서: [Spring Boot Gradle Plugin Reference Guide - 3. Managing Dependencies]

 

 

BOM 파일이 의존성 라이브러리의 버전들을 명세하고 있는 POM 파일이라는 사실을 알았다. - [스프링 BOM이란?]

BOM 파일을 적용할 때, 플랫폼(platform)과 인포스트플랫폼(enforcedPlatform)이 존재한다.

 

1. 플랫폼의 사용법

Groovy

dependencies {
  implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}

Kotlin

dependencies {  implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
}

 

2. 인포스트플랫폼의 사용법

Groovy

dependencies {
  implementation enforcedPlatform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}

Kotlin

dependencies {
  implementation(enforcedPlatform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
}

 

3. 플랫폼과 인포스트플랫폼

 공식문서에서 "플랫폼 의존성은 bom의 버전을 권장 사항으로 취급하고 의존성 그래프의 다른 버전 및 제약 조건으로 인해 bom에서 선언된 것과 다른 의존성 버전이 사용될 수 있다. 인포스트플랫폼 의존성은 bom의 버전을 요구 사항으로 취급하며 의존성 그래프에 있는 다른 버전을 재정의한다."고 정의했다. 플랫폼 의존성권장 사항 인포스트플랫폼 의존성요구 사항으로 설명하고 있다. 사실 영어 단어만 봐도 인포스트플랫폼이 뭔가 더 강한 느낌을 받는다. 예를 들어 아래와 같이 코틀린 예제에서 onestone-library:1.0.0 의존성 라이브러리 중 aspectj 라이브러리 버전을 1.9.9.1을 사용중이고, bom 파일이 aspectj 라이브러리 버전을 1.9.19를 사용중이라면 요구 사항에 맞게 aspectj 라이브러리 버전 1.9.19로 의존 라이브러리 버전을 모두 변경한다.

 

Kotlin

plugins {
  java
  id("org.springframework.boot") version "3.1.0" apply false
  id("io.spring.dependency-management") version "1.1.0"
}

dependencies {    implementation(enforcedPlatform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)) 
  implementation(test.onestone:onestone-library:1.0.0)
}

 

반응형