Skip to content

Commit

Permalink
enable explicitApi mode in Android modules (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
RBusarow authored Jul 21, 2021
1 parent 01214f9 commit f762c0c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
13 changes: 13 additions & 0 deletions buildSrc/src/main/kotlin/androidLibrary.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ tasks.withType<KotlinCompile>()
}
}

// https://youtrack.jetbrains.com/issue/KT-37652
tasks
.matching { it is KotlinCompile && !it.name.contains("test", ignoreCase = true) }
.configureEach {
val task = this
if (!project.hasProperty("kotlin.optOutExplicitApi")) {
val kotlinCompile = task as KotlinCompile
if ("-Xexplicit-api=strict" !in kotlinCompile.kotlinOptions.freeCompilerArgs) {
kotlinCompile.kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict"
}
}
}

tasks.withType<Test> {
useJUnitPlatform()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public annotation class ContributesFragment(
)
@Retention(AnnotationRetention.RUNTIME)
@MapKey
annotation class FragmentKey(val value: KClass<out Fragment>)
public annotation class FragmentKey(val value: KClass<out Fragment>)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentFactory
import javax.inject.Provider

class TangleFragmentFactory(
public class TangleFragmentFactory(
private val providerMap: Map<Class<out Fragment>, Provider<@JvmSuppressWildcards Fragment>>,
@TangleFragmentProviderMap
private val assistedProviderMap: Map<Class<out Fragment>, Provider<@JvmSuppressWildcards Fragment>>
Expand Down
4 changes: 2 additions & 2 deletions tangle-fragment-api/src/main/java/tangle/fragment/arg.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tangle.inject.api
package tangle.fragment

import androidx.fragment.app.Fragment

fun <A : Any> Fragment.arg(bundleKey: String) = lazy {
public fun <A : Any> Fragment.arg(bundleKey: String): Lazy<A> = lazy {
@Suppress("UNCHECKED_CAST")
(arguments?.get(bundleKey) as? A)
?: throw IllegalStateException("Bundle does not contain key: $bundleKey")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.savedstate.SavedStateRegistryOwner
import tangle.inject.InternalTangleApi

@InternalTangleApi
class TangleViewModelFactory(
public class TangleViewModelFactory(
owner: SavedStateRegistryOwner,
defaultArgs: Bundle?,
private val tangleViewModelKeys: Set<Class<*>>,
Expand Down Expand Up @@ -65,9 +65,9 @@ class TangleViewModelFactory(
}
}

companion object {
public companion object {

operator fun invoke(
public operator fun invoke(
owner: SavedStateRegistryOwner,
defaultArgs: Bundle?,
defaultFactory: ViewModelProvider.Factory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ import kotlin.reflect.KClass
)
@Retention(AnnotationRetention.RUNTIME)
@MapKey
annotation class ViewModelKey(val value: KClass<out ViewModel>)
public annotation class ViewModelKey(val value: KClass<out ViewModel>)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import tangle.viewmodel.tangle
* the NavController back stack.
*/
@Composable
inline fun <reified VM : ViewModel> tangle(
public inline fun <reified VM : ViewModel> tangle(
viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) {
"No ViewModelStoreOwner was provided via LocalViewModelStoreOwner"
}
Expand Down

0 comments on commit f762c0c

Please sign in to comment.