Git Product home page Git Product logo

dependencyversion-maven-plugin's Introduction

Set Properties for Maven Dependency Versions

dependencyversion-maven-plugin makes it easy to set and use version properties for dependencies that are declared in a different context.

Why would I need to use this?

  • When importing dependencies from a BOM - Since imported BOMs do not allow for property import, this plugin provides a way to access the version information from said boms.
  • When a parent pom declares a dependency, but not a version - Most commonly this can be solved by simply declaring a pom in the parent property. However, there are instances in which the parent pom is not under the control of downstream consumers.
  • For transient dependency compatibility - for example, an upstream dependency may declare an API, and your pom declares an implementation with a version corresponding to the upstream API. This plugin would provide an easy way to keep the two in sync.

Usage Example

To use the dependencyversion-maven-plugin, just include the plugin in your build

<build>
   .
   .
    <plugins>
        .
        .
        <plugin>
            <groupId>io.reformanda.semper</groupId>
            <artifactId>dependencyversion-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
                <execution>
                    <id>set-all</id>
                    <goals>
                        <goal>set-version</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

This configuration will set a version property for all project dependencies (both declared and transitive) in the following format:

groupId:artifactId:type[:classifier].version

For eample, a dependency declared in an imported BOM like this:

<dependency>
    <groupId>io.undertow</groupId>
    <artifactId>undertow-core</artifactId>
    <version>1.3.15.Final</version>
</dependency>

Would result in the following property:

io.undertow:undertow-core:jar.version=1.3.15.Final

Including and Excluding Dependencies

By default, all declared and transitive dependencies that are resolved against the declaring project will be included. However, inclusion and exclusion of dependencies from property generation can be accomplished using the <configuration> element.

To Include only specified dependencies:

                    <configuration>
                        <propertySets>
                            <propertySet>
                                <includes>
                                    <include>io.undertow:undertow-core:jar</include>
                                </includes>
                            </propertySet>
                        </propertySets>
                    </configuration>

Or to include all resolved dependencies except those on the excludes list:

                    <configuration>
                        <propertySets>
                            <propertySet>
                                <excludes>
                                    <exclude>org.jboss.xnio:xnio-api:jar</exclude>
                                    <exclude>org.jboss.xnio:xnio-nio:jar</exclude>
                                </excludes>
                            </propertySet>
                        </propertySets>
                    </configuration>

Omitting Transitive Dependencies

The plugin will create properties for all resolved dependencies - transitives included. To shrink the scope of property creation to only declared dependencies, simply omit set the <transitive> configuration element to false.

                    <configuration>
                        <propertySets>
                            <propertySet>
                                <transitive>false</transitive>
                            </propertySet>
                        </propertySets>
                    </configuration>

Use a Custom Property Suffix

By default, .version is the suffix appended to all properties. This suffix setting can be altered by configuring the <suffix> element:

                    <configuration>
                        <propertySets>
                            <propertySet>
                                <suffix>fromBom</suffix>
                            </propertySet>
                        </propertySets>
                    </configuration>

The above setting would generate properties like this:

io.undertow:undertow-core:jar.fromBom=1.3.15.Final

dependencyversion-maven-plugin's People

Contributors

bitstrings avatar josh-cain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.