Class MavenInvoker

java.lang.Object
se.kth.depclean.util.MavenInvoker

public final class MavenInvoker
extends Object
  • Method Details

    • runCommand

      public static String[] runCommand​(String cmd) throws IOException, InterruptedException
      Creates a native process to execute a custom command. This method is used to invoke maven plugins directly.
      Parameters:
      cmd - The command to be executed.
      Returns:
      The console output.
      Throws:
      IOException - In case of IO issues.
      InterruptedException - In case of IO issues.
    • invokeMaven

      public static int invokeMaven​(String mvnHome, String pomPath, String mvnGoal) throws org.apache.maven.shared.invoker.MavenInvocationException
      This method invokes Maven to execute a given goal programmatically instead of running a command directly as in runCommand(String).
      Parameters:
      mvnHome - Location of maven installation.
      pomPath - Path to the pom of the project.
      mvnGoal - The maven goal to execute.
      Returns:
      The exit code from the Maven invocation.
      Throws:
      org.apache.maven.shared.invoker.MavenInvocationException - In case of any issue invoking maven.