build.gradle 파일에 주석을 작성하는 구문은 무엇입니까?


174

이 build.gradle파일을 내려다 보면서

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "package.myapp"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.nineoldandroids:library:2.4.0'
}

이 프로젝트를 위해이 라이브러리를 선택한 이유에 대한 의견을 남기고 싶은 경우 ,

build.gradle파일에 주석을 작성하는 구문은 무엇 입니까?

답변:


265

쉬운:

// Single line comment

/*
 Multi
 line
 comment
*/

29

사용하여 //또는/* */

예를 들면 다음과 같습니다.

        // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.2.3'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

/**
 * Returns the credential username used by Namirial Maven repository
 * Set this value in your ~/.gradle/gradle.properties with CREDENTIALS_USERNAME key
 * @return
 */
def getCredentialsMavenUsername() {
    return hasProperty('CREDENTIALS_USERNAME') ? CREDENTIALS_USERNAME : ""
}

글쎄요, 안드로이드 스튜디오는 내가 다시 시작할 때까지 주석 줄을 인식하지 못했습니다. 웹에는 아무런 대답이 없지만 재미있는 일입니다.
— Machado
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.