Refresh a project after a task execution

Hi, there,

I am rather new to gradle and hit an issue I cannot work around. Appreciate any pointer.

Context: I am using openApiGenerator plugin to codegen java from swagger spec. What I want to do is to: 1) codegen java 2) build my own codes (which depend on the autogen java codes).

My approach so far: Here’s my folder structure
------ root
|--------openApi
| ------- src
|---------main/java/…
|-------- test/java/…
build.gradle

In my root folder’s build.gradle, I have:

 openApiGenerate task to output the codegen java files under openApi
 declare dependency of: implementation project(":root:openApi")
 tasks.openApiGenerate.finalizedBy ":root:openApi:compileJava"

I intend following things to happen in sequence:

  1. openApiGenerate to codegen, and create build.gradle under openApi folder
  2. run compileJava task under openApi folder
  3. run compileJava task under root folder.

However, it fails at step 2. Looking into the info log, it appears :root:openApi: project configuration happened before openApiGenerate. That makes sense to me because configuration happens before execution. Which begs the questions:

  1. is there a way to let openApiGenerate run BEFORE :root:openApi project configuration? I don’t think it’s possible after reading gradle project life cycle doc. But correct me if I am wrong.
  2. is there a way to force :root:openApi project to reload its configuration after openApiGenerate? maybe via a customized task?

Thank you in advance!