frontend-maven-plugin执行了两次

时间:2017-07-19 05:32:10

标签: java maven

当我发出followign命令时,

frontend-maven-plugin被执行了两次 -

mvn clean install package -DenvType=local2

我的pom.xml -

<?xml version="1.0" encoding="UTF-8"?>
<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.awpl</groupId>
  <artifactId>pva-nb-uw-ui</artifactId>
  <packaging>war</packaging>
  <version>0.2.0</version>

  <profiles>
    <profile>
      <id>local</id>
      <activation>
        <property>
          <name>envType</name>
          <value>local</value>
        </property>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <envType>local</envType>
      </properties>
    </profile>
    <profile>
      <id>local2</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <envType>local2</envType>
      </properties>
    </profile>
    <profile>
      <id>dev</id>
      <activation>
        <property>
          <name>envType</name>
          <value>dev</value>
        </property>
      </activation>
      <properties>
        <envType>dev</envType>
      </properties>
    </profile>
    <profile>
      <id>sit</id>
      <activation>
        <property>
          <name>envType</name>
          <value>sit</value>
        </property>
      </activation>
      <properties>
        <envType>sit</envType>
      </properties>
    </profile>
    <profile>
      <id>uat</id>
      <activation>
        <property>
          <name>envType</name>
          <value>uat</value>
        </property>
      </activation>
      <properties>
        <envType>uat</envType>
      </properties>
    </profile>
  </profiles>

  <build>
    <finalName>pva-ui-webapp</finalName>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.4</version>
        <!-- <configuration> <installDirectory>target</installDirectory> 
          </configuration> -->
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <nodeVersion>v6.10.0</nodeVersion>
              <npmVersion>3.10.10</npmVersion>
            </configuration>
          </execution>
          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>bower install</id>
            <goals>
              <goal>bower</goal>
            </goals>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>gulp build</id>
            <goals>
              <goal>gulp</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>optimize --env ${envType}</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

