我使用這個插件:
https://github.com/eirslett/frontend-maven-plugin
<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.3</nodeVersion>
<npmVersion>3.8.3</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>--strict-ssl=false install</arguments>
</configuration>
</execution>
<execution>
<id>npm build prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build.prod</arguments>
</configuration>
</execution>
</executions>
</plugin>
NPM build.prod是我一飲而盡任務,建立督促部署和被指定爲我的package.json(腳本我使用角2號種子):https://github.com/mgechev/angular-seed
我不得不創建一個任務複製到一個地方,我的Java應用程序使用靜態文件:
import * as gulp from 'gulp';
let gnf = require('gulp-npm-files');
let resourceDest = 'src/main/resources/public';
export =() => {
gulp.src('**', {cwd:'./dist/prod'}).pipe(gulp.dest(resourceDest));
gulp.src(gnf(), {base:'./'}).pipe(gulp.dest(resourceDest));
};
這複製我編譯的角2 JavaScript到src/main/resources/public