Marcelo D. Ré
Marcelo D. Ré

Reputation: 191

In gradle custom plugin, how to insert a task between build and war?

I'am creating a custom plugin and I need to execute the war task after another task has finished, but I could note get it to work. Here are the task dependencies:

build: compile the java classes.

prepareFrontEnd: requiere build java classes as input so I added a dependsOn build, and create some files as a result.

buildFrontEnd: require the prepareFrontEnd files as input an create a directory structure with the compiled version of the frontEnd, so I added a dependsOn prepareFrontEnd

and finally

war: I need that this task add the output directories of buildFrontEnd, but if I add a dependsOn or mustRunAfter I get a

FAILURE: Build failed with an exception.

* What went wrong:
Circular dependency between the following tasks:
:assemble
\--- :war
     \--- :buildFrontEnd
          \--- :prepareFrontEnd
               \--- :updatePom
                    \--- :build
                         \--- :assemble (*)

How could I solve this?

Here is the plugin url

Upvotes: 0

Views: 299

Answers (1)

cfrick
cfrick

Reputation: 37008

build usually is the end of the line and usually means assemble + check. And the war usually is part of assemble. So you have to integrate that way sooner. For sure you don't want to have something depend on build - it's usually build (or rather assemble) depends on things.

I'd go: classes <- buildFrontEnd <- prepareFrontEnd <- compileJava to start conservatively.

Try how it looks with gradle -m build and adjust if needed. Other options to chain into:

  • war: most likely not correct, since the files might be useful while running the code in development
  • processResources: usefull if you just generate some JS files that will be sent as static resources later

Upvotes: 2

Related Questions