Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
maven使用com.github.eirslett在maven中构建angular项目_Maven - Fatal编程技术网

maven使用com.github.eirslett在maven中构建angular项目

maven使用com.github.eirslett在maven中构建angular项目,maven,Maven,我的项目结构如下: demo-welcome +-- pom.xml +-- package.json +-- src | +-- files +-- dist | +-- files <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apach

我的项目结构如下:

demo-welcome
 +-- pom.xml
 +-- package.json
 +-- src
 |  +-- files
 +-- dist
 |  +-- files
  <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.denv</groupId>
     <artifactId>demo-welcome</artifactId>
     <packaging>war</packaging>
     <version>1.0</version>
     <name>Welcome Page for Demo</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>
我想要实现的是,在maven的构建阶段,我得到一个目标,该目标生成我的dist文件夹,其中包含最终结果

所以我读了这个例子:

我的package.json中有

"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build --prod",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},
然后,我的pom.xml如下所示:

demo-welcome
 +-- pom.xml
 +-- package.json
 +-- src
 |  +-- files
 +-- dist
 |  +-- files
  <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.denv</groupId>
     <artifactId>demo-welcome</artifactId>
     <packaging>war</packaging>
     <version>1.0</version>
     <name>Welcome Page for Demo</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>
我还尝试从pom中删除所有插件,只运行前端maven插件,但它似乎没有做任何相关的事情,即使没有失败,也没有做任何事情

$ 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] ------------------------------------------------------------------------

我在React项目上也有同样的问题!不过,这只是偶尔发生的,它会通过运行两个连续的Maven构建而消失。我想这与缓存和清理有关