使用Maven安装Bower组件并在全球安装Bower [英] Using Maven to install Bower components with Bower installed globally

查看:143
本文介绍了使用Maven安装Bower组件并在全球安装Bower的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用NPM在全球范围内安装了凉亭. 在我的Maven项目中,我有一个bower.json文件,我使用exec-maven-plugin在构建中安装Bower组件,但是失败了,因为它无法在目录中运行程序'bower'",这是有道理的,因为Bower不在本地安装在项目目录中.

I have bower installed globally using NPM. In my Maven project I have a bower.json file, I am using the exec-maven-plugin to install the bower components on build, however it failed because it "cannot run the program 'bower' in directory" which makes sense because Bower is not locally installed in the project directory.

但是我想使用Bower的全局版本,因此在我所有的项目中都没有单独的Bower程序,如果我进入终端中的目录并手动运行"bower install",则可以使用它.

However I want to use the global version of Bower so I don't have separate Bower programs in all my projects, it works if I go to the directory in terminal and manual run 'bower install'.

问题:我希望Maven使用我的全局Bower版本来避免在每个项目中都有Bower的重复副本,我该怎么做?

Question: I want Maven to use my global Bower version to avoid me having duplicate copies of Bower in each project, how do I do this?

这是运行插件并执行的POM文件中的代码:

This is the code from my POM file that runs the plugin and execution:

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

推荐答案

经过大量测试,我发现这是我的IDE的问题,由于某些原因,Netbeans在尝试构建该插件时给了我一个错误.项目在插件执行期间,但是当我直接从命令行运行Maven项目时,它就会构建!

After a lot of testing, I've figured out it was a problem with my IDE, for some reason Netbeans gives me an error when it tries to build the project during the plugin execution, however when I run the Maven project straight from command line, it builds!

这篇关于使用Maven安装Bower组件并在全球安装Bower的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