<commit_before>package com.byclosure.maven.plugins.phonegap;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public abstract class AbstractPhoneGapMojo extends AbstractMojo {

	/**
	 * @parameter default-value="${project.basedir}" expression="${phonegap.base_dir}"
	 */
	protected File projectBaseDir;

	/**
	 * @parameter default-value="${project.build.directory}" expression="${phonegap.working_dir}
	 */
	protected File workingDir;

	/**
	 * @parameter default-value="phonegap" expression="${phonegap.project_path}
	 */
	protected String projectPath;

	/**
	 * @parameter expression="${phonegap.phonegap_bin}"
	 */
	protected File phonegapBin;


	protected abstract void executeComand() throws IOException;

	@Override
	public void execute() throws MojoExecutionException {
		try {
			executeComand();
		} catch (IOException e) {
			throw new MojoExecutionException(e.getMessage());
		}
	}

	protected boolean isWindows() {
		return System.getProperty("os.name").indexOf("Win") >= 0;
	}
	protected boolean isMac() {
		return System.getProperty("os.name").indexOf("Mac") >= 0;
	}

	protected CommandLine getCrossPlatformCommandLine() {
		final CommandLine cmdLine;

		if (isWindows()) {
			cmdLine = new CommandLine("cmd");
			cmdLine.addArgument("/c");
		} else if (isMac()) {
			cmdLine = new CommandLine("/bin/sh");
			cmdLine.addArgument("-c");
		} else {
			cmdLine = new CommandLine("/bin/env");
		}

		return cmdLine;
	}

	protected void executeCommandLine(CommandLine cmdLine, Map<String, String> env, File workingDir) throws IOException {
		DefaultExecutor executor = new DefaultExecutor();
		executor.setWorkingDirectory(workingDir);

		PumpStreamHandler pump = new PumpStreamHandler(System.out, System.err, System.in);
		executor.setStreamHandler(pump);

		executor.execute(cmdLine, env);
	}

	protected Map<String, String> getEnv() {
		final Map<String, String> env = new HashMap<String, String>(System.getenv());<commit_msg>[EASYEASY-1926] set env launch as in mac<commit_after>package com.byclosure.maven.plugins.phonegap;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public abstract class AbstractPhoneGapMojo extends AbstractMojo {

	/**
	 * @parameter default-value="${project.basedir}" expression="${phonegap.base_dir}"
	 */
	protected File projectBaseDir;

	/**
	 * @parameter default-value="${project.build.directory}" expression="${phonegap.working_dir}
	 */
	protected File workingDir;

	/**
	 * @parameter default-value="phonegap" expression="${phonegap.project_path}
	 */
	protected String projectPath;

	/**
	 * @parameter expression="${phonegap.phonegap_bin}"
	 */
	protected File phonegapBin;


	protected abstract void executeComand() throws IOException;

	@Override
	public void execute() throws MojoExecutionException {
		try {
			executeComand();
		} catch (IOException e) {
			throw new MojoExecutionException(e.getMessage());
		}
	}

	protected boolean isWindows() {
		return System.getProperty("os.name").indexOf("Win") >= 0;
	}
	protected boolean isMac() {
		return System.getProperty("os.name").indexOf("Mac") >= 0;
	}

	protected CommandLine getCrossPlatformCommandLine() {
		final CommandLine cmdLine;

		if (isWindows()) {
			cmdLine = new CommandLine("cmd");
			cmdLine.addArgument("/c");
		} else if (isMac()) {
			cmdLine = new CommandLine("/bin/sh");
			cmdLine.addArgument("-c");
		} else {
			cmdLine = new CommandLine("/bin/sh");
			cmdLine.addArgument("-c");
		}

		return cmdLine;
	}

	protected void executeCommandLine(CommandLine cmdLine, Map<String, String> env, File workingDir) throws IOException {
		DefaultExecutor executor = new DefaultExecutor();
		executor.setWorkingDirectory(workingDir);

		PumpStreamHandler pump = new PumpStreamHandler(System.out, System.err, System.in);
		executor.setStreamHandler(pump);

		executor.execute(cmdLine, env);
	}

	protected Map<String, String> getEnv() {
		final Map<String, String> env = new HashMap<String, String>(System.getenv());
{'fraction_non_alphanumeric': 0.13224237063246352, 'fraction_numerical': 0.0017691287041132243, 'mean_word_length': 5.079301075268817, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5454284', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1325, 'n_words': 290}