Maven Dependency Version Plugin Parent Pom

Parent for dependencyversion-maven-plugin

License

License

Categories

Categories

Maven Build Tools ORM Data
GroupId

GroupId

io.reformanda.semper
ArtifactId

ArtifactId

dependencyversion-maven-plugin-parent
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom
Description

Description

Maven Dependency Version Plugin Parent Pom
Parent for dependencyversion-maven-plugin
Project URL

Project URL

http://semper-reformanda.github.io/dependencyversion-maven-plugin/
Source Code Management

Source Code Management

https://github.com/cainj13/dependencyversion-maven-plugin

Download dependencyversion-maven-plugin-parent

How to add to project

<!-- https://jarcasting.com/artifacts/io.reformanda.semper/dependencyversion-maven-plugin-parent/ -->
<dependency>
    <groupId>io.reformanda.semper</groupId>
    <artifactId>dependencyversion-maven-plugin-parent</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.reformanda.semper/dependencyversion-maven-plugin-parent/
implementation 'io.reformanda.semper:dependencyversion-maven-plugin-parent:1.0.1'
// https://jarcasting.com/artifacts/io.reformanda.semper/dependencyversion-maven-plugin-parent/
implementation ("io.reformanda.semper:dependencyversion-maven-plugin-parent:1.0.1")
'io.reformanda.semper:dependencyversion-maven-plugin-parent:pom:1.0.1'
<dependency org="io.reformanda.semper" name="dependencyversion-maven-plugin-parent" rev="1.0.1">
  <artifact name="dependencyversion-maven-plugin-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.reformanda.semper', module='dependencyversion-maven-plugin-parent', version='1.0.1')
)
libraryDependencies += "io.reformanda.semper" % "dependencyversion-maven-plugin-parent" % "1.0.1"
[io.reformanda.semper/dependencyversion-maven-plugin-parent "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • dependencyversion-maven-plugin
  • dependencyversion-test

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

Versions

Version
1.0.1
1.0.0