|
<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>phillipgreenii</groupId> |
|
<artifactId>npm-to-maven-adapator</artifactId> |
|
<version>0.0.1-SNAPSHOT</version> |
|
<packaging>war</packaging> |
|
<properties> |
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|
<maven.test.skip>false</maven.test.skip> |
|
<gulp.output.directory>target/gulp</gulp.output.directory> |
|
</properties> |
|
<build> |
|
<plugins> |
|
<!-- Standard plugin to generate WAR --> |
|
<plugin> |
|
<groupId>org.apache.maven.plugins</groupId> |
|
<artifactId>maven-war-plugin</artifactId> |
|
<version>2.1.1</version> |
|
<configuration> |
|
<failOnMissingWebXml>false</failOnMissingWebXml> |
|
<webResources> |
|
<resource> |
|
<directory>${gulp.output.directory}</directory> |
|
</resource> |
|
</webResources> |
|
</configuration> |
|
</plugin> |
|
|
|
|
|
<plugin> |
|
<groupId>org.codehaus.mojo</groupId> |
|
<artifactId>exec-maven-plugin</artifactId> |
|
<version>1.3.2</version> |
|
<executions> |
|
<!-- Required: The following will ensure `npm install` is called |
|
before anything else during the 'Default Lifecycle' --> |
|
<execution> |
|
<id>npm install (initialize)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>initialize</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>install</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
<!-- Required: The following will ensure `npm install` is called |
|
before anything else during the 'Clean Lifecycle' --> |
|
<execution> |
|
<id>npm install (clean)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>pre-clean</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>install</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Optional: The following will output the npm configuration. |
|
I do this so my CI logs will show the npm information used |
|
for the build --> |
|
<execution> |
|
<id>npm config list (validate)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>validate</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>config</argument> |
|
<argument>list</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Required: This following calls `npm run build` where 'build' is |
|
the script name I used in my project, change this if yours is |
|
different --> |
|
<execution> |
|
<id>npm run build (compile)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>compile</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>run</argument> |
|
<argument>build</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Optional: The following runs the script that copies the |
|
appropriate files from the npm build directory into the location |
|
'maven-war-plugin' is expecting. The copying could be done |
|
during the 'build' script, but I like to keep it separate. |
|
Idealy in the future, I won't need maven at which, I can just |
|
delete the 'prepare-for-maven-war' script. --> |
|
<execution> |
|
<id>npm run prepare-for-maven (prepare-package)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>prepare-package</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>run</argument> |
|
<argument>prepare-for-maven-war</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Optional: The following will publish to npm if you run |
|
`mvn deploy`. --> |
|
<execution> |
|
<id>npm run publish (deploy)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>deploy</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>publish</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Required: The following will run unit tests. My test scripts |
|
in npm look for the property 'skipTests', so I map it to |
|
'maven.test.skip' |
|
Note: the douple '-' syntax used below only works with npm >= 2. --> |
|
<execution> |
|
<id>npm run test (test)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>test</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>run</argument> |
|
<argument>test</argument> |
|
<argument>--</argument> |
|
<argument>--skipTests=${maven.test.skip}</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
|
|
<!-- Required: The following calls the npm script that cleans |
|
up the build. --> |
|
<execution> |
|
<id>npm run clean (clean)</id> |
|
<goals> |
|
<goal>exec</goal> |
|
</goals> |
|
<phase>clean</phase> |
|
<configuration> |
|
<executable>npm</executable> |
|
<arguments> |
|
<argument>run</argument> |
|
<argument>clean</argument> |
|
</arguments> |
|
</configuration> |
|
</execution> |
|
</executions> |
|
|
|
<configuration> |
|
<environmentVariables> |
|
<!-- The following parameters create an NPM sandbox for CI --> |
|
<NPM_CONFIG_PREFIX>${basedir}/npm</NPM_CONFIG_PREFIX> |
|
<NPM_CONFIG_CACHE>${NPM_CONFIG_PREFIX}/cache</NPM_CONFIG_CACHE> |
|
<NPM_CONFIG_TMP>${project.build.directory}/npmtmp</NPM_CONFIG_TMP> |
|
</environmentVariables> |
|
</configuration> |
|
</plugin> |
|
</plugins> |
|
</build> |
|
</project> |
This looks interesting as I'm working on integrating a vue.js project as a deliverable package with along side a maven based backend service, but in this case it isn't a WAR file and so we only need to package up the vue.js after it is built. I just wonder how your maven project structure looks, did you put the source code for your node projects under a
src/ui
folder as mentioned in thefrontend-maven-plugin
or if you have some other structure?