Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 2.0 and modernize things #43

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
registries: "*"
labels: [ "version update" ]
groups:
kotlin-ksp-compose:
patterns:
- "org.jetbrains.kotlin:*"
- "org.jetbrains.kotlin.jvm"
- "com.google.devtools.ksp"
- "androidx.compose.compiler:compiler"
open-pull-requests-limit: 10
registries:
maven-google:
type: "maven-repository"
url: "https://maven.google.com"
replaces-base: true
34 changes: 18 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Pull Request
name: Build

on:
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]

Expand All @@ -9,28 +12,27 @@ permissions:
actions: read

jobs:
build:
check-style:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

- name: Setup JDK
uses: actions/setup-java@v4
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- uses: gradle/actions/setup-gradle@v4
- name: Check spotless
run: ./gradlew spotlessCheck

build:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4
- name: Build App
run: ./gradlew :app:assembleDebug
15 changes: 15 additions & 0 deletions .github/workflows/gradle-wrapper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: gradle-wrapper

on:
pull_request:
paths:
- 'gradlew'
- 'gradlew.bat'
- 'gradle/wrapper/'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
.gradle
.kotlin
/local.properties
/.idea/androidTestResultsUserPreferences.xml
/.idea/caches
Expand Down
19 changes: 3 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@
* limitations under the License.
*/

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.baselineprofile)
alias(libs.plugins.hilt)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.kotlinCompose)
alias(libs.plugins.ksp)
alias(libs.plugins.secrets)
}

kotlin {
jvmToolchain(17)
}

secrets {
defaultPropertiesFileName = "secret.defaults.properties"
}

android {
namespace = "com.google.android.samples.socialite"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "com.google.android.samples.socialite"
Expand All @@ -52,19 +48,11 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf("-Xcontext-receivers")
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
buildConfig = true
}
packaging {
resources {
Expand Down Expand Up @@ -115,7 +103,6 @@ dependencies {

implementation(libs.lifecycle.ktx)
implementation(libs.lifecycle.compose)
implementation(libs.lifecycle.runtime.compose)

ksp(libs.room.compiler)
implementation(libs.room.ktx)
Expand Down
11 changes: 1 addition & 10 deletions baselineprofile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ plugins {

android {
namespace = "com.google.android.samples.socialite.baselineprofile"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}
compileSdk = 35

defaultConfig {
minSdk = 28
Expand Down
12 changes: 10 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@

import com.diffplug.gradle.spotless.SpotlessExtension

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidTest) apply false
alias(libs.plugins.baselineprofile) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.kotlinCompose) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.ksp) apply false
}

subprojects {
allprojects {
// Configure Java to use our chosen language level. Kotlin will automatically pick this up.
// See https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
plugins.withType<JavaBasePlugin>().configureEach {
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
}

plugins.apply(rootProject.libs.plugins.spotless.get().pluginId)
configure<SpotlessExtension> {
kotlin {
Expand Down
31 changes: 8 additions & 23 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
# Disable buildFeatures flags by default
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

kotlin.code.style=official

org.gradle.caching=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g
org.gradle.parallel=true
# Enable configuration cache
org.gradle.configuration-cache=true
59 changes: 28 additions & 31 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,42 @@
# limitations under the License.

[versions]
accompanist = "0.32.0"
activity = "1.9.0-rc01"
agp = "8.2.2"
benchmarkMacroJunit4 = "1.2.3"
baselineprofile = "1.2.3"
accompanist = "0.34.0"
activity = "1.9.1"
agp = "8.6.0"
benchmarkMacroJunit4 = "1.3.0"
baselineprofile = "1.3.0"
camera = "1.4.0-SNAPSHOT"
cameraViewfinderCompose = "1.0.0-SNAPSHOT"
coil = "2.4.0"
compose_bom = "2024.04.00"
composeCompiler = "1.5.4" # Used in app/build.gradle.kts
compose-foundation = "1.6.0-beta03"
concurrent = "1.1.0"
core = "1.12.0"
coil = "2.7.0"
compose_bom = "2024.08.00"
concurrent = "1.2.0"
core = "1.13.1"
core-splashscreen = "1.0.1"
espresso = "3.5.1"
graphics = "1.0.0-alpha05"
hilt = "2.49"
espresso = "3.6.1"
graphics = "1.0.0"
hilt = "2.52"
hiltNavigationCompose = "1.2.0"
junit = "4.13.2"
kotlin = "1.9.20"
ksp = "1.9.20-1.0.14"
lifecycle = "2.7.0"
kotlin = "2.0.20"
ksp = "2.0.20-1.0.24"
lifecycle = "2.8.4"
material3 = "1.2.1"
media3 = "1.4.0-rc01"
navigation = "2.8.0-alpha07"
media3 = "1.4.1"
navigation = "2.8.0-rc01"
profileinstaller = "1.3.1"
room = "2.6.1"
spotless = "6.24.0"
test = "1.1.5"
truth = "1.1.3"
turbine = "1.0.0"
spotless = "6.25.0"
test = "1.2.1"
truth = "1.4.4"
turbine = "1.1.0"
uiautomator = "2.3.0"
window = "1.2.0"
material3-adaptive-navigation-suite = "1.0.0-alpha05"
glance = "1.1.0-alpha01"
window = "1.3.0"
material3-adaptive-navigation-suite = "1.0.0-alpha07"
glance = "1.1.0"
secrets = "2.0.1"
generativeai = "0.7.0"
datastore = "1.0.0"

generativeai = "0.9.0"
datastore = "1.1.1"

[libraries]
accompanist-painter = { group = "com.google.accompanist", name = "accompanist-drawablepainter", version.ref = "accompanist" }
Expand Down Expand Up @@ -92,7 +89,6 @@ hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-com
junit = { group = "junit", name = "junit", version.ref = "junit" }
lifecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" }
lifecycle-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
media3-common = { group = "androidx.media3", name = "media3-common", version.ref = "media3" }
media3-effect = { group = "androidx.media3", name = "media3-effect", version.ref = "media3" }
media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
Expand All @@ -108,7 +104,7 @@ truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiautomator" }
window = { group = "androidx.window", name = "window", version.ref = "window" }
ktlint = "com.pinterest.ktlint:ktlint-cli:1.1.1" # Used in build.gradle.kts
ktlint = "com.pinterest.ktlint:ktlint-cli:1.2.1" # Used in build.gradle.kts
generativeai = { group = "com.google.ai.client.generativeai", name = "generativeai", version.ref = "generativeai"}
datastore = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore"}

Expand All @@ -118,6 +114,7 @@ androidTest = { id = "com.android.test", version.ref = "agp" }
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinCompose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Dec 08 17:47:03 JST 2022
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading