Skip to content

Commit

Permalink
Version Catalog の導入 (#123)
Browse files Browse the repository at this point in the history
* Kotlin の依存関係定義を Version Catalog へ移行

* Version Catalog で各 plugin を扱うために pluginManagement の設定を追加

* Android Gradle Plugin の依存関係定義を Version Catalog へ移行

* SDK Version の設定を Version Catalog へ移行

* Jetpack Compose の依存関係定義を Version Catalog へ移行
  • Loading branch information
yugg003 authored Oct 13, 2023
1 parent 24c4006 commit cd47a13
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 48 deletions.
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'

Expand All @@ -18,15 +16,13 @@ buildscript {
}

plugins {
alias libs.plugins.android.application apply false
alias libs.plugins.android.library apply false
id "org.jlleitschuh.gradle.ktlint" version "11.4.2"
alias libs.plugins.kotlin apply false
alias libs.plugins.kotlin.parcelize apply false
}

ext.versions = [
compileSdk: 33,
targetSdk : 30,
minSdk : 23,
]

allprojects {
repositories {
google()
Expand Down
22 changes: 11 additions & 11 deletions catalog/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
alias libs.plugins.android.application
alias libs.plugins.kotlin
alias libs.plugins.kotlin.parcelize
}

android {
compileSdk versions.compileSdk
compileSdk libs.versions.android.compileSdk.get().toInteger()

buildFeatures {
viewBinding true
Expand All @@ -15,8 +15,8 @@ android {

defaultConfig {
applicationId "net.pixiv.charcoal.android.catalog"
minSdk versions.minSdk
targetSdk versions.targetSdk
minSdk libs.versions.android.minSdk.get().toInteger()
targetSdk libs.versions.android.targetSdk.get().toInteger()
versionCode 1
versionName "1.0"

Expand All @@ -40,7 +40,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion "${composeCompilerVersion}"
kotlinCompilerExtensionVersion "${libs.versions.composeCompiler.get()}"
}

signingConfigs {
Expand All @@ -64,10 +64,10 @@ dependencies {

implementation deps.androidX.appCompat
implementation deps.androidX.activity.compose
implementation platform(deps.androidX.compose.bom)
implementation deps.androidX.compose.ui
implementation deps.androidX.compose.uiTooling
implementation deps.androidX.compose.material
implementation platform(libs.androidx.compose.bom)
implementation libs.androidx.compose.ui
implementation libs.androidx.compose.ui.tooling
implementation libs.androidx.compose.material
implementation deps.androidX.recyclerView
implementation deps.androidX.material
implementation deps.androidX.constraintLayout
Expand Down
22 changes: 11 additions & 11 deletions charcoal-android-compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
alias libs.plugins.android.library
alias libs.plugins.kotlin
id 'signing'
id 'maven-publish'
id 'org.jetbrains.dokka'
Expand All @@ -10,16 +10,16 @@ group = "net.pixiv.charcoal"
version = findProperty('CHARCOAL_RELEASE_VERSION') ?: System.getenv('CHARCOAL_RELEASE_VERSION') ?: ""

android {
compileSdkVersion versions.compileSdk
compileSdk libs.versions.android.compileSdk.get().toInteger()

buildFeatures {
buildConfig false
compose true
}

defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
minSdk libs.versions.android.minSdk.get().toInteger()
targetSdk libs.versions.android.targetSdk.get().toInteger()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -43,7 +43,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion "${composeCompilerVersion}"
kotlinCompilerExtensionVersion "${libs.versions.composeCompiler.get()}"
}
namespace 'net.pixiv.charcoal.android.compose'
}
Expand All @@ -52,11 +52,11 @@ dependencies {
api project(":charcoal-android")

implementation deps.androidX.activity.compose
implementation deps.androidX.compose.compiler
implementation platform(deps.androidX.compose.bom)
implementation deps.androidX.compose.ui
implementation deps.androidX.compose.uiTooling
implementation deps.androidX.compose.material
implementation libs.androidx.compose.compiler
implementation platform(libs.androidx.compose.bom)
implementation libs.androidx.compose.ui
implementation libs.androidx.compose.ui.tooling
implementation libs.androidx.compose.material
implementation deps.kotlinX.serialization

testImplementation deps.junit
Expand Down
11 changes: 5 additions & 6 deletions charcoal-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
alias libs.plugins.android.library
alias libs.plugins.kotlin
id 'signing'
id 'maven-publish'
id 'org.jetbrains.dokka'
Expand All @@ -10,11 +10,11 @@ group = "net.pixiv.charcoal"
version = findProperty('CHARCOAL_RELEASE_VERSION') ?: System.getenv('CHARCOAL_RELEASE_VERSION') ?: ""

android {
compileSdkVersion versions.compileSdk
compileSdk libs.versions.android.compileSdk.get().toInteger()

defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
minSdk libs.versions.android.minSdk.get().toInteger()
targetSdk libs.versions.android.targetSdk.get().toInteger()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -40,7 +40,6 @@ dependencies {
implementation deps.androidX.fragment
implementation deps.androidX.material
implementation deps.androidX.core
implementation deps.kotlin.stdlib

testImplementation deps.junit

Expand Down
12 changes: 0 additions & 12 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
ext {
kotlinVersion = '1.7.20'
androidXCoreVersion = '1.7.0'
activityVersion = '1.5.1'
composeCompilerVersion = '1.3.2'
groupieVersion = "2.9.0"
dokkaVersion = '1.7.20'
}
ext.deps = [
kotlin : [
stdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinVersion}",
],
kotlinX : [
serialization : "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
],
Expand All @@ -20,13 +15,6 @@ ext.deps = [
core : "androidx.activity:activity-ktx:${activityVersion}",
compose: "androidx.activity:activity-compose:${activityVersion}"
],
compose : [
compiler : "androidx.compose.compiler:compiler:$composeCompilerVersion",
bom : "androidx.compose:compose-bom:2023.01.00",
ui : "androidx.compose.ui:ui",
uiTooling: "androidx.compose.ui:ui-tooling",
material : "androidx.compose.material:material"
],
fragment : 'androidx.fragment:fragment-ktx:1.4.1',
material : 'com.google.android.material:material:1.6.1',
recyclerView : 'androidx.recyclerview:recyclerview:1.2.1',
Expand Down
20 changes: 20 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
android-compileSdk = "33"
android-targetSdk = "30"
android-minSdk = "23"
android-gradle = "7.4.2"
composeCompiler = "1.3.2"
kotlin = "1.7.20"

[libraries]
androidx-compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2023.01.00" }
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-material = { module = "androidx.compose.material:material" }

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle" }
android-library = { id = "com.android.library", version.ref = "android-gradle" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

rootProject.name = "charcoal-android"
include ':charcoal-android'
include ':charcoal-android-compose'
Expand Down

0 comments on commit cd47a13

Please sign in to comment.