com.itemis.maven.plugins.unleash.util.functions.ProjectToCoordinates 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.project.MavenProject;
import com.google.common.base.Function;
import com.itemis.maven.aether.ArtifactCoordinates;
import com.itemis.maven.plugins.unleash.util.PomUtil;
/**
* A function to convert a {@link Project} to a {@link ArtifactCoordinates} object.
* There are several implementations that include different properties of the pom and may set defaults.
*
* @author Stanley Hillner
* @since 1.0.0
*/
public enum ProjectToCoordinates implements Function {
/**
* Uses all relevant properties of the project.
*/
INSTANCE(true, null),
/**
* Assumes the default empty version for the project.
*/
EMPTY_VERSION(false, null),
/**
* Uses the relevant properties of the project but assumes "pom" packaging.
*/
POM(true, PomUtil.ARTIFACT_TYPE_POM),
/**
* Assumes an empty project version and packaging type "pom".
*/
EMPTY_VERSION_POM(false, PomUtil.ARTIFACT_TYPE_POM);
private boolean includeVersion;
private String type;
private ProjectToCoordinates(boolean version, String type) {
this.includeVersion = version;
this.type = type;
}
@Override
public ArtifactCoordinates apply(MavenProject p) {
if (this.includeVersion) {
return new ArtifactCoordinates(p.getGroupId(), p.getArtifactId(), p.getVersion(),
this.type != null ? this.type : p.getPackaging());
} else {
return new ArtifactCoordinates(p.getGroupId(), p.getArtifactId(), MavenProject.EMPTY_PROJECT_VERSION,
this.type != null ? this.type : p.getPackaging());
}
}
}