hi, can somebody help me with running code after b...
# community-support
m
hi, can somebody help me with running code after build has finished? looks like I've solved it I'm looking at thread https://github.com/gradle/gradle/issues/20151 So, the `BuildListener.buildFinished`still works, but is deprecated and thus I'd like to use an officially recommended approach. However data flow actions don't work for me for a (probably stupid) reason
Funny part is that recommended approach is in incubation - anyway, I've added this code to my build.gradle.kts:
Copy code
@Suppress("UnstableApiUsage")
abstract class SoundPlay : FlowAction<FlowParameters> {

    override fun execute(parameters: FlowParameters) {
        println("something happened")
    }
}

@Suppress("UnstableApiUsage")
abstract class SoundFeedbackPlugin : Plugin<Settings> {
    @get:Inject
    protected abstract val flowScope: FlowScope

    override fun apply(settings: Settings) {
        println("apply")
        this.flowScope.always(
            SoundPlay::class.java,
            {
                println("configure")
            })
        }
}
but nothing is printed
Do I need to wire SoundFeedbackPlugin somehow or gradle finds it automatically?
Nevermind, I needed applySoundFeedbackPlugin() in the script
v
Why do you think that flow actions do not work for you, or is that not current anymore? An alternative would be to have a build service that implements
AutoCloseable
and
OperationCompletionListener
and do your logic in the
close()
method. As it is an operation completion listener it is needed until the last task finished and so it will be closed somewhere between the last task finished and the end of the build.
m
I was missing apply<SoundFeedbackPlugin>()
docs are not that specific on details 🙂
but I have another problem now - passing flavor to my action