Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

README.md

spring-boot-frontend-maven-plugin

Apache License 2 Build Status Maven Central Bintray

Description

The spring-boot-frontend-maven-plugin is intended for Spring boot developers that develop a frontend application as part of their Spring boot application.

The spring-boot-frontend-maven-plugin enables to build a frontend application and package it for deployment together with a Spring boot application.

Currently, the plugin supports the Angular and Bootstrap frameworks for building frontend applications.

Prerequisites

Please make sure the following components are installed on your machine before using the plugin:

Configuration

The following options are available for configuring the plugin:

  • npmDependencies

    • The list of npm dependencies. This is where you can configure the npm dependencies.
    • By default the following dependencies are configured:
      • bower@1.4.1
      • grunt-cli@0.1.13
      • grunt-contrib-jshint@0.11.2
      • grunt-lesslint@1.1.14
      • grunt-contrib-copy@0.8.0
      • grunt-contrib-less@1.0.1
      • grunt-contrib-uglify@0.9.1
      • grunt-contrib-concat@0.5.1
      • grunt-contrib-cssmin@0.13.0
      • grunt-filerev@2.3.1
      • grunt-usemin@2.6.1
  • bowerDependencies

    • The list of bower dependencies. This is where you can configure the bower dependencies.
    • By default the following dependencies are configured:
      • angular#1.4.3
      • bootstrap#3.3.5
      • angular-ui-bootstrap#0.13.3
  • GruntFile

    • Indicates the location of the Gruntfile.js file used to build the frontend application.
    • By default the spring-boot-frontend-maven-plugin plugin creates a Gruntfile.js in the spring-boot project's src/main/web/.tmp subdirectory.
  • arguments

    • Allow to add arguments to grunt command line (example --verbose)
    • By default no arguments are giving

Goals

  • prepare-deps

    • Allow to download grunt and bower deps, this could be done during a specific profile to speed regular build
    • Default phase : generate-resources
  • build

    • run grunt build
    • Default phase : compile

Examples

Example using a simple configuration

The following example demonstrates a simple configuration of the spring-boot-frontend-maven-plugin:

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.albanseurat</groupId>
                <artifactId>spring-boot-frontend-maven-plugin</artifactId>
                <version>0.1</version>
                <configuration>
                    <!-- default value -->
                    <workingDirectory>src/main/web</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-deps</goal>
                        </goals>
                    </execution>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

With the above configuration, the pluging looks for files in the following subdirectories under the workingDirectory
directory specified in the pluging configuration section, in this example src/main/web:

  • less files located in the less subdirectory
  • javascript files in the scripts subdirectory

The plugin uses grunt as a task runner to build the frontend application assets. The pluging uses grunt-usemin from yeoman to minify the resources and html files.

Example using yeoman blocks

Here is an example of a html file using blocks:

<!doctype html>
<html lang="en" ng-app>
<head>
    <meta charset="utf-8">
    <title>My HTML File</title>
    <!-- build:less css/main.css -->
    <link rel="stylesheet/css" href="bower_components/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet/less" href="less/main.less">
    <!-- endbuild -->
    <!-- build:js js/main.js -->
    <script src="bower_components/angular/angular.js"></script>
    <script src="scripts/main.js"></script>
    <!-- endbuild -->
</head>
<body>

<p>Nothing here {{'yet' + '!'}}</p>

</body>
</html>

All the resources (css, javascript, images not yet) will be generated into the src/main/resources/static directory by default, following spring-boot convention for publishing static Web content.

Example using command line

Here an example allowing to run grunt with arguments

``mvn spring-boot-frontend:build -Darguments=--verbose`

Reporting Issues

Issues can be reported at https://github.com/AlbanSeurat/spring-boot-frontend-maven-plugin/issues

Code

All the code is available at https://github.com/AlbanSeurat/spring-boot-frontend-maven-plugin

License

All the code distributed under the ASL 2.0 license.

Copyright

Copyright © 2015 Alban Seurat. All rights reserved.

About

Allow to integrate AngularJS / bootstrap / Less within a spring-boot project seamlessly

Resources

Packages

No packages published
You can’t perform that action at this time.