com.itemis.maven.plugins.unleash.util.functions.DependencyToString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unleash-maven-plugin Show documentation
Show all versions of unleash-maven-plugin Show documentation
This plugin provides a generic alternative to the error-prone default release plugin provided by Maven.
It is designed to require a minimal effort of work for releasing modules and being extensible to integrate in every
project setup.
package com.itemis.maven.plugins.unleash.util.functions;
import org.apache.maven.model.Dependency;
import com.google.common.base.Function;
/**
* A function to convert a {@link Dependency} to its String representation in coordinates format.
*
* @author Stanley Hillner
* @since 1.0.0
*/
public enum DependencyToString implements Function {
INSTANCE(true), NO_TYPE(false);
private boolean includeType;
private DependencyToString(boolean includeType) {
this.includeType = includeType;
}
@Override
public String apply(Dependency d) {
StringBuilder sb = new StringBuilder(d.getGroupId());
sb.append(":").append(d.getArtifactId());
if (includeType && d.getType() != null) {
sb.append(":").append(d.getType());
}
if (d.getClassifier() != null) {
sb.append(":").append(d.getClassifier());
}
if (d.getVersion() != null) {
sb.append(":").append(d.getVersion());
}
return sb.toString();
}
}