'How To Build React App Through Gradle Task

I am a new in gradle task creation.I am using Spring application as backend and in frontend I am using React App.So now My question is how can I build react app using npm run build through gradle task and copy the build folder to the wepapp folder which is present inside the spring application(<project_path>src\main\webapp).My Backend folder and Frontend folder present in same folder.Just like below,

<project_path>/Backend

<project_path>/Frontend

Or is there any other solution do achieve the above? beacuse everytime I need to run the build cmd and copy the build folder to the webapp folder.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source