com.netflix.gradle.plugins.rpm.validation.RpmPackageNameAttributeValidator.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-ospackage-plugin Show documentation
Show all versions of gradle-ospackage-plugin Show documentation
Provides a task similar to Tar and Zip for constructing RPM and DEB package files.
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-._+]"
}
}