Using Maven to install Bower components with Bower installed globally

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

However, I want to use the global version of Bower, so I do not have separate Bower programs in all my projects, it works if I go to the directory in the terminal and in manual mode "bower install".

Question: I want Maven to use my global version of Bower to avoid duplicate Bower instances in each project, how to do it?

This is the code from my POM file that launches 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>
+4
source share
3 answers

After much testing, I realized that this is a problem with my IDE, for some reason Netbeans gives me an error when trying to create a project while the plugin is running, however, when I start the Maven project directly from the command line, it builds!

+2
source

don't forget workDirectory and put your bower.json in the root folder

<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>
+2
source

, bower, :

 <executable>c:/bower_directory/bower</executable>
+1
source

Source: https://habr.com/ru/post/1570304/


All Articles