Skip to content

Instantly share code, notes, and snippets.

@bitristan
Created July 21, 2021 07:48
Show Gist options
  • Save bitristan/899ad4070ace4bf54d2680233730669a to your computer and use it in GitHub Desktop.
Save bitristan/899ad4070ace4bf54d2680233730669a to your computer and use it in GitHub Desktop.
gradle reference note
  1. When Gradle executes a Groovy build script (.gradle), it compiles the script into a class which implements Script. This means that all of the properties and methods declared by the Script interface are available in your script.

  2. When Gradle executes a Kotlin build script (.gradle.kts), it compiles the script into a subclass of KotlinBuildScript. This means that all of the visible properties and functions declared by the KotlinBuildScript type are available in your script. Also see the KotlinSettingsScript and KotlinInitScript types respectively for settings scripts and init scripts.

  3. An important feature of the resulting file collections is that they are live. In other words, when you combine file collections in this way, the result always reflects what’s currently in the source file collections, even if they change during the build.

  4. Define custom gradle plugin

plugins {
    `java-gradle-plugin`
}
gradlePlugin {
    plugins {
        create("myPlugins") {
            id = "my-plugin"
            implementationClass = "my.MyPlugin"
        }
    }
}
  1. .gradle.kts定义常量
gradle.properties定义helloVersion=1.0.0,
build.gradle.kts中使用: val helloVersion: String by settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment