Madasu K Madasu K - 3 months ago 43
AngularJS Question

easing the gradle build process in deploying spring boot and angular js application

I am working on gradle based spring boot and angularjs project. I have all my angularjs code in

static
folder which is committed to Git. We need to deploy it into a server which does not have access to internet. So I have generated
dist
contents using
gulp serve:dist
and replaced the contents in the
static
folder with the contents of
dist
folder. Then I have generated jar file and deployed in server.

So it is becoming manually cumbersome every time to replace the contents of
static
folder with the contents of
dist
generating jar file then removing the
dist
folder contents from
static
folder and then replacing it with original angular js code.

Is there any possibility to generate the jar file directly using the contents from
dist
folder instead using the contents in
static
folder?

I am not sure whether I made the problem clear or not. Please update me if you need any further clarification.

Answer

If you are using Spring Boot with standalone JAR deployment, you just need to output front-end assets into src/main/resources/static and Spring Boot will serve them via embedded container.

You can use Gradle Gulp Plugin to execute Gulp build as task within main Gradle build.

Reaction on comment:

Mentioned static folder of course contains only assets you intend to serve by Spring Boot. It wouldn't contain code or anything else. You can have your code in e.g. [projectRoot]/jsSrc. Just Gulp needs to know where to find these files.

We are using such directory structure without any problems (with CI build running on every commit). If manual action is needed to build project, your build is fundamentally broken. In this case your issue is misplaced JS source files.

Comments