Skip to content

2장 build.gradle 실패하시는 분들 참고하세요! #7

@Yelin-park

Description

@Yelin-park

깃헙 소스 코드 그대로 작성 후 래퍼 파일을 생성하려고 하니 실패가 떠서 해결한 뒤 글을 작성합니다.

예전에는 원하는 gralde 버전을 명시했던 부분을 이제는 설정을 하지 않아도 된다고 합니다.
참고 : https://kwonnam.pe.kr/wiki/gradle/wrapper

task wrapper(type: Wrapper) {
    gradleVersion = '1.6' // 원하는 Gradle 버전 명시
}

수정된 부분 확인하시고 참고하세요~

before

apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"

repositories {
	mavenCentral()
}

dependencies {
	compile 'org.springframework:spring-context:5.0.2.RELEASE'
}

task wrapper(type: Wrapper){
        gradleVersion = '4.4'
}

after

apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"

repositories {
	mavenCentral()
}

dependencies {
	compile 'org.springframework:spring-context:5.0.2.RELEASE'
}

제가 접한 에러 메시지는 다음과 같습니다.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\spring5fs\sp5-chap02\build.gradle' line: 15

* What went wrong:
A problem occurred evaluating root project 'sp5-chap02'.
> Cannot add task 'wrapper' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.3/userguide/command_line_interface.html#sec:command_line_warnings
  • 추가로 build.gradle 파일 어디서 작성하는지 모르시는 분들~
    Noteapd++나 에디터플러스 같은 프로그램에 작성하시고 확장자를 .gradle로 저장하시면 됩니다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions