com.outbrain.ci.friendly.maven.plugin.VersionProviderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ci-friendly-maven-plugin Show documentation
Show all versions of ci-friendly-maven-plugin Show documentation
Plugin helps to use CI friendly versions in maven projects https://maven.apache.org/maven-ci-friendly.html replacing the flatten-maven-plugin
The newest version!
package com.outbrain.ci.friendly.maven.plugin;
import org.apache.maven.plugin.MojoExecutionException;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@Named
@Singleton
public class VersionProviderImpl implements VersionProvider {
public String getVersion(String command) throws MojoExecutionException {
try {
StringBuilder builder = new StringBuilder();
Process process = Runtime.getRuntime().exec(command);
try (BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = input.readLine()) != null) {
builder.append(line);
}
}
// return the output
return builder.toString();
} catch (IOException e) {
throw new MojoExecutionException("Execution of command '" + command
+ "' failed", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy