【问题标题】:What is the syntax for writing comments in build.gradle file?在 build.gradle 文件中写注释的语法是什么?
【发布时间】:2015-12-10 18:06:51
【问题描述】:

向下看这个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文件中写cmets的语法是什么?

【问题讨论】:

    标签: android gradle comments android-gradle-plugin build.gradle


    【解决方案1】:

    简单:

    // Single line comment
    
    /*
     Multi
     line
     comment
    */
    

    【讨论】:

      【解决方案2】:

      使用///* */

      例如:

              // 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 : ""
      }
      

      【讨论】:

      • 这很奇怪,我的 Android Studio 在我重新启动之前无法识别注释行。有趣的事情,虽然它在网络上没有任何答案。
      猜你喜欢
      • 2012-07-31
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-12
      • 2015-06-10
      相关资源
      最近更新 更多