versions icon indicating copy to clipboard operation
versions copied to clipboard

Specifies if the build should be failed

Open KamilKrysztofiak opened this issue 6 years ago • 4 comments

Hi,

we have the following case within the team:

As a developer I want to see how I can check the topicality for my dependencies for my application in a proper way.

We perform a dependency check using the versions-maven-plugin for topicality inside the stage of the jenkins pipeline.

How we can ensure that the build fails in case if e.g. a depedency has a major update available or e.g. we have more than 5 dependencies which require a major update etc. I didn't see the possibility in the plugin configuration or maybe I overlook it.

Best regards, Kamil

KamilKrysztofiak avatar Mar 17 '20 15:03 KamilKrysztofiak

having the same issue, would be great to have this implemented or explained

schdief avatar Mar 17 '20 15:03 schdief

Same issue here, but the summary is a bit confusing.

Suggested rewording: "There should be a configurable way to fail the build when dependency and / or plugin updates are available"

lestephane avatar Jun 25 '20 05:06 lestephane

I'm working on an article on "Modern Java/JVM Build Practices", and this plugin is one of the recommendations for Maven projects (https://github.com/ben-manes/gradle-versions-plugin is the counterpart for Gradle projects).

I'd like to offer advice on failing the build if plugins/dependencies are out of date -- with an eye to helping teams that want explicit version exclusions when needed.

So this issue is important for me. What do you suggest?

binkley avatar Oct 04 '20 11:10 binkley

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Oct 13 '22 03:10 github-actions[bot]

Hi all. Is there still popular interest in having this feature implemented?

andrzejj0 avatar Oct 24 '22 11:10 andrzejj0

Hi all. Is there still popular interest in having this feature implemented?

Yes! This feature would simplify life :-)

hugoheden avatar Oct 24 '22 14:10 hugoheden

Ok, I'm working on it.

But it will be done as an Enforcer rule. So, it will have to be used in combination with the Enforer plugin. I'll describe how to do it in the Examples section.

In a very short example:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <goals>
          <goal>enforce</goal>
        </goals>
        <configuration>
          <rules>
            <maxDependencyUpdates>
              <maxUpdates>0</maxUpdates>
              <ignoreMinorUpdates>true</ignoreMinorUpdates>
            </maxDependencyUpdates>
          </rules>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

The above configuration will fail if it discovers any dependencies with major updates. Minor and less updates will be ignored.

andrzejj0 avatar Oct 24 '22 15:10 andrzejj0

Sounds reasonable. Is there a separate github "Issue" where your work can be discussed?

An idea is to make it possible to suppress versions that are not suitable to update to. For example, a project might feel that they are not ready to move to Spring Boot 3 (whenever that is released). The project "dependency-check-maven" supports suppressions (of false positives when looking for vulnerabilities). A suppression can even have an expiry date. In our case here one would be able to express that "we are not ready to move to Spring Boot now, but in one month we'll have time, and we should do it then"

hugoheden avatar Oct 24 '22 16:10 hugoheden

I think this could best be discussed here.

A feature like you describe is already present in version maven plugin though - dependency includes/excludes, which could be used to filter GAV regex patterns which are or aren't to be considered.

This could be used to filter out spring boot or for example just instruct the plugin to check a select set of dependencies.

andrzejj0 avatar Oct 24 '22 17:10 andrzejj0

Checking on how this is looking. Is there a version I can try the enforcer feature with?

binkley avatar Dec 31 '22 12:12 binkley

Yes, it's released as of 2.14.0.

andrzejj0 avatar Dec 31 '22 12:12 andrzejj0

Please see https://www.mojohaus.org/versions/versions-enforcer/index.html

andrzejj0 avatar Dec 31 '22 12:12 andrzejj0