命令的输出 -

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building artifactname 0.2.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ artifactname ---
[INFO] Deleting D:\Softwares\workspace_eclipse\artifactname\target
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:install-node-and-npm (install node and npm) @ artifactname ---
[INFO] Node v6.10.0 is already installed.
[INFO] NPM 3.10.10 is already installed.
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:npm (npm install) @ artifactname ---
[INFO] Running 'npm install' in D:\Softwares\workspace_eclipse\artifactname
[WARNING] npm WARN artifactname@0.2.0 No repository field.
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:bower (bower install) @ artifactname ---
[INFO] Running 'bower install' in D:\Softwares\workspace_eclipse\artifactname
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:gulp (gulp build) @ artifactname ---
[INFO] Running 'gulp optimize --env local2' in D:\Softwares\workspace_eclipse\artifactname
[INFO] [10:50:06] Using gulpfile D:\Softwares\workspace_eclipse\artifactname\gulpfile.js
[INFO] [10:50:06] Starting 'lintjs'...
[INFO] [10:50:06] Analyzing JS files
[INFO] [10:50:06] Starting 'linthtml'...
[INFO] [10:50:06] Analyzing HTML files
[INFO] [10:50:06] Starting 'lintcss'...
[INFO] [10:50:06] Analyzing CSS files
[INFO] [10:50:06] Starting 'lintjson'...
[INFO] [10:50:06] Analyzing JSON files
[INFO] [10:50:06] Starting 'clean'...
[INFO] [10:50:06] cleaning ./src/main/webapp/js/,./src/main/webapp/fonts/,./src/main/webapp/resources/,./src/main/webapp/styles/,./src/main/webapp/index.html,./src/main/webapp/rev-manifest.json,./.tmp/
[ERROR] The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information
[INFO] [10:50:07] Finished 'clean' after 1.13 s
[INFO] [10:50:07] Starting 'jsoncopy'...
[INFO] [10:50:07] copying and minifying json resources
[INFO] [10:50:10] Finished 'lintcss' after 3.37 s
[INFO] [10:51:12] Finished 'lintjson' after 1.1 min
[INFO] [10:51:13] Finished 'jsoncopy' after 1.08 min
[INFO] [10:51:13] Starting 'htmlcopy'...
[INFO] [10:51:13] copying html files for making it ready for templatecache
[INFO] [10:51:14] Finished 'linthtml' after 1.12 min
[INFO] [10:51:16] Finished 'lintjs' after 1.17 min
[INFO] [10:51:16] Starting 'wireindex'...
[INFO] [10:51:16] Linking all js/css files into index.html
[INFO] [10:51:17] gulp-inject 100 files into index.html.
[INFO] [10:51:17] gulp-inject 3 files into index.html.
[INFO] [10:51:17] Finished 'wireindex' after 705 ms
[INFO] [10:51:17] Finished 'htmlcopy' after 3.21 s
[INFO] [10:51:17] Starting 'fontscopy'...
[INFO] [10:51:17] copying bootstrap and other fonts
[INFO] [10:51:17] Finished 'fontscopy' after 224 ms
[INFO] [10:51:17] Starting 'templatecache'...
[INFO] [10:51:17] creating AngularJS $templateCache
[INFO] [10:51:18] Finished 'templatecache' after 824 ms
[INFO] [10:51:18] Starting 'optimize'...
[INFO] [10:51:18] optimizing the js/html/css files
[INFO] [10:51:19] gulp-inject 1 files into index.html.
[INFO] [10:51:31] Finished 'optimize' after 13 s
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ artifactname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Softwares\workspace_eclipse\artifactname\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ artifactname ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ artifactname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Softwares\workspace_eclipse\artifactname\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ artifactname ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ artifactname ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ artifactname ---
[INFO] Packaging webapp
[INFO] Assembling webapp [artifactname] in [D:\Softwares\workspace_eclipse\artifactname\target\pva-ui-webapp]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Softwares\workspace_eclipse\artifactname\src\main\webapp]
[INFO] Webapp assembled in [600 msecs]
[INFO] Building war: D:\Softwares\workspace_eclipse\artifactname\target\pva-ui-webapp.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ artifactname ---
[INFO] Installing D:\Softwares\workspace_eclipse\artifactname\target\pva-ui-webapp.war to C:\Users\Admin\.m2\repository\com\mycompany\artifactname\0.2.0\artifactname-0.2.0.war
[INFO] Installing D:\Softwares\workspace_eclipse\artifactname\pom.xml to C:\Users\Admin\.m2\repository\com\mycompany\artifactname\0.2.0\artifactname-0.2.0.pom
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:install-node-and-npm (install node and npm) @ artifactname ---
[INFO] Node v6.10.0 is already installed.
[INFO] NPM 3.10.10 is already installed.
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:npm (npm install) @ artifactname ---
[INFO] Running 'npm install' in D:\Softwares\workspace_eclipse\artifactname
[WARNING] npm WARN artifactname@0.2.0 No repository field.
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:bower (bower install) @ artifactname ---
[INFO] Running 'bower install' in D:\Softwares\workspace_eclipse\artifactname
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:gulp (gulp build) @ artifactname ---
[INFO] Running 'gulp optimize --env local2' in D:\Softwares\workspace_eclipse\artifactname
[INFO] [10:51:48] Using gulpfile D:\Softwares\workspace_eclipse\artifactname\gulpfile.js
[INFO] [10:51:48] Starting 'lintjs'...
[INFO] [10:51:48] Analyzing JS files
[INFO] [10:51:49] Starting 'linthtml'...
[INFO] [10:51:49] Analyzing HTML files
[INFO] [10:51:49] Starting 'lintcss'...
[INFO] [10:51:49] Analyzing CSS files
[INFO] [10:51:49] Starting 'lintjson'...
[INFO] [10:51:49] Analyzing JSON files
[INFO] [10:51:49] Starting 'clean'...
[INFO] [10:51:49] cleaning ./src/main/webapp/js/,./src/main/webapp/fonts/,./src/main/webapp/resources/,./src/main/webapp/styles/,./src/main/webapp/index.html,./src/main/webapp/rev-manifest.json,./.tmp/
[ERROR] The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information
[INFO] [10:51:50] Finished 'clean' after 1.05 s
[INFO] [10:51:50] Starting 'jsoncopy'...
[INFO] [10:51:50] copying and minifying json resources
[INFO] [10:51:52] Finished 'lintcss' after 3.29 s
[INFO] [10:52:56] Finished 'lintjson' after 1.12 min
[INFO] [10:52:58] Finished 'jsoncopy' after 1.12 min
[INFO] [10:52:58] Starting 'htmlcopy'...
[INFO] [10:52:58] copying html files for making it ready for templatecache
[INFO] [10:52:58] Finished 'linthtml' after 1.13 min
[INFO] [10:53:00] Finished 'lintjs' after 1.18 min
[INFO] [10:53:00] Starting 'wireindex'...
[INFO] [10:53:00] Linking all js/css files into index.html
[INFO] [10:53:01] gulp-inject 100 files into index.html.
[INFO] [10:53:01] gulp-inject 3 files into index.html.
[INFO] [10:53:01] Finished 'wireindex' after 568 ms
[INFO] [10:53:01] Finished 'htmlcopy' after 3.04 s
[INFO] [10:53:01] Starting 'fontscopy'...
[INFO] [10:53:01] copying bootstrap and other fonts
[INFO] [10:53:01] Finished 'fontscopy' after 182 ms
[INFO] [10:53:01] Starting 'templatecache'...
[INFO] [10:53:01] creating AngularJS $templateCache
[INFO] [10:53:02] Finished 'templatecache' after 805 ms
[INFO] [10:53:02] Starting 'optimize'...
[INFO] [10:53:02] optimizing the js/html/css files
[INFO] [10:53:02] gulp-inject 1 files into index.html.
[INFO] [10:53:15] Finished 'optimize' after 13 s
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ artifactname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Softwares\workspace_eclipse\artifactname\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ artifactname ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ artifactname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Softwares\workspace_eclipse\artifactname\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ artifactname ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ artifactname ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ artifactname ---
[INFO] Packaging webapp
[INFO] Assembling webapp [artifactname] in [D:\Softwares\workspace_eclipse\artifactname\target\pva-ui-webapp]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Softwares\workspace_eclipse\artifactname\src\main\webapp]
[INFO] Webapp assembled in [312 msecs]
[INFO] Building war: D:\Softwares\workspace_eclipse\artifactname\target\pva-ui-webapp.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:27 min
[INFO] Finished at: 2017-07-19T10:53:15+05:30
[INFO] Final Memory: 12M/122M
[INFO] ------------------------------------------------------------------------

请注意,frontend-maven-plugin执行了两次。这几乎使构建时间翻倍。

如何让它只运行一次?

1 个答案:

答案 0 :(得分:2)

您将获得多次执行,因为您在命令行上指定了多个默认生命周期阶段:

 mvn clean install package -DenvType=local2

这将:

  1. 运行clean生命周期;

  2. 运行default生命周期,包括install(包括package);

  3. 再次运行default生命周期,包括package

  4. 有关详细信息,请参阅Introduction to the Build Lifecycle