maven中的maven build angular项目与com.github.eirslett什么都不做

时间:2018-03-02 04:48:21

标签: maven

我的项目结构是这样的:

demo-welcome
 +-- pom.xml
 +-- package.json
 +-- src
 |  +-- files
 +-- dist
 |  +-- files

我想要实现的是,在maven的构建阶段,我得到一个目标,用最终结果生成我的dist文件夹。

所以我正在读这个例子: build angular 2 project in maven

我的package.json

"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build --prod",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},

然后我的pom.xml看起来像这样:

  <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/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.avaloq.denv</groupId>
     <artifactId>demo-welcome</artifactId>
     <packaging>war</packaging>
     <version>1.0</version>
     <name>Welcome Page for Sales</name>
     <url>http://maven.apache.org</url>
     <build>
        <finalName>demo-welcome</finalName>
        <pluginManagement>
           <plugins>
              <plugin>
                  <groupId>com.github.eirslett</groupId>
                  <artifactId>frontend-maven-plugin</artifactId>
                  <executions>
                    <execution>
                      <id>ng build</id>
                      <goals>
                          <goal>npm</goal>
                      </goals>
                      <phase>generate-resources</phase>
                      <configuration>
                          <arguments>run build</arguments>
                      </configuration>
                    </execution>
                  </executions>
              </plugin>
              <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <configuration>
                    <webXml>WEB-INF/web.xml</webXml>
                    <webResources>
                       <resource>
                          <directory>dist</directory>
                       </resource>
                    </webResources>
                    <encoding>UTF-8</encoding>
                 </configuration>
                 <executions>
                   <execution>
                     <phase>package</phase>
                   </execution>
                 </executions>
              </plugin>
           </plugins>
        </pluginManagement>
     </build>
  </project>

我的想法是让NPM构建创建我的dist文件夹,然后将其打包

但似乎frontend-maven-plugin从未真正运行过,我不明白为什么。

这是输出

$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Welcome Page for Sales 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo-welcome ---
[INFO] Deleting C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-welcome ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo-welcome ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demo-welcome ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ demo-welcome ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ demo-welcome ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ demo-welcome ---
[INFO] Packaging webapp
[INFO] Assembling webapp [demo-welcome] in [C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\target\demo-welcome]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\dist] to [C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\target\demo-welcome]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.052 s
[INFO] Finished at: 2018-03-02T12:38:11+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project demo-welcome: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.2:war failed: basedir C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\dist does not exist -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

我还尝试从pom中运行删除所有插件并仅运行frontend-maven-plugin,但它似乎与它没有任何关系,即使它没有失败也没有做任何事情。

$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Welcome Page for Sales 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo-welcome ---
[INFO] Deleting C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-welcome ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo-welcome ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demo-welcome ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ demo-welcome ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ demo-welcome ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ demo-welcome ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\dev\repo\bitbucket\denv\denv-ccp\demo-welcome\target\demo-welcome.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.329 s
[INFO] Finished at: 2018-03-02T12:45:03+08:00
[INFO] Final Memory: 13M/205M
[INFO] ------------------------------------------------------------------------

0 个答案:

没有答案