4

I have two project, framework that is Spring boot application, and another is framework-web that contains html layouts and web ui.

I run maven with this goals, clean install to install framework into local repository. Then i want to run maven with goal clean spring-boot:run and this profiles prod, dev on framework-web to start Spring boot application and run gulp task on framework-web. But it runs only gulp tasks, and does not start spring boot application.

This is pom.xml of framework-web:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.rgh</groupId>
    <artifactId>framework-web</artifactId>
    <version>0.0.1-releases</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>

    <properties>
        <start-class>com.rgh.framework.Application</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.rgh</groupId>
            <artifactId>framework</artifactId>
            <version>0.0.1-releases</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>prod</id>
            <build>
                <finalName>framework-web</finalName>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                            <fork>true</fork>
                            <encoding>UTF-8</encoding>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>dev</id>
            <build>
                <finalName>framework-web</finalName>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v4.4.7</nodeVersion>
                                    <npmVersion>3.10.5</npmVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>bower install</id>
                                <goals>
                                    <goal>bower</goal>
                                </goals>
                                <configuration>
                                    <arguments>install --no-color</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>gulp build</id>
                                <goals>
                                    <goal>gulp</goal>
                                </goals>
                                <configuration>
                                    <arguments>serve</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

and this is run configuration in eclipse:

enter image description here

Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71

1 Answers1

4

You're not using the frontend-maven-plugin correctly. This plugin is intended to build your code (transpile/compile/minify/...) during a Maven build. However, it is not intended for tasks like "serve" or "watch" which will keep the process running forever, because this also means your Maven build will run forever.

Also, you don't really need a "serve" task. A "serve" task is useful when you want to run your frontend code in a separate web container. But since you're using Gulp within a Spring boot project, which already has its own web container, you shouldn't create your own.

The solution:

  1. Use the frontend-maven-plugin only for building, not for continuous tasks like serve/watch/...
  2. If you want to have a serve/watch/... task for development, you should run that Gulp task manually. It doesn't require a Maven build. Since you're using Eclipse, you might want to take a look into this plugin (haven't used it myself).
  3. Spring boot is able to serve static webcontent, so if you're using Gulp within a Spring boot/JavaScript project, you don't really need a serve task for Gulp.
  4. If you want to run your static content in a separate webcontainer (not in a Spring boot project), you should separate both projects, and in this case you don't have to use Maven for your frontend project.
g00glen00b
  • 41,995
  • 13
  • 95
  • 133