4

NPMを使用してbowerをグローバルにインストールしました。私のMavenプロジェクトにはbower.jsonファイルがあり、exec-maven-pluginを使用してビルド時にbowerコンポーネントをインストールしていますが、「ディレクトリでプログラム「bower」を実行できない」ため失敗しました。プロジェクト ディレクトリにローカルにインストールされていません。

ただし、Bower のグローバル バージョンを使用したいので、すべてのプロジェクトで別の Bower プログラムを使用する必要はありません。ターミナルでディレクトリに移動し、「bower install」を手動で実行すると機能します。

質問: 各プロジェクトで Bower のコピーが重複しないように、Maven にグローバル Bower バージョンを使用してもらいたいのですが、どうすればよいですか?

これは、プラグインと実行を実行する POM ファイルのコードです。

 <plugin>

  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.3.2</version>

  <executions>

    <execution>
      <id>exec-bower-install</id>

      <phase>generate-sources</phase>
      <configuration>

        <executable>bower</executable>

        <arguments>
          <argument>install</argument>
        </arguments>

      </configuration>
      <goals>
        <goal>exec</goal>
      </goals>
    </execution>

  </executions>
</plugin>
4

3 に答える 3

2

workingDirectoryを忘れずに、bower.json をルート フォルダー内に配置します。

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <executions>
     <execution>
     <phase>generate-sources</phase>
     <goals>
      <goal>exec</goal>
     </goals>
     </execution>
   </executions>
   <configuration>
     <executable>bower</executable>
     <arguments>
      <argument>install</argument>
     </arguments>
     <workingDirectory>${basedir}/src/main/webapp</workingDirectory>
   </configuration>
</plugin>
于 2015-01-07T16:15:04.197 に答える