Search in sources :

Example 16 with InvocationRequest

use of org.apache.maven.shared.invoker.InvocationRequest in project beakerx by twosigma.

the class MavenJarResolver method createInvocationRequest.

private InvocationRequest createInvocationRequest() {
    InvocationRequest request = new DefaultInvocationRequest();
    request.setGoals(GOALS);
    return request;
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest)

Example 17 with InvocationRequest

use of org.apache.maven.shared.invoker.InvocationRequest in project beakerx by twosigma.

the class MavenJarResolver method retrieve.

public AddMvnCommandResult retrieve(List<Dependency> dependencies, MvnLoggerWidget progress) {
    File finalPom = null;
    try {
        String pomAsString = pomFactory.createPom(pathToMavenRepo, dependencies, commandParams.getRepos());
        finalPom = saveToFile(commandParams.getPathToNotebookJars(), pomAsString);
        InvocationRequest request = createInvocationRequest();
        request.setOffline(commandParams.getOffline());
        request.setPomFile(finalPom);
        request.setUpdateSnapshots(true);
        Invoker invoker = getInvoker(progress);
        progress.display();
        InvocationResult invocationResult = invoker.execute(request);
        progress.close();
        return getResult(invocationResult, dependencies);
    } catch (Exception e) {
        return AddMvnCommandResult.error(e.getMessage());
    } finally {
        deletePomFolder(finalPom);
    }
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) Invoker(org.apache.maven.shared.invoker.Invoker) DefaultInvoker(org.apache.maven.shared.invoker.DefaultInvoker) File(java.io.File) InvocationResult(org.apache.maven.shared.invoker.InvocationResult) IOException(java.io.IOException)

Example 18 with InvocationRequest

use of org.apache.maven.shared.invoker.InvocationRequest in project dspot by STAMP-project.

the class MavenAutomaticBuilder method runGoals.

private int runGoals(String pathToRootOfProject, String... goals) {
    InvocationRequest request = new DefaultInvocationRequest();
    request.setGoals(Arrays.asList(goals));
    request.setPomFile(new File(pathToRootOfProject + FILE_SEPARATOR + POM_FILE));
    request.setJavaHome(new File(System.getProperty("java.home")));
    Properties properties = new Properties();
    properties.setProperty("enforcer.skip", "true");
    properties.setProperty("checkstyle.skip", "true");
    properties.setProperty("cobertura.skip", "true");
    properties.setProperty("skipITs", "true");
    properties.setProperty("rat.skip", "true");
    properties.setProperty("license.skip", "true");
    properties.setProperty("findbugs.skip", "true");
    properties.setProperty("gpg.skip", "true");
    request.setProperties(properties);
    Invoker invoker = new DefaultInvoker();
    invoker.setMavenHome(new File(this.mavenHome));
    LOGGER.info(String.format("run maven %s", Arrays.stream(goals).collect(Collectors.joining(" "))));
    if (Main.verbose) {
        invoker.setOutputHandler(System.out::println);
        invoker.setErrorHandler(System.err::println);
    } else {
        invoker.setOutputHandler(null);
        invoker.setErrorHandler(null);
    }
    try {
        return invoker.execute(request).getExitCode();
    } catch (MavenInvocationException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) Invoker(org.apache.maven.shared.invoker.Invoker) DefaultInvoker(org.apache.maven.shared.invoker.DefaultInvoker) MavenInvocationException(org.apache.maven.shared.invoker.MavenInvocationException) DefaultInvoker(org.apache.maven.shared.invoker.DefaultInvoker) DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) Properties(java.util.Properties)

Example 19 with InvocationRequest

use of org.apache.maven.shared.invoker.InvocationRequest in project syncope by apache.

the class MavenUtils method archetypeGenerate.

public void archetypeGenerate(final String archetypeVersion, final String groupId, final String artifactId, final String secretKey, final String anonymousKey, final String jwsKey, final String adminPassword, final String installPath, final File customSettingsFile) {
    final InvocationRequest request = new DefaultInvocationRequest();
    request.setGoals(Collections.singletonList(archetypeVersion.contains("SNAPSHOT") ? "org.apache.maven.plugins:maven-archetype-plugin:2.4:generate" : "archetype:generate"));
    request.setBatchMode(true);
    final Properties properties = archetypeProperties(archetypeVersion, groupId, artifactId, secretKey, anonymousKey, jwsKey, adminPassword);
    request.setProperties(properties);
    if (customSettingsFile != null && FileUtils.sizeOf(customSettingsFile) > 0) {
        request.setUserSettingsFile(customSettingsFile);
    }
    logToHandler(request.getGoals(), properties);
    logToFile(request.getGoals(), properties);
    invoke(request, installPath);
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) Properties(java.util.Properties)

Example 20 with InvocationRequest

use of org.apache.maven.shared.invoker.InvocationRequest in project syncope by apache.

the class MavenUtils method mvnCleanPackageWithProperties.

public void mvnCleanPackageWithProperties(final String path, final Properties properties, final File customSettingsFile) {
    final InvocationRequest request = new DefaultInvocationRequest();
    request.setProperties(properties);
    if (customSettingsFile != null && FileUtils.sizeOf(customSettingsFile) > 0) {
        request.setUserSettingsFile(customSettingsFile);
    }
    final List<String> mavenGoals = new ArrayList<>();
    mavenGoals.add("clean");
    mavenGoals.add("package");
    request.setGoals(mavenGoals);
    logToHandler(request.getGoals(), properties);
    logToFile(request.getGoals(), properties);
    invoke(request, path);
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) ArrayList(java.util.ArrayList) DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest)

Aggregations

DefaultInvocationRequest (org.apache.maven.shared.invoker.DefaultInvocationRequest)31 InvocationRequest (org.apache.maven.shared.invoker.InvocationRequest)31 File (java.io.File)19 MavenInvocationException (org.apache.maven.shared.invoker.MavenInvocationException)17 Properties (java.util.Properties)15 InvocationResult (org.apache.maven.shared.invoker.InvocationResult)15 DefaultInvoker (org.apache.maven.shared.invoker.DefaultInvoker)14 Invoker (org.apache.maven.shared.invoker.Invoker)13 InvokerProperties (org.apache.maven.plugins.invoker.InvokerProperties)7 IOException (java.io.IOException)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 CommandLineConfigurationException (org.apache.maven.shared.invoker.CommandLineConfigurationException)2 MavenCommandLineBuilder (org.apache.maven.shared.invoker.MavenCommandLineBuilder)2 RunFailureException (org.apache.maven.shared.scriptinterpreter.RunFailureException)2 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1