Project dependency depending on task (Spring Boot, Angular)

I have a multi-project gradle project, one module build a jar out of an angular application, the other one (boot) uses that jar as a dependency.
We have the angular project as dependency because we have to generate a war to deploy.
When we run the bootRun task, however, we don’t need that jar because we start the angular application through npm start, so the case is “how can I remove a dependency based on what task I’m executing”

Dependency resolution is done before the taskGraph is available, so we haven’t the possibility to use taskGraph to detect which task we’re running.
I have tried with Variations, by declaring a variation and then declaring the angular project dependency as each type of the configurations created by the variation, but I couldn’t find how to specify that a particular task requires a particular variation and it seems both build and bootRun take runtime variations, so both take it.
I have tried with Configurations and editing the inputs of build task to include the angular project dependency, but unsuccessfully, the task does not use the configuration.

I’m out of ideas, so I ask for guidance. How can I exclude a dependency from a particular existent task, or how can I add a particular dependency to a particular existent task?