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

com.netflix.gradle.plugins.rpm.validation.RpmPackageNameAttributeValidator.groovy Maven / Gradle / Ivy

The newest version!
package com.netflix.gradle.plugins.rpm.validation

import com.netflix.gradle.plugins.packaging.validation.SystemPackagingAttributeValidator
class RpmPackageNameAttributeValidator implements SystemPackagingAttributeValidator {
    /**
     * Per RPM manpage a valid
     * package name has to follow these conventions:
     *
     * abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._+
     *
     * @param packageName Package name
     * @return Result
     */
    @Override
    boolean validate(String packageName) {
        matchesExpectedCharacters(packageName)
    }

    private boolean matchesExpectedCharacters(String packageName) {
        packageName ==~ /[a-zA-Z0-9-._+]+/
    }

    @Override
    String getErrorMessage(String attribute) {
        "Invalid package name '$attribute' - a valid package name must only contain [a-zA-Z0-9-._+]"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy