com.nlocketz.plugins.RepetitionConfigPlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin-repeater-maven-plugin Show documentation
Show all versions of plugin-repeater-maven-plugin Show documentation
A Maven plugin that repeats a plugin while replacing placeholder variables. Used to reduce duplication within the POM.
package com.nlocketz.plugins;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class RepetitionConfigPlugin {
private String groupId;
private String artifactId;
private String version;
private List executions;
List getExecutions() {
return executions;
}
// TODO we should be able to make "mutable string" slots and just set them for each rep
// so only 1 traverse to put mut strings in place
RepetitionConfigPlugin substitute(Map vars) {
RepetitionConfigPlugin output = new RepetitionConfigPlugin();
output.version = version;
output.artifactId = artifactId;
output.groupId = groupId;
output.executions = new ArrayList<>(executions.size());
for (RepetitionExecution exec : executions) {
output.executions.add(exec.sub(vars));
}
return output;
}
Plugin asPlugin() {
Plugin newPlugin = new Plugin();
newPlugin.setGroupId(groupId);
newPlugin.setArtifactId(artifactId);
newPlugin.setVersion(version);
// We currently don't support inline dependencies, although this is easy enough to add in the future.
newPlugin.setDependencies(Collections.emptyList());
return newPlugin;
}
String toGav() {
return String.format("%s:%s:%s", groupId, artifactId, version);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy