Skip to content

Instantly share code, notes, and snippets.

@marweck
Last active October 21, 2018 22:33
Show Gist options
  • Save marweck/57fe4af47782521aa7e29eb2b62a1720 to your computer and use it in GitHub Desktop.
Save marweck/57fe4af47782521aa7e29eb2b62a1720 to your computer and use it in GitHub Desktop.
Maven exec plugin to invoke npm install and build. Integrating Spring Boot and Angular builds.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/static</outputDirectory>
<resources>
<resource>
<directory>src/main/frontend/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm-install</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
<argument>--silent</argument>
</arguments>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
</execution>
<execution>
<id>npm-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment