3

I am trying integrate bower in my maven webapp here is my pom.xml and and bower.json but i was failed to download the dependencies. this here is my pom.xml and bower.json files.And one more question does i need the nodejs or npm help to download the dependencies ?

bower.json:

{
"name": "Bower1",
"version": "1.0.0",

"description": "javaee7-angular JavaScript dependencies.",
"private": true,
"dependencies": {
    "angular": "1.2.0",
    "jquery": "1.9.1",
    "angular-bootstrap": "0.10.0",
    "angular-grid": "2.0.7"
}

}

pom.xml:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>

    <finalName>Bower1</finalName>
    <plugins>
        <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>
    </plugins>

</build>

  • Possible duplicate of [Using Maven to install Bower components with Bower installed globally](http://stackoverflow.com/questions/27822050/using-maven-to-install-bower-components-with-bower-installed-globally) – zillani Mar 17 '17 at 10:05
  • Thanks for your reply @zillani but while installing the bower i am getting the error like "'node' is not recognized as an internal or external command, operable program or batch file." how can i resolve this.??? – Gopi Krishna Seeram Mar 17 '17 at 10:41
  • np, find my answer below, let me know if it helps @Gopi Krishna Seeram – zillani Mar 17 '17 at 10:51

2 Answers2

3

Step by step process to run bower in a maven eclipse project:

1.install npm in your local system

2.Add the following plug in your maven pom.xml <build></build> tags

<plugins>
        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>0.0.20</version>
            <executions>
                <execution>
                    <id>bower install</id>
                    <goals>
                        <goal>bower</goal>
                    </goals>
                    <configuration>
                        <arguments>install</arguments>
                    </configuration>
                </execution>
            </executions>

        </plugin>

    </plugins>

3.Add the following bower.json file in your webapp root folder

 {
"name": "BowerTest",
"version": "1.0.0",
"private": true,
"dependencies": {
    "angular": "1.2.0",
    "jquery": "1.9.1",
    "bootstrap":"3.3.7",
    "css":""
}}

4. If you want to add any dependencies add your dependency within dependencies as shown above bower.json file.

  1. Then right click on your project click on bower install after this installation one folder will be created like bower_components in your root path there you can found your dependencies then refer that dependencies into your view layer.
0

Bower needs npm (node package manager), so install npm and make sure its on your PATH, enter image description here

npm download: https://nodejs.org/en/download/

zillani
  • 1,070
  • 3
  • 18
  • 26