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

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

There is a newer version: 4.1.3
Show newest version
package org.bitbucket.bradleysmithllc.etlunit.cli;

import org.bitbucket.bradleysmithllc.etlunit.ETLTestVM;
import org.bitbucket.bradleysmithllc.etlunit.ProcessDescription;
import org.bitbucket.bradleysmithllc.etlunit.ProcessFacade;
import org.clamshellcli.api.Command;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
import org.bitbucket.bradleysmithllc.etlunit.cli.util.OSValidator;

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