change.impact Maven Plugin

A Maven plug-in that conditionally sets a property based on whether the latest Git commit affects any files in the transitive dependency chain of the current project.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.tasktop.maven
ArtifactId

ArtifactId

change-impact
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

change.impact Maven Plugin
A Maven plug-in that conditionally sets a property based on whether the latest Git commit affects any files in the transitive dependency chain of the current project.
Project URL

Project URL

https://github.com/greensopinion/maven-change-impact
Project Organization

Project Organization

Tasktop Technologies
Source Code Management

Source Code Management

https://github.com/greensopinion/maven-change-impact.git

Download change-impact

How to add to project

<plugin>
    <groupId>com.tasktop.maven</groupId>
    <artifactId>change-impact</artifactId>
    <version>0.0.3</version>
</plugin>

Dependencies

compile (6)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
org.apache.maven.shared : maven-dependency-tree jar 3.0
org.apache.maven : maven-core jar 3.0
org.apache.maven : maven-project jar 2.0.9
org.eclipse.jgit : org.eclipse.jgit jar 4.11.0.201803080745-r
org.codehaus.plexus : plexus-utils jar 3.0.21

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.5.2

Project Modules

There are no modules declared in this project.

What Is This?

A Maven plug-in that conditionally sets a property based on whether the latest Git commit affects any files in the transitive dependency chain of the current project, or any poms in the pom hierarchy of the current project.

How Is It Useful?

We can dynamically decide which projects should run their tests in a review verification build. The idea is to build everything, but only run tests for projects that are affected by the latest commit - either directly or via a change to a transitive dependency.

This is useful in cases where some tests (such as integration tests) take a long time to run. For code review verification it's usually unnecessary to run tests that are not affected by a change. By avoiding those tests, in some cases we can shorten the feedback cycle time significantly.

How To Use

Configuring

Install the plug-in in your local Maven repository, then add this to the root pom of your project:

  <build>
    <plugins>
      <plugin>
        <groupId>com.tasktop.maven</groupId>
        <artifactId>change-impact</artifactId>
        <version>0.0.3</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>set-property</goal>
            </goals>
            <configuration>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Properties:

  • <skip> - defaults to true, must be set to false for this plug-in to have any effect
  • <property-name> - defaults to maven.test.skip, defines the name of the property to set
  • <true-value> - the value to set the property to if the latest Git commit affects the current project or one of it's transitive dependencies, defaults to false
  • <false-value> - the value to set the property to if the latest Git commit does not affect the current project or one of it's transitive dependencies, defaults to true

This assumes that your maven-surefire-plugin has the following: <skip>${maven.test.skip}</skip>

Running

Run your maven build normally, for example:

$ mvn clean package

You should see that tests are skipped in every project except for those that are affected by a change in the latest commit.

Status

This is a proof-of-concept.

Build status on Travis CI: Build Status

How To Release

To release this plug-in to Maven Central, from the command-line:

mvn -Possrh -Psign -DpushChanges=false -DlocalCheckout=true -Darguments=-Dgpg.passphrase=thesecret release:clean release:prepare
mvn -Possrh -Psign -DpushChanges=false -DlocalCheckout=true -Darguments=-Dgpg.passphrase=thesecret release:perform

Then push changes:

git push

Search for the staging repository, close and relase it: https://oss.sonatype.org/#stagingRepositories

License

Copyright (c) 2018 Tasktop Technologies

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Versions

Version
0.0.3
0.0.2