Home > Net >  Gradle dependencies: Parenthesis vs single/double quotes only
Gradle dependencies: Parenthesis vs single/double quotes only

Time:12-04

When naming dependencies in the Cradle-file: What's the difference between putting the string within parenthesis or just quotes alone.

For example: implementation("io.coil-kt:coil:2.2.2")

Versus: implementation 'com.squareup.moshi:moshi-kotlin:1.9.3'

I see both forms all the time. When do I use which?

CodePudding user response:

Both notation are available and are equivalent , in the Groovy DSL: see explanation here

Reference to this feature in Groovy specifications: https://groovy-lang.org/style-guide.html#_omitting_parentheses

In Koltin DSL, only the method call version (with parenthesis) is available.

"When do I use which? " : personally I prefer using the version with parenthesis , making it simpler to migrate to Kotlin DSL later : https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html#prepare_your_groovy_scripts

  • Related