Reputation: 25
I'm trying to write a maven plugin that is able to auto-update my dependencies. I have a working plug-in that, for now, just compile the maven project it's executed on. I am able to get de Dependency objects, but for I'm not looking for a way to find the possible versions to update to. Is there a way that allows me to check for new versions (local and from central)?
@Override
public void execute() {
final File directory = project.getBasedir();
final String[] arguments = {"clean compile"};
LOGGER.info(String.format("Execute maven at '%s': %s", directory, Arrays.toString(arguments)));
//System.setProperty("maven.multiModuleProjectDirectory", directory.getAbsolutePath());
final MavenCli mavenCli = new MavenCli();
final ByteArrayOutputStream stdOutStream = new ByteArrayOutputStream();
final ByteArrayOutputStream stdErrStream = new ByteArrayOutputStream();
final PrintStream stdOutPrint = new PrintStream(stdOutStream);
final PrintStream stdErrPrint = new PrintStream(stdErrStream);
final int exitCode = mavenCli.doMain(arguments, directory.getAbsolutePath(), stdOutPrint, stdErrPrint);
for(Dependency dep : project.getDependencies()) {
LOGGER.info(String.format("Dependency: %s:%s, version %s", dep.getGroupId(), dep.getArtifactId(), dep.getVersion()));
}
Upvotes: 0
Views: 770
Reputation: 311
Perhaps this post can help you https://stackoverflow.com/a/1172805/12155976
Instead of implementing something that can be done by other plugin, invoke that plugin with your needs from your plugin.
Upvotes: 1