【Kotlin DSL】Deprecated な packagingOptions が fun Packaging.() に変換される件

これは?

【Kotlin DSL】packagingOption  が  fun Packaging.()  に変換される件

以下の記述が


packagingOptions {
  resources {
    excludes += "META-INF/rxjava.properties"
  }
}

これになりました。


fun Packaging.() {
  resources {
    excludes += "META-INF/rxjava.properties"
  }
}

なんだかおかしいです?

該当部分のコードを確認します。


    /**
     * Specifies options and rules that determine which files the Android plugin packages into your
     * APK.
     *
     * For more information about the properties you can configure in this block, see [Packaging].
     */
    @Deprecated("Renamed to packaging", replaceWith = ReplaceWith("packaging"))
    val packagingOptions: Packaging

    /**
     * Specifies options and rules that determine which files the Android plugin packages into your
     * APK.
     *
     * For more information about the properties you can configure in this block, see [Packaging].
     */
    @Deprecated("Renamed to packaging", replaceWith = ReplaceWith("packaging"))
    fun packagingOptions(action: Packaging.() -> Unit)

    /**
     * Specifies options and rules that determine which files the Android plugin packages into your
     * APK.
     *
     * For more information about the properties you can configure in this block, see [Packaging].
     */
    val packaging: Packaging

    /**
     * Specifies options and rules that determine which files the Android plugin packages into your
     * APK.
     *
     * For more information about the properties you can configure in this block, see [Packaging].
     */
    fun packaging(action: Packaging.() -> Unit)

👉 build-system/gradle-api/src/main/java/com/android/build/api/dsl/CommonExtension.kt - platform/tools/base - Git at Google hatena-bookmark

こうですね。


packaging {
  resources {
    excludes += "META-INF/rxjava.properties"
  }
}

ついでに、短くしておきます。


packaging {
  resources.excludes += "META-INF/rxjava.properties"
}

これでOK。

👉 How to replace deprecated packagingOptions in Android Gradle build files - Stack Overflow hatena-bookmark


関連ワード:  AndroidAndroidStudioKotlinおすすめツール今さら聞けない初心者開発