package com.tobedevoured.naether.maven;

import com.tobedevoured.naether.NaetherException;
import org.apache.maven.shared.invoker.*;

import java.io.File;
import java.util.Arrays;

public class Invoker {

    private DefaultInvoker invoker;

    public Invoker(String localRepo, String mavenHome) {
        invoker = new DefaultInvoker();
        invoker.setLocalRepositoryDirectory( new File(localRepo) );
        if ( mavenHome != null ) {
            invoker.setMavenHome(new File(mavenHome));
        }
    }

    public InvocationResult execute(String pom, String... goals) throws NaetherException {
        InvocationRequest request = new DefaultInvocationRequest();
        request.setPomFile(new File(pom));
        request.setInteractive(false);
        request.setGoals( Arrays.asList(goals) );

        try {
            return invoker.execute( request );
        } catch (MavenInvocationException e) {
            throw new NaetherException("Failed to execute maven task",e);
        }
    }
}

@@ -174,16 +174,46 @@
 rrays;%0A%0A
+/**%0A * Invoke Maven goals%0A */%0A
 public c
@@ -265,16 +265,148 @@
 voker;%0A%0A
+    /**%0A     * Construct Invoker%0A     * @param localRepo local Maven repo to use%0A     * @param mavenHome path to Maven home%0A     */%0A
     publ
@@ -669,16 +669,199 @@
 %0A    %7D%0A%0A
+    /**%0A     * Execute goals for a pom%0A     *%0A     * @param pom String path%0A     * @param goals String%0A     * @return %7B@link InvocationResult%7D%0A     * @throws NaetherException%0A     */%0A
     publ

add javadocs