Skip to content

Instantly share code, notes, and snippets.

@jmfayard
jmfayard / stacktrace.txt
Created September 6, 2019 15:30
Cannot change dependencies of configuration ':classpath' after it has been resolved.
$ cd sample-kotlin
$ gw --stacktrace dependencyUpdates
executing gradlew instead of gradle
> Task :dependencyUpdates FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dependencyUpdates'.
> Cannot change dependencies of configuration ':classpath' after it has been resolved.
object MoshiAdapters {
val moshi : Moshi = Moshi.Builder().build()
inline fun <reified T: Any> moshiAdapter(clazz: Class<T> = T::class.java): Lazy<JsonAdapter<T>>
= lazy { moshi.adapter(clazz) }
val movie: JsonAdapter<Movie> by moshiAdapter()
val user: JsonAdapter<User> by moshiAdapter()

i was thinking how to integrate it with the newest feature

we could have

rejectVersionContaining ("alpha","beta",...)

which would be a shorter version of

@jmfayard
jmfayard / 1.kt
Last active September 22, 2019 05:22
Gradle buildSrcVersions
/** buildSrc/src/main/kotlin/Libs.kt **/
object Libs {
const val okhttp = "com.squareup.okhttp3:okhttp:" + Versions.okhttp
const val okio = "com.squareup.okio:okio:" + Versions.okio
//... all others
}
/** buildSrc/src/main/kotlin/Versions.kt **/
object Versions {
const val okhttp = "3.12.1"
@jmfayard
jmfayard / Mercari-Jmfayard.adoc
Last active November 21, 2018 11:37
Mercari-Jmfayard
# Open a new android project in Android Studio
# From Android Studio, run the gradle task ":properties"
# From the command-line, run
$ ./gradlew :properties
# Check if you see this message
Starting a Gradle Daemon, 1 incompatible could not be reused
# To debug the problem run this
$ ps auxw | grep GradleDaemon
@jmfayard
jmfayard / Config.kt
Last active September 22, 2020 13:15
Gists Gradle-Kotlin-DSL
// buildSrc/src/main/kotlin/Config.kt
object Config {
const val ACTIVITY = "com.mautinoa.cardapp.MainActivity"
const val PACKAGE = "com.mautinoa.cardapp"
const val kotlinVersion = "1.2.71"
object SdkVersions {
val versionCode = 1
val compile = 28
val target = 26
@jmfayard
jmfayard / GooglePlay.kt
Created September 5, 2018 10:48
Custom task with gradle kotlin buildSrc
// buildSrc/src/main/java/GooglePlay.kt
import java.io.File
object GooglePlay {
@JvmStatic
fun updateWhatsNew(projectDir: File, version: String) {
val files: List<File> = listOf(
"src/production/play/en-US/listing/whatsnew-alpha",
@jmfayard
jmfayard / app-component-1.kt
Last active February 15, 2018 16:25
How To Not Use Dagger2
fun app() = AppComponent.instance
interface AppComponent {
val context: Context
val retrofit: Retrofit
val okHttpClient: OkHttpClient
val catRepository: CatRepository
val catService: CatService
val mainThreadScheduler: Scheduler