一度は見たことがあるでしょう「Jetpack Compose Samples」。
👉 android/compose-samples: Official Jetpack Compose samples.
こんな記述があります。
👉 Jetchat/build.gradle.kts#L39-L42
何でしょうか、調べてみましょう。
■ Version catalog update plugin
このプラグインは、libs.versions.toml
の作成や更新をしてくれるようです。
👉 littlerobots/version-catalog-update-plugin: Gradle plugin for updating a project version catalog
一度、書き出して、どのようになるか確かめてみます。
■ 作成
./gradlew versionCatalogUpdate --create
作成されました。
[versions]
androidx-appcompat = "1.5.1"
androidx-arch-core = "2.1.0"
androidx-core = "1.8.0"
androidx-emoji2 = "1.2.0"
androidx-vectordrawable = "1.1.0"
org-jetbrains-kotlin = "1.7.20"
org-jetbrains-kotlinx = "1.6.1"
[libraries]
androidx-activity = "androidx.activity:activity:1.5.1"
androidx-annotation = "androidx.annotation:annotation:1.3.0"
androidx-annotation-annotation-experimental = "androidx.annotation:annotation-experimental:1.1.0"
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-appcompat-appcompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appcompat" }
androidx-arch-core-core-common = { module = "androidx.arch.core:core-common", version.ref = "androidx-arch-core" }
androidx-arch-core-core-runtime = { module = "androidx.arch.core:core-runtime", version.ref = "androidx-arch-core" }
androidx-cardview = "androidx.cardview:cardview:1.0.0"
androidx-collection = "androidx.collection:collection:1.1.0"
androidx-concurrent-concurrent-futures = "androidx.concurrent:concurrent-futures:1.0.0"
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
androidx-constraintlayout-constraintlayout-core = "androidx.constraintlayout:constraintlayout-core:1.0.4"
androidx-constraintlayout-constraintlayout-solver = "androidx.constraintlayout:constraintlayout-solver:2.0.1"
androidx-coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" }
androidx-core-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-cursoradapter = "androidx.cursoradapter:cursoradapter:1.0.0"
androidx-customview = "androidx.customview:customview:1.1.0"
androidx-documentfile = "androidx.documentfile:documentfile:1.0.0"
androidx-drawerlayout = "androidx.drawerlayout:drawerlayout:1.1.1"
androidx-dynamicanimation = "androidx.dynamicanimation:dynamicanimation:1.0.0"
androidx-emoji2 = { module = "androidx.emoji2:emoji2", version.ref = "androidx-emoji2" }
androidx-emoji2-emoji2-views-helper = { module = "androidx.emoji2:emoji2-views-helper", version.ref = "androidx-emoji2" }
androidx-fragment = "androidx.fragment:fragment:1.3.6"
androidx-interpolator = "androidx.interpolator:interpolator:1.0.0"
androidx-legacy-legacy-support-core-utils = "androidx.legacy:legacy-support-core-utils:1.0.0"
androidx-lifecycle-lifecycle-common = "androidx.lifecycle:lifecycle-common:2.5.1"
androidx-lifecycle-lifecycle-livedata = "androidx.lifecycle:lifecycle-livedata:2.0.0"
androidx-lifecycle-lifecycle-livedata-core = "androidx.lifecycle:lifecycle-livedata-core:2.5.1"
androidx-lifecycle-lifecycle-process = "androidx.lifecycle:lifecycle-process:2.4.1"
androidx-lifecycle-lifecycle-runtime = "androidx.lifecycle:lifecycle-runtime:2.5.1"
androidx-lifecycle-lifecycle-viewmodel = "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
androidx-lifecycle-lifecycle-viewmodel-savedstate = "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1"
androidx-loader = "androidx.loader:loader:1.0.0"
androidx-localbroadcastmanager = "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"
androidx-print = "androidx.print:print:1.0.0"
androidx-recyclerview = "androidx.recyclerview:recyclerview:1.1.0"
androidx-resourceinspection-resourceinspection-annotation = "androidx.resourceinspection:resourceinspection-annotation:1.0.1"
androidx-savedstate = "androidx.savedstate:savedstate:1.2.0"
androidx-startup-startup-runtime = "androidx.startup:startup-runtime:1.1.1"
androidx-test-espresso-espresso-core = "androidx.test.espresso:espresso-core:3.4.0"
androidx-test-ext-junit = "androidx.test.ext:junit:1.1.3"
androidx-tracing = "androidx.tracing:tracing:1.0.0"
androidx-transition = "androidx.transition:transition:1.2.0"
androidx-vectordrawable = { module = "androidx.vectordrawable:vectordrawable", version.ref = "androidx-vectordrawable" }
androidx-vectordrawable-vectordrawable-animated = { module = "androidx.vectordrawable:vectordrawable-animated", version.ref = "androidx-vectordrawable" }
androidx-versionedparcelable = "androidx.versionedparcelable:versionedparcelable:1.1.1"
androidx-viewpager = "androidx.viewpager:viewpager:1.0.0"
androidx-viewpager2 = "androidx.viewpager2:viewpager2:1.0.0"
com-google-android-material = "com.google.android.material:material:1.7.0"
junit = "junit:junit:4.13.2"
org-apache-logging-log4j-log4j-core = "org.apache.logging.log4j:log4j-core:2.17.1"
org-jacoco-org-jacoco-ant = "org.jacoco:org.jacoco.ant:0.8.7"
org-jetbrains-annotations = "org.jetbrains:annotations:13.0"
org-jetbrains-kotlin-kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlin-kotlin-stdlib-common = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlin-kotlin-stdlib-jdk7 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlin-kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlinx-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "org-jetbrains-kotlinx" }
org-jetbrains-kotlinx-kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "org-jetbrains-kotlinx" }
org-jetbrains-kotlinx-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "org-jetbrains-kotlinx" }
org-jetbrains-kotlinx-kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "org-jetbrains-kotlinx" }
[plugins]
com-android-application = "com.android.application:7.3.1"
com-android-library = "com.android.library:7.3.1"
com-github-ben-manes-versions = "com.github.ben-manes.versions:0.41.0"
nl-littlerobots-version-catalog-update = "nl.littlerobots.version-catalog-update:0.7.0"
org-jetbrains-kotlin-android = "org.jetbrains.kotlin.android:1.7.20"
フォーマットが統一され、ソートされたきれいなTOMLファイルです。
キーは、kebab-case
で重複処理も上手に行ってくれてるように見えます。
👉 【Gradle Version Catalog】libs.versions.toml キー名の形式 camelCase vs kebab-case
build.gradle 側は更新しないようなので新規作成は安全ですが、既存の場合は、
./gradlew versionCatalogUpdate --interactive
とすると、別のファイル名 libs.versions.updates.toml
で書き出してくれるようです。
実行後は gradle ディレクトリを Reload すると作成されてることが確認できます。
[plugins]
# From version 7.3.1 --> 8.0.0-alpha06
android-application = "com.android.application:8.0.0-alpha06"
まずは、参考にまで使ってみました。簡単で便利です。
無駄のない最小限の記述なので、最初の書き出しには使うと良いと思います。
👌 もっと、シンプルでいいような気がするので以下の方法でもやってみました。
【Android Studio】TOML内のすべてをインライン・テーブルに書き換える Live Templates 用 Groovy スクリプト https://t.co/hTpsezFD2d #android #kotlin #groovy #androiddev #プログラミング pic.twitter.com/7PyX7I95gX
— chanzmao (@maochanz) November 11, 2022
【AndroidStudio】コードを縦に揃えて、あるカラムでソートできるプラグイン - String Manipulation
👉 https://t.co/s6DS8WVuSi #android #idea #androidstudio #python #プログラミング pic.twitter.com/hjmHJcuZQV— chanzmao (@maochanz) November 16, 2022
関連ワード: Android・AndroidStudio・Google・IDEA・JetBrains・JetpackCompose・おすすめ・ツール・便利な設定・評判・開発