All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.cli.UpdateCmd Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
package org.etlunit.cli;

import org.apache.maven.DefaultMaven;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.DefaultModelReader;
import org.apache.maven.project.MavenProject;
import org.clamshellcli.api.Command;
import org.clamshellcli.api.Configurator;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
import org.etlunit.*;
import org.etlunit.cli.util.OSValidator;
import org.etlunit.feature.Feature;
import org.etlunit.feature.RuntimeOptionDescriptor;
import org.etlunit.feature.ServiceLocatorFeatureLocator;
import org.etlunit.io.FileBuilder;
import org.etlunit.maven.ETLUnitMojo;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class UpdateCmd implements Command {
	private static final String NAMESPACE = "syscmd";
	public static final String ACTION_NAME = "update";

	public Object execute(Context ctx) {
		IOConsole console = ctx.getIoConsole();

		try
		{
			ETLTestVM vm = TestCmd.getEtlTestVM();

			vm.installFeatures();

			ProcessFacade proc = vm.getRuntimeSupport().execute(new ProcessDescription("mvn" + (OSValidator.isWindows() ? ".bat" : "")).argument("clean").argument("package").argument("-Dmaven.test.skip=true"));

			proc.waitForCompletion();

			StringBuffer buff = proc.getInputBuffered();

			String text = buff.toString();

			MavenSuccessExpression mse = new MavenSuccessExpression(text);

			if (!mse.hasNext())
			{
				console.writeOutput("Failed to update binaries\n");
				console.writeOutput(text + "\n");
			}
			else
			{
				console.writeOutput("Please restart the shell to activate the updated libraries\n");
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		return null;
	}

	public void plug(Context plug) {
		// no load-time setup needed
	}

	public Descriptor getDescriptor() {
		return new Descriptor() {
			public String getNamespace() {
				return NAMESPACE;
			}

			public String getName() {
				return ACTION_NAME;
			}

			public String getDescription() {
				return "Updates external binaries";
			}

			public String getUsage() {
				return "update";
			}

			public Map getArguments() {
				return Collections.emptyMap();
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy