nidi3 / use-webjars-maven-plugin

use webjars as if they would be npm modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use-webjars-maven-plugin

Use webjars as if they would be npm modules.

Why?

Webjars work well in the JVM world. But as soon as a project comes into contact with the javascript / npm / node.js eco system, things start to get complicated. There are mainly two reasons for that:

  • webjars basically are zip files. Therefore the contents is not directly available without unzipping.
  • webjars encode their version in the directory structure. Therefore every tool processing them must configure somewhere the version number.

This plugin treats webjars the same way as npm does with its modules:

  • unpack the webjar
  • strip the version from its path

This way, tools like minifiers, css postprocessors, unit test runners etc. can be used with less hassle.

Usage

The basic configuration looks like this:

<build>
    <plugins>
        <plugin>
            <groupId>guru.nidi.maven.plugins</groupId>
            <artifactId>use-webjars-maven-plugin</artifactId>
            <version>0.0.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>angularjs</artifactId>
        <version>1.5.7</version>
    </dependency>
</dependencies>

Running mvn package results in this file structure:

src
    ...
target
    webjars
        META-INF
            resources
                webjars
                    angularjs
                        <contents of angularjs>

Configuration

The plugin site lists all options.

Flatten

Adding

<configuration>
    <flatten>true</flatten>
</configuration>

omits META-INF/resources/webjars and results in

src
    ...
target
    webjars
        angularjs
            <contents of angularjs>

Further settings

The plugin is based on maven-dependency-plugin:unpack-dependencies and supports all its settings.

About

use webjars as if they would be npm modules

License:Apache License 2.0


Languages

Language:Java 100.0%