개발
[gradle] build 시 java home 지정하는 방법
정리하는개발자
2023. 8. 22. 11:06
728x90
반응형
github에서 spring boot 3.x 관련하여 공부하던중 로컬에서 gralde build 수행시 어플리케이션이 jdk 17로 구성되어 있어 빌드시 에러발생.!!
현재 JAVA_HOME 설정이 jdk11로 지정되어 있어 발생되는 문제로 추정된다.
C:\Users\wylee\test\springboot-developer\chapter11>gradle clean build
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'spring-boot-developer'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.2.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.2
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.2 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
... 생략 ...
gradle의 org.gradle.java.home 옵션을 적용하여 jdk17이 설치된 경로를 지정해주면 해결된다.
(다만 OS가 윈도우이면서 jdk 자바경로에 공백이 들어가 있는 경우 자바홈 경로를 쌍따옴표로 감싸주면 된다.)
gradle -Dorg.gradle.java.home="C:/Program Files/Java/jdk-17" clean build -x test
C:\Users\wylee\test\springboot-developer\chapter11>gradle -Dorg.gradle.java.home="C:/Program Files/Java/jdk-17" clean build -x test
> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
BUILD SUCCESSFUL in 3s
6 actionable tasks: 6 executed
C:\Users\wylee\test\springboot-developer\chapter11>
728x90
반응형