From 20c4545874c2f2c84d61b1f4b8f04fe584b82dd7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 17 Jun 2023 21:53:56 -0700 Subject: [PATCH] Add spotless --- app-compose/build.gradle | 2 ++ .../kotlin/com/pitchedapps/frost/FrostApp.kt | 7 +++---- .../com/pitchedapps/frost/StartActivity.kt | 20 ++++++++++++++++--- build.gradle | 1 + gradle.properties | 11 ++++++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- spotless.gradle | 2 +- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app-compose/build.gradle b/app-compose/build.gradle index ee52e8ff8..85ac7ee8c 100644 --- a/app-compose/build.gradle +++ b/app-compose/build.gradle @@ -6,6 +6,8 @@ plugins { id "com.google.devtools.ksp" } +apply from: '../spotless.gradle' + android { compileSdk 33 diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index 20fdc49f4..585731ef4 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Allan Wang + * Copyright 2023 Allan Wang * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +19,8 @@ package com.pitchedapps.frost import android.app.Activity import android.app.Application import android.os.Bundle -import android.util.Log import com.google.common.flogger.FluentLogger import dagger.hilt.android.HiltAndroidApp -import java.util.Random -import javax.inject.Inject @HiltAndroidApp class FrostApp : Application() { @@ -35,7 +32,9 @@ class FrostApp : Application() { registerActivityLifecycleCallbacks( object : ActivityLifecycleCallbacks { override fun onActivityPaused(activity: Activity) {} + override fun onActivityResumed(activity: Activity) {} + override fun onActivityStarted(activity: Activity) {} override fun onActivityDestroyed(activity: Activity) { diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index a483aeab8..1a27ef8f1 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -1,8 +1,22 @@ +/* + * Copyright 2023 Allan Wang + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package com.pitchedapps.frost import androidx.appcompat.app.AppCompatActivity import dagger.hilt.android.AndroidEntryPoint -@AndroidEntryPoint -class StartActivity : AppCompatActivity() { -} +@AndroidEntryPoint class StartActivity : AppCompatActivity() {} diff --git a/build.gradle b/build.gradle index 5141d2997..deab326c1 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,7 @@ plugins { id 'org.jetbrains.kotlin.android' version '1.8.21' apply false // https://mvnrepository.com/artifact/com.google.devtools.ksp/com.google.devtools.ksp.gradle.plugin id 'com.google.devtools.ksp' version '1.8.21-1.0.11' apply false + id 'com.diffplug.spotless' version '6.19.0' apply false } tasks.register('clean', Delete) { diff --git a/gradle.properties b/gradle.properties index 14663b9aa..af0dcf3a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # 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 -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +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 @@ -19,4 +19,11 @@ APP_GROUP=com.pitchedapps KAU=00595a89 android.useAndroidX=true -android.enableJetifier=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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3ffebc84b..ff9ef3c44 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/spotless.gradle b/spotless.gradle index 1f31b7912..603ea645b 100644 --- a/spotless.gradle +++ b/spotless.gradle @@ -3,7 +3,7 @@ apply plugin: "com.diffplug.spotless" spotless { kotlin { target "**/*.kt" - ktfmt(kau.Versions.ktfmt).googleStyle() + ktfmt().googleStyle() licenseHeaderFile '../spotless.license.kt' trimTrailingWhitespace() endWithNewline()