How can I do this notation but in `buildSrc` inste...
# gradle
a
How can I do this notation but in
buildSrc
instead?
Copy code
implementation(group = "", name = "facebook-login-6.3.0-jetified", ext = "aar")
In buildSrc I can't access the
implementation
function, and I can only do
add("implementation", "put-the-local-aar-here")
, the question is how can I include the local aar through the add function which is only available under only the
buildSrc
?
Found a solution, you can do it through
externalModuleDependencyFor
Copy code
add(
        "implementation",
        externalModuleDependencyFor(
            this,
            group = "",
            ext = "aar",
            name = "facebook-login-6.3.0-jetified",
            classifier = null,
            configuration = null,
            version = null
        )
    )
o
if you apply the kotlin-dsl plugin to buildSrc, you can do it with "implementation"(...) which is very close
a
I think I've applied that already, and I still can't access the
implementation
accessor.
Copy code
plugins {
    `kotlin-dsl`
}
For some reason what's available to a normal project module is not for buildSrc
o
right, it's specifically in double quotes
there's no project context for it to generate accessors from, so it doesn't generate the plain functions
to be clear, this should work:
Copy code
"implementation"(group = "", name = "facebook-login-6.3.0-jetified", ext = "aar")
a
Are you sure? that doesn't seem to be the case for me. Notice I'm speaking about the context of buildSrc, because I'm trying to put several deps on a single function.
Something like
Copy code
fun DependencyHandler.implementFacebook() {
    add(
        "implementation",
        externalModuleDependencyFor(name = "facebook-login-6.3.0-jetified", ext = "aar")
    )
    add(
        "implementation",
        externalModuleDependencyFor(name = "facebook-common-6.3.0-jetified", ext = "aar")
    )
    add(
        "implementation",
        externalModuleDependencyFor(name = "facebook-core-6.3.0-jetified", ext = "aar")
    )
}
And normal usage in a normal project module
Copy code
dependencies {
    implementFacebook()
}
o
yes, I've used it many times before. Though I do believe it's on DependencyHandlerScope, so perhaps if you change your receiver it will work
a
Still don't 😞
o
odd, guess you'll have to make do with that other function then
😞 1
a
Thanks BTW
j
Copy code
internal fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? =
    add("implementation", dependencyNotation)
@Ahmed Ibrahim you can use it for general, but with some modifications you can get implementFacebook too