본문 바로가기

카테고리 없음

[gradle] The destinationDir property has been deprecated.

destinationDir 프로퍼티가 deprecated 되었다.

Gradle 7.0 버전 부터는 제거된다고 한다.

> Configure project :
The destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead.
        at build_1mh8oopzo33vg2womc6rg8jd3$_run_closure7.doCall(/Users/namo/git/ya-payment-api/build.gradle:171)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

destinationDir 대신에 destinationDirectory 프로퍼티를 사용하라고 한다.
하지만 바꾸면 에러가 난다. 왜냐하면 gralde에서 프로퍼티는 경우에 따라 getter나 setter로 쓸 수 있기 때문이다.
나의 경우는 setter로 쓰는 경우인데 destinationDirectory는 getDestinationDirectory()였기 때문이다.

package org.gradle.api.tasks.bundling;

public abstract class AbstractArchiveTask extends AbstractCopyTask {
    @Deprecated
    @ReplacedBy("destinationDirectory")
    public File getDestinationDir() {
        DeprecationLogger.nagUserOfReplacedProperty("destinationDir", "destinationDirectory");
        return (File)this.archiveDestinationDirectory.getAsFile().get();
    }

    @Deprecated
    public void setDestinationDir(File destinationDir) {
        DeprecationLogger.nagUserOfReplacedProperty("destinationDir", "destinationDirectory");
        this.archiveDestinationDirectory.set(this.getProject().file(destinationDir));
    }

    @Internal("Represented by the archiveFile")
    public DirectoryProperty getDestinationDirectory() {
        return this.archiveDestinationDirectory;
    }

결국은 아래와 같이 바꾸면 된다.

destinationDir project.buildDir	// setDestinationDir(project.buildDir) 와 같다.
// 을
destinationDirectory.set(project.file(project.buildDir))

gradle-wrapper를 5.4.1 에서 6.0.1 로 바꾸니 나온다.

build.gradle에 있는 프로퍼티를 gradle.properties 로 옮기는 작업을 했다.

1. 기존에 '~~' 나 "~~" 의 경우 '나 "를 제거해야 한다.

2. 일부 plugins의 version에서는 프로퍼티가 안먹는 것 같다. 이슈가 이미 발행되어 있다.

 아래와 같이 "$변수" 로 참조가 가능하다. (예.)

[gradle.properties]
springBootVersion=2.1.6.RELEASE
springDependencyManagementVersion=1.0.8.RELEASE
sonarqubePluginVersion=2.8

[build.gradle]
plugins {
    id 'org.springframework.boot' version "$springBootVersion"
    id 'io.spring.dependency-management' version "$springDependencyManagementVersion"
    id 'java'
    id "org.sonarqube" version "$sonarqubePluginVersion"
}