Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

A Maven plugin that avoids deploying snapshot versions when the artifact actually has not changed.

Notifications You must be signed in to change notification settings

dscho/maven-lazydeploy-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Description

This Maven plugin verifies that the previously deployed snapshot artifact actually differs from the to-be-deployed artifact. If they are identical, the plugin will ask the [deploy plugin] (http://maven.apache.org/plugins/maven-deploy-plugin/) to skip the upload.

Introduction

Maven has a lot of strengths. But it also has weaknesses, one of the more visible ones being that it downloads three quarters of the internet every morning.

A large part of the reason is that many artifacts are actually snapshot artifacts built & deployed by continuous integration systems which do not care whether the artifacts are different from before or not. They simply deploy the files.

However, it is a complete waste of time to upload such unchanged artifacts: there are typically more downloaders than uploaders and Maven has no chance to avoid these unnecessary downloads: the snapshot version is indeed different.

This plugin tries to help that situation by preventing such unnecessary uploads.

How does it work

It binds to the verify phase, to make sure that the artifact has been packaged correctly. In case the current version is not a snapshot version, it gracefully exits. The same is true in offline mode.

Otherwise it tries to download the snapshot artifact (if there is one). To avoid interfering with the install nor the deploy phase, it downloads the artifact to an alternative local repository in target/lazydeploy/.

If a snapshot artifact was successfully downloaded, the plugin now compares it to the local artifact. If they are identical, the project property maven.deploy.skip is set to true, otherwise the plugin just exits normally.

When it is the [deploy plugin] (http://maven.apache.org/plugins/maven-deploy-plugin/)'s turn to run, it will pick up that property -- if set to true -- and skip uploading the artifact.

Usage

Just add this to your pom.xml:

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>maven-lazydeploy-plugin</artifactId>
        <version>1.0-SNAPSHOT</version>
        <executions>
          <execution>
            <id>lazy-deploy</id>
            <phase>verify</phase>
            <goals>
              <goal>lazy-deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Shortcomings

It does not lock. That is, if you try to deploy a snapshot version and the plugin says it is unchanged while your friend also uploads a snapshot version that is changed, it is a gamble who wins. If -- for network latency reasons or whatever -- one person's upload happens between the download of the snapshot version and the skipped upload, Maven will say everything is fine, but the other person's upload will have changed the deployed snapshot artifact.

Another shortcoming is that if you were used to getting a coffee and chatting with your colleagues in the morning while Maven is burning the LAN cables, you might not like what this plugin does.

Future Plans

Add a parameter deep-inspection which will trigger the plugin to look inside .jar files and ignore the timestamps of the .jar file entries (as a .jar file is really a .zip file, every contained file has a timestamp; this means that building a .jar file at different times invariably results in different files, even if the contents are the same). Since we are dealing with Maven, we should also exclude the timestamps of the .properties files and some entries in the manifest which also depend on the build environment (and do not provide functional changes).

Also, handle attached artifacts, for the [NAR plugin] (https://github.com/scijava/maven-nar-plugin).

About

A Maven plugin that avoids deploying snapshot versions when the artifact actually has not changed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages