Skip to content

Instantly share code, notes, and snippets.

@dave-trudes
Last active December 19, 2015 22:09
Show Gist options
  • Save dave-trudes/6025427 to your computer and use it in GitHub Desktop.
Save dave-trudes/6025427 to your computer and use it in GitHub Desktop.
Run Grunt.js build in Maven
<properties>
<js.source.dir>${project.basedir}/src/main/js</js.source.dir>
<js.dist.dir>${js.source.dir}/dist</js.dist.dir>
</properties>
<build>
<finalName>app name</finalName>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target name="building">
<echo>---- NPM INSTALL ----</echo>
<exec executable="cmd" dir="${js.source.dir}" osfamily="windows" failonerror="true">
<arg line="/c npm install"/>
</exec>
<exec executable="bash" dir="${js.source.dir}" osfamily="unix" failonerror="true">
<arg line="-c 'npm install'"/>
</exec>
<echo>---- BOWER INSTALL ----</echo>
<exec executable="cmd" dir="${js.source.dir}" osfamily="windows" failonerror="true">
<arg line="/c npm install"/>
</exec>
<exec executable="bash" dir="${js.source.dir}" osfamily="unix" failonerror="true">
<arg line="-c 'bower install'"/>
</exec>
<echo>---- GRUNT ----</echo>
<exec executable="cmd" dir="${js.source.dir}" osfamily="windows" failonerror="true">
<arg line="/c grunt"/>
</exec>
<exec executable="bash" dir="${js.source.dir}" osfamily="unix" failonerror="true">
<arg line="-c 'grunt'"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Include JS dist directory as webResource -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>${js.dist.dir}</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment