2015-01-15 1 views
4

나는 Maven과 frontend-maven-plugin (com.github.eirslett)을 사용하는 프로젝트를 가지고있다.빌드 폴더에만 maven 실행을 대상으로 지정하는 방법은 무엇입니까?

나는 플러그인 실행에서 mvn install 모든 실행을 실행으로, 그들은 실제 프론트 엔드 코드 인 src/main/webapp 루트에서 node_modules, bower_componentsnode 폴더를 만들 수 있습니다.

것은 내가 아니라 그것은 자바 라이브러리 않는 것처럼 아닌 버전 응용 프로그램 코드에서 build 디렉토리에 생성 된 패키지를 실행하고 war 사람들을 만들 mvn install에 원이다.

달성 할 수있는 방법이 있습니까?

<build> 
    <directory>build</directory> 
    <outputDirectory>build/classes</outputDirectory> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <source>${java.version}</source> 
       <target>${java.version}</target> 
       <encoding>UTF-8</encoding> 
       <webResources> 
        <resource> 
         <filtering>true</filtering> 
         <directory>src/main/webapp</directory> 
         <includes> 
          <include>WEB-INF/weblogic.xml</include> 
         </includes> 
        </resource> 
       </webResources> 
      </configuration> 
     </plugin> 
     ... 
     <plugin> 
      <groupId>com.github.eirslett</groupId> 
      <artifactId>frontend-maven-plugin</artifactId> 
      <version>0.0.20</version> 

      <configuration> 
       <workingDirectory>src/main/webapp</workingDirectory> 
      </configuration> 

      <executions> 
       <execution> 
        <id>install node and npm</id> 
        <goals> 
         <goal>install-node-and-npm</goal> 
        </goals> 
        <configuration> 
         <nodeVersion>v0.10.34</nodeVersion> 
         <npmVersion>2.1.11</npmVersion> 
        </configuration> 
       </execution> 

       <execution> 
        <id>npm install</id> 
        <goals> 
         <goal>npm</goal> 
        </goals> 
        <configuration> 
         <arguments>install</arguments> 
        </configuration> 
       </execution> 

       <execution> 
        <id>bower install</id> 
        <goals> 
         <goal>bower</goal> 
        </goals> 
        <configuration> 
         <arguments>install</arguments> 
        </configuration> 
       </execution> 

       <execution> 
        <id>grunt build</id> 
        <goals> 
         <goal>grunt</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     ... 
    </plugins> 
</build> 
+1

당신은 혼자이와 있습니다. 수락을 기다리는 풀 요청이있는 공개 문제 https://github.com/eirslett/frontend-maven-plugin/issues/18이 있습니다. https://github.com/cfmobile/frontend-maven-plugin/commit/52b7b28d1b8fd449f63ced3d0ed792fde22c041b – xverges

+0

티켓이 [닫혀 있음] (https://github.com/eirslett/frontend-maven-plugin/issues/18#ref-commit- c6a01c1) witn [ 구성 매개 변수] (https://github.com/eirslett/frontend-maven-plugin/pull/234) – chivorotkiv

답변

5

그것은 어디 NodeJS를 설치하는 선택 < installDirectory> 구성 매개 변수를 사용하는 것이 가능하다 :

여기 내 설정이다.

frontend-maven-pluginpackage.json이 발견 된 곳에 node_modules을 설치합니다. 그렇기 때문에 웹 리소스 사본을package.json과에 제공해야하는 이유입니다.

다음 frontend-maven-plugin

이 방법으로 구성 할 수 있습니다

 <plugin> 
      <groupId>com.github.eirslett</groupId> 
      <artifactId>frontend-maven-plugin</artifactId> 
      <version>0.0.24</version> 

      <configuration> 
       <nodeVersion>v0.11.14</nodeVersion> 
       <npmVersion>2.13.4</npmVersion> 
       <installDirectory>target/<sub-path></installDirectory> 
       <workingDirectory>target/<sub-path></workingDirectory> 
      </configuration> 
      ... 
1

플러그인 (프론트 엔드 - 받는다는 - 플러그인) 대부분이 지원

이 내 pom.xml의 관련 부분이다. "workingDirectory"매개 변수는 플러그인이 작업을 수행 할 위치 (즉, npm 설치)를 알려줍니다. 빌드 파일 (예 : package.json, gruntFile.js)은 해당 workingDirectory에 있어야합니다. 이를 수용하기 위해 나머지 빌드 전에 필터링을 통해 해당 파일을 복사하는 antrun 실행을 추가했습니다. 그런 다음 내 grunt 파일은 적절한 경우 소스에서 파일을 참조하고 출력은 내 target-grunt 폴더에 저장됩니다.

 <plugin> 
      <groupId>com.github.eirslett</groupId> 
      <artifactId>frontend-maven-plugin</artifactId> 
      <version>0.0.20</version> 
      <configuration> 
       <workingDirectory>target-grunt</workingDirectory> 
      </configuration> 
      <executions> 
       ... 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>prepare-grunt</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <target> 
          <!-- copy, filter, rename --> 
          <filter token="moduleName" value="${moduleName}" /> 
          <filter token="project.version" value="${project.version}" /> 
          <filter token="project.artifactId" value="${project.artifactId}" /> 
          <copy file="${basedir}/target-grunt/imported-js/main/js/com/verisk/underwriting/config/grunt/npm-package-module/0.0.1/npm-package-module-0.0.1.js" tofile="${basedir}/target-grunt/package.json" filtering="true" failonerror="true" verbose="true" /> 
          <copy file="${basedir}/Gruntfile.js" tofile="${basedir}/target-grunt/Gruntfile.js" failonerror="true" verbose="true" /> 
         </target> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
관련 문제