All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ning.maven.plugins.dependencyversionscheck.VersionCheckExcludes Maven / Gradle / Ivy

Go to download

The maven-dependency-versions-check-plugin is a Maven plugin that verifies that the resolved versions of dependencies are at least the versions specified by the dependencies (or their dependencies etc.) if not higher. More specifically, it will check that * The resolved version of every dependency declared explicitly in the current POM is the same or a newer one than what was stated. If the resolved version has a higher major version number than the declared version, then the plugin will issue a warning if configured to do so. Note that enforced declared versions are ignored by the plugin. * For every explicitly declared dependency in the current POM, all its dependency versions are met. I.e. the resolved versions for all dependencies in that dependency's POM are the same or higher than the one stated in that dependency's POM. This is basically the same check as the one above, but using the dependency's POM! Also, if the current POM has exclusions specified for the dependency, then these transitive dependencies are ignored when checking this particular dependency.

There is a newer version: 2.0.4
Show newest version
/*
 * Copyright 2010 Ning, Inc.
 *
 * Ning licenses this file to you 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.
 */

package com.ning.maven.plugins.dependencyversionscheck;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.Artifact;

import com.ning.maven.plugins.dependencyversionscheck.version.Version;

public class VersionCheckExcludes
{
    private String groupId;
    private String artifactId;
    private String classifier;
    private String type = "jar";
    private Version expectedVersion;
    private Version resolvedVersion;

    public void setGroupdId(String groupId)
    {
        this.groupId = groupId;
    }

    public void setArtifactId(String artifactId)
    {
        this.artifactId = artifactId;
    }

    public void setClassifier(String classifier)
    {
        this.classifier = classifier;
    }

    public void setType(String type)
    {
        this.type = (type == null ? "jar" : type);
    }

    public void setExpectedVersion(String versionStr)
    {
        this.expectedVersion = new Version(versionStr);
    }

    public void setResolvedVersion(String versionStr)
    {
        this.resolvedVersion = new Version(versionStr);
    }

    public boolean check()
    {
        return !StringUtils.isEmpty(groupId) && !StringUtils.isEmpty(artifactId) && (expectedVersion != null) && (resolvedVersion != null);
    }

    public String toString()
    {
        StringBuilder builder = new StringBuilder();

        builder.append(groupId);
        builder.append(":");
        builder.append(artifactId);
        if (!"jar".equals(type)) {
            builder.append(":");
            builder.append(type);
        }
        if (classifier != null) {
            builder.append(":");
            builder.append(classifier);
        }
        builder.append(" ");
        builder.append(expectedVersion.getSelectedVersion());
        builder.append(" vs. ");
        builder.append(resolvedVersion.getSelectedVersion());
        return builder.toString();
    }

    public boolean matches(Artifact artifact, Version expectedVersion, Version resolvedVersion)
    {
        return StringUtils.equals(groupId, artifact.getGroupId()) &&
               StringUtils.equals(artifactId, artifact.getArtifactId()) &&
               StringUtils.equals(classifier, artifact.getClassifier()) &&
               StringUtils.equals(type, artifact.getType()) &&
               this.expectedVersion.equals(expectedVersion) &&
               this.resolvedVersion.equals(resolvedVersion);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy