refactor: Enable core library desugaring as build convention logic (#480)
Once desugaring is enabled it needs to be enabled for up/down the dependency chain, so enable it in the shared configuration defined by the build convention code. Highlighted a failing test that wasn't being run, so fix that too.
This commit is contained in:
parent
9a23439d04
commit
af58de5a8f
|
@ -53,10 +53,6 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
resources.excludes.apply {
|
resources.excludes.apply {
|
||||||
add("LICENSE_OFL")
|
add("LICENSE_OFL")
|
||||||
|
@ -116,8 +112,6 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
|
||||||
|
|
||||||
// CachedTimelineRemoteMediator needs the @Transaction annotation from Room
|
// CachedTimelineRemoteMediator needs the @Transaction annotation from Room
|
||||||
compileOnly(libs.bundles.room)
|
compileOnly(libs.bundles.room)
|
||||||
testCompileOnly(libs.bundles.room)
|
testCompileOnly(libs.bundles.room)
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
* see <http://www.gnu.org/licenses>.
|
* see <http://www.gnu.org/licenses>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import app.pachli.libs
|
||||||
import com.android.build.api.dsl.CommonExtension
|
import com.android.build.api.dsl.CommonExtension
|
||||||
import org.gradle.api.JavaVersion
|
import org.gradle.api.JavaVersion
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.dependencies
|
||||||
import org.gradle.kotlin.dsl.provideDelegate
|
import org.gradle.kotlin.dsl.provideDelegate
|
||||||
import org.gradle.kotlin.dsl.withType
|
import org.gradle.kotlin.dsl.withType
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
@ -35,6 +37,12 @@ internal fun Project.configureKotlinAndroid(
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
isCoreLibraryDesugaringEnabled = true
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests {
|
unitTests {
|
||||||
// Without this Robolectric skips some tests with "doesn't support legacy
|
// Without this Robolectric skips some tests with "doesn't support legacy
|
||||||
|
@ -55,6 +63,10 @@ internal fun Project.configureKotlinAndroid(
|
||||||
}
|
}
|
||||||
|
|
||||||
configureKotlin()
|
configureKotlin()
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
add("coreLibraryDesugaring", libs.findLibrary("desugar.jdk.libs").get())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,10 +27,6 @@ android {
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -54,7 +50,6 @@ dependencies {
|
||||||
// Crash reporting in orange (Pachli Current) builds only
|
// Crash reporting in orange (Pachli Current) builds only
|
||||||
orangeImplementation(libs.bundles.acra)
|
orangeImplementation(libs.bundles.acra)
|
||||||
|
|
||||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
|
||||||
orangeCompileOnly(libs.auto.service.annotations)
|
orangeCompileOnly(libs.auto.service.annotations)
|
||||||
kspOrange(libs.auto.service.ksp)
|
kspOrange(libs.auto.service.ksp)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import app.pachli.core.database.dao.InstanceDao
|
||||||
import app.pachli.core.database.model.AccountEntity
|
import app.pachli.core.database.model.AccountEntity
|
||||||
import app.pachli.core.network.model.InstanceConfiguration
|
import app.pachli.core.network.model.InstanceConfiguration
|
||||||
import app.pachli.core.network.model.InstanceV1
|
import app.pachli.core.network.model.InstanceV1
|
||||||
import app.pachli.core.network.model.StatusConfiguration
|
|
||||||
import app.pachli.core.network.retrofit.MastodonApi
|
import app.pachli.core.network.retrofit.MastodonApi
|
||||||
import at.connyduck.calladapter.networkresult.NetworkResult
|
import at.connyduck.calladapter.networkresult.NetworkResult
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
@ -121,29 +120,41 @@ class InstanceInfoRepositoryTest {
|
||||||
assertEquals(customMaximum * 2, instanceInfo.maxChars)
|
assertEquals(customMaximum * 2, instanceInfo.maxChars)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInstanceWithCustomConfiguration(maximumLegacyTootCharacters: Int? = null, configuration: InstanceConfiguration? = null): InstanceV1 {
|
private fun getInstanceWithCustomConfiguration(maximumLegacyTootCharacters: Int? = null, configuration: InstanceConfiguration = InstanceConfiguration()): InstanceV1 {
|
||||||
return InstanceV1(
|
return InstanceV1(
|
||||||
uri = "https://example.token",
|
uri = "https://example.token",
|
||||||
version = "2.6.3",
|
version = "2.6.3",
|
||||||
maxTootChars = maximumLegacyTootCharacters,
|
maxTootChars = maximumLegacyTootCharacters,
|
||||||
pollConfiguration = null,
|
pollConfiguration = null,
|
||||||
configuration = configuration,
|
configuration = configuration,
|
||||||
maxMediaAttachments = null,
|
|
||||||
pleroma = null,
|
pleroma = null,
|
||||||
uploadLimit = null,
|
uploadLimit = null,
|
||||||
rules = emptyList(),
|
rules = emptyList(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCustomInstanceConfiguration(maximumStatusCharacters: Int? = null, charactersReservedPerUrl: Int? = null): InstanceConfiguration {
|
private fun getCustomInstanceConfiguration(
|
||||||
return InstanceConfiguration(
|
maximumStatusCharacters: Int? = null,
|
||||||
statuses = StatusConfiguration(
|
charactersReservedPerUrl: Int? = null,
|
||||||
maxCharacters = maximumStatusCharacters,
|
): InstanceConfiguration {
|
||||||
maxMediaAttachments = null,
|
var result = InstanceConfiguration()
|
||||||
charactersReservedPerUrl = charactersReservedPerUrl,
|
|
||||||
|
maximumStatusCharacters?.let {
|
||||||
|
result = result.copy(
|
||||||
|
statuses = result.statuses.copy(
|
||||||
|
maxCharacters = it,
|
||||||
),
|
),
|
||||||
mediaAttachments = null,
|
|
||||||
polls = null,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
charactersReservedPerUrl?.let {
|
||||||
|
result = result.copy(
|
||||||
|
statuses = result.statuses.copy(
|
||||||
|
charactersReservedPerUrl = it,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,6 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -43,6 +39,4 @@ dependencies {
|
||||||
implementation(libs.moshi)
|
implementation(libs.moshi)
|
||||||
implementation(libs.moshi.adapters)
|
implementation(libs.moshi.adapters)
|
||||||
ksp(libs.moshi.codegen)
|
ksp(libs.moshi.codegen)
|
||||||
// Instant in LogEntryEntity
|
|
||||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,6 @@ android {
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aboutLibraries {
|
aboutLibraries {
|
||||||
|
@ -65,7 +61,4 @@ dependencies {
|
||||||
|
|
||||||
// For FixedSizeDrawable
|
// For FixedSizeDrawable
|
||||||
implementation(libs.glide.core)
|
implementation(libs.glide.core)
|
||||||
|
|
||||||
// For Instant.now() in NotificationLogFragment
|
|
||||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue