Hi, I'm trying to fix firebase app distribution gr...
# community-support
v
Hi, I'm trying to fix firebase app distribution gradle plugin
Copy code
tasks.named("appDistributionUpload${variant.name.capitalize()}").configure {
    artifactPath = output.outputFile.absolutePath
    serviceCredentialsFile = project.file("...").absolutePath
    groups = ...
}
this works for modifying the already registered tasks by plugin, but for my setup, I need to register such tasks myself because plugin doesn't generate all it's supposed to (apk splits) so googling gets me this
Copy code
tasks.register("appDistributionUpload${abiName.capitalize()}${variant.name.capitalize()}", com.google.firebase.appdistribution.gradle.UploadDistributionTask) {
    artifactPath = output.outputFile.absolutePath
    serviceCredentialsFile = project.file("...").absolutePath
    releaseNotes = abi
}
but gradle complains about
Copy code
A problem occurred evaluating project ':app'.
> Could not get unknown property 'com' for project ':app' of type org.gradle.api.Project.
so I presume the
com.google.firebase.appdistribution.gradle.UploadDistributionTask
doesnt exist is there a way to know the correct fully qualified name of the task if I know its name? printing
this
in the
.configure { .. }
just gives me nonsense 😕
v
That could also be a Groovy DSL quirk. Sometimes it does not work if you use FQCN, try to use an import instead. Or even better, switch to Kotlin DSL. 🙂 And for thow to get the type,
gw help --task myTaskName
shows information about the task, its supported CLI arguments and also its type.
v
btw since you're here, do you have any intuition about the related issue i'm seeing? what I'm actually doing now was working in the past, but after I upgraded to latest plugin version the fully qualified name broke, hence me trying to patch it now but, when it was working (i.e. I could call the gradle task via terminal no problem), but in the IDE (Android studio) it sometimes gave me cryptic errors about not knowing the qualified name on IDE sync (yet the task executing worked) is that the quirk you're referring to?
v
No, doesn't ring any bell.
Just remembering that sometimes there were problems with FQCNs
But could be that this was only when it was
java.util.Properties
and so on where then the property
util
was searched in the
java
extension instead of considering it as FQCN
If you would do use Kotlin DSL, then after a successful sync you also have all the classes of plugins in the IDE scope and in external dependencies, so you could simply search for the class in the tree or with "Go To Class"
v
I see.. I'm not a huge fan of kotlin in gradle, it's slower from what I recall & only really helpful once in a blue moon debugging session like this
btw before you gave me the nice
help --task name
I pulled it out like this
Copy code
tasks.register("printTaskClass") {
    doLast {
        def taskName = "appDistributionUploadTstingRelease"  // Replace with the actual task name
        def task = tasks.named(taskName).get()
        if (task != null) {
            println "The class of the task '${taskName}' is ${task.getClass().getName()}"
        } else {
            println "Task '${taskName}' not found."
        }
    }
}
and that gave me
com.google.firebase.appdistribution.gradle.tasks.UploadDistributionTask_Decorated
and your task gave me
com.google.firebase.appdistribution.gradle.tasks.UploadDistributionTask
any idea why the difference? i.e. what's
_Decorated
?
v
I see.. I'm not a huge fan of kotlin in gradle, it's slower from what I recall & only really helpful once in a blue moon debugging session like this
Yeeeah, ..., no. In some situations Groovy is faster, in some situations Kotlin is faster. But the advantages of Kotlin DSL almost always outweigh it majorly. By now it is the default DSL, you immediately get typesafe build scripts, actually helpful error message if you mess up the syntax, and amazingly better IDE support when using a good IDE like IntelliJ IDEA or Android Studio. But hey, to each his tool and sacrifice. 🙂
any idea why the difference?
Of course. 🙂 Because it is decorated. 😛
All types you create through Gradle are decorated automatically with some stuff. For example all those objects are inheriting
ExtensionAware
and thus can get extensions added, whether they declare it or not, you can always cast them, due to that I tend to always also formally make extensions and so on
ExtensionAware
. Or all the Gradle magic is doing for you like implementing the abstract getters and properties, injecting services and so on.
v
I love kotlin but I think the way for gradle to go is the declarative route, atleast for me
v
All these things are in the subclass with the
_Decorated
suffix
Well, the declarative route IS also Kotlin 😄
A restricted subset, but still Kotlin
v
okay so you say I should not subclass the "_Decorated"
v
And well, I don't think it is "the way to go", it mainly is a different DSL
> okay so you say I should not subclass the "_Decorated" You mean register, right? Not subclass
No, you should not even stay aware of the
_Decorated
, that's just an internal detail, just forget about it
v
not sure what the correct terminology is .. register by subclassing?
tasks.register("appDistributionUpload${abiName.capitalize()}${variant.name.capitalize()}", com.google.firebase.appdistribution.gradle.tasks.UploadDistributionTask) {
v
No, register is registering
subclassing is subclassing
class Foo extends UploadDistributionTask {}
is subclassing
tasks.register
just schedules an instance of type
UploadDistributionTask
(actually
UploadDistributionTask_Decorated
) and configuration for it to be created as soon as necessary.
v
gotcha
v
But you cannot access the
..._Decorated
anyway, it it just a runtime decoration of the original class to do the Gradle magic.
v
btw any idea why the default dsl is like this
Copy code
firebaseAppDistribution {
    serviceCredentialsFile = file("...") <--------
}
yet when I register
Copy code
tasks.register("appDistributionUpload${abiName.capitalize()}${variant.name.capitalize()}", com.google.firebase.appdistribution.gradle.tasks.UploadDistributionTask) {
                    serviceCredentialsFile = project.file("....").absolutePath
it forces me to add the
.absolutePath
to make it work?
I'd expect the two to be exactly the same
v
No, I have no idea of firebase or Android development at all
v
nobody does even they don't lol but you'd expect the dsl = extension, to be just sugar for getting the input values from user and registering a task like I do, no?
v
Maybe, maybe not, I have no idea what they are doing and my crystal ball is in the repair shop, sorry 🙂
v
nevermind thank you anyways!
v
But digging out my spare ball, the plugin does call
UploadDistributionTaskConfigurator.configure
with the task and extension as arguments and that method does call
task.serviceCredentialsFile.set(nullOrAbsolutePath(extension.serviceCredentialsFile, project))
, so, ...
And that method resolves a relative path relative to the root project directory
v
so I'm doing it right, thanks!
👌 1
now if you only could help me pressure them to fix their stuff https://github.com/firebase/firebase-android-sdk/issues/5760 😄
v
Yeah, well, I'm not interested yet in firebase or android dev, sorry 🙂
v
worth a shot, thanks 😄
👌 1
btw how did you figure that out? do you see their sources?
v
Sure, decompiled by IntelliJ 🙂
Easily available if you use Kotlin DSL 😉
I just added
id("com.google.firebase.appdistribution") version "4.2.0" apply false
to my play project, synced, and then navigated to the plugin extension and task
v
yay groovy does it too 😄
👌 1
btw the sources seem too nice .. they're probably not minified could I then possible set a breakpoint there?
v
Maybe. At least method breakpoints should work, line breakpoints might
v
and then how do I run it in debug?
v
Press debug?
v
ehm..I'm calling
./gradlew ..
pressing debug executes my current IDE run config..no?
v
Which would be a Grand run config if you run Gradle through the IDE, not command line. So then either run through IDE, for example in the tool window, from the Shift-Shift Run anything dialog. There you can also directly use Shift-Enter to debug instead of run right away. Or if you prefer running from command line, add
-Dorg.gradle.debug=true
and then attach the debugger to 5005