Skip to content

Commit

Permalink
Merge pull request #719 from supabase-community/gradle-10-1
Browse files Browse the repository at this point in the history
Update Gradle to 10.1 and fix some warnings
  • Loading branch information
jan-tennert authored Sep 9, 2024
2 parents acc27b8 + d7d826b commit a2b0e3c
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.russhwolf.settings.coroutines.toSuspendSettings
* @param settings The [Settings] instance to use. Defaults to [createDefaultSettings].
* @param key The key to use for saving the code verifier.
*/
@OptIn(ExperimentalSettingsApi::class)
class SettingsCodeVerifierCache(
private val settings: Settings = createDefaultSettings(),
private val key: String = SETTINGS_KEY,
Expand All @@ -31,20 +32,16 @@ class SettingsCodeVerifierCache(
}
}

@OptIn(ExperimentalSettingsApi::class)
private val suspendSettings = settings.toSuspendSettings()

@OptIn(ExperimentalSettingsApi::class, ExperimentalSettingsApi::class)
override suspend fun saveCodeVerifier(codeVerifier: String) {
suspendSettings.putString(key, codeVerifier)
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun loadCodeVerifier(): String? {
return suspendSettings.getStringOrNull(key)
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun deleteCodeVerifier() {
suspendSettings.remove(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ private val settingsJson = Json {
* @param key The key to use for saving the session.
* @param json The [Json] instance to use for serialization. Defaults to [settingsJson]. **Important: [JsonBuilder.encodeDefaults] must be set to true.**
*/
@OptIn(ExperimentalSettingsApi::class)
class SettingsSessionManager(
private val settings: Settings = createDefaultSettings(),
private val key: String = SETTINGS_KEY,
Expand All @@ -44,12 +45,10 @@ class SettingsSessionManager(

private val suspendSettings = settings.toSuspendSettings()

@OptIn(ExperimentalSettingsApi::class)
override suspend fun saveSession(session: UserSession) {
suspendSettings.putString(key, json.encodeToString(session))
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun loadSession(): UserSession? {
val session = suspendSettings.getStringOrNull(key) ?: return null
return try {
Expand All @@ -60,7 +59,6 @@ class SettingsSessionManager(
}
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun deleteSession() {
suspendSettings.remove(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ internal class RealtimeChannelImpl(
)
}

@Suppress("UNCHECKED_CAST")
override fun <T : PostgresAction> RealtimeChannel.postgresChangeFlowInternal(
action: KClass<T>,
schema: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ import kotlinx.serialization.json.Json
* A [ResumableCache] implementation using [com.russhwolf.settings.Settings]. This implementation saves the urls on the disk. If you want a memory only cache, use [Memory].
* Unsupported on Linux.
*/
@OptIn(ExperimentalSettingsApi::class)
class SettingsResumableCache(settings: Settings = Settings()) : ResumableCache {

@OptIn(ExperimentalSettingsApi::class)
private val settings = settings.toSuspendSettings()

@OptIn(ExperimentalSettingsApi::class)
override suspend fun set(fingerprint: Fingerprint, entry: ResumableCacheEntry) {
settings.putString(fingerprint.value, Json.encodeToString(entry))
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun get(fingerprint: Fingerprint): ResumableCacheEntry? {
return settings.getStringOrNull(fingerprint.value)?.let {
Json.decodeFromString(it)
}
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun remove(fingerprint: Fingerprint) {
settings.remove(fingerprint.value)
}

@OptIn(ExperimentalSettingsApi::class)
override suspend fun clear() {
settings.keys().forEach {
if(it.split(Fingerprint.FINGERPRINT_SEPARATOR).size == Fingerprint.FINGERPRINT_PARTS) remove(Fingerprint(it) ?: error("Invalid fingerprint $it"))
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
val excludedModules = listOf("plugins", "serializers", "test-common")

fun libraryModules(withBom: Boolean = true, init: Project.() -> Unit) = configure(
allprojects.filter { it.name !in excludedModules && !it.path.contains("sample") && if(withBom) true else it.name != "bom" },
allprojects.filter { it.name !in excludedModules && !it.path.contains("sample") && if(withBom) true else it.name != "bom" && it.name != it.rootProject.name },
init
)

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096m
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.native.ignoreDisabledTargets=true
kotlin.native.ignoreIncorrectDependencies=true
org.gradle.parallel=true
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
1 change: 0 additions & 1 deletion sample/multi-factor-auth/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ kotlin {
}
}
val desktopMain by getting {
dependsOn(nonJsMain)
dependencies {
api(compose.preview)
}
Expand Down

0 comments on commit a2b0e3c

Please sign in to comment.