<commit_before>/*
 * Copyright 2014 <NAME> <<EMAIL>>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.psorobka.appium;

import java.io.File;
import java.io.IOException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
@Mojo(name = "start")
public class StartServerMojo extends AbstractMojo {

    public static final String PROCESS_PROPERTY_NAME = "process";

    @Parameter(defaultValue = "${project.build.directory}", readonly = true)
    private File target;
    @Parameter(defaultValue = "${project.build.directory}\\node\\npm\\node_modules\\.bin")
    private File appiumHome;
    @Parameter(defaultValue = "${session}", readonly = true)
    private MavenSession session;

    @Override
    public void execute() throws MojoExecutionException {
        try {
            getLog().debug("execute start");
            ProcessBuilder processBuilder = new ProcessBuilder();
            final String appiumBin = appiumHome.getAbsolutePath() + File.separator + "appium.cmd";
            getLog().debug("appium binary: " + appiumBin);
            processBuilder.command(appiumBin, "--log-timestamp");
            processBuilder.redirectError(new File(target, "appiumErrorLog.txt"));
            processBuilder.redirectOutput(new File(target, "appiumOutputLog.txt"));
            getLog().info("Starting Appium server...");
            Process startProcess = processBuilder.start();
            getLog().info("Appium server started");
            session.getUserProperties().put(PROCESS_PROPERTY_NAME, startProcess);
        } catch (IOException ex) {
            getLog().error("Error while executing start goal", ex);
            throw new MojoExecutionException("Error while executing start goal", ex);
        }
    }
}
<commit_msg>fixed running on *nix platforms<commit_after>/*
 * Copyright 2014 <NAME> <<EMAIL>>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.psorobka.appium;

import java.io.File;
import java.io.IOException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.Os;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
@Mojo(name = "start")
public class StartServerMojo extends AbstractMojo {

    public static final String PROCESS_PROPERTY_NAME = "process";

    @Parameter(defaultValue = "${project.build.directory}", readonly = true)
    private File target;
    @Parameter(defaultValue = "${project.build.directory}\\node\\npm\\node_modules\\.bin")
    private File appiumHome;
    @Parameter(defaultValue = "${session}", readonly = true)
    private MavenSession session;

    @Override
    public void execute() throws MojoExecutionException {
        try {
            getLog().debug("execute start");
            ProcessBuilder processBuilder = new ProcessBuilder();
            final String appiumBin;
            if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                appiumBin = appiumHome.getAbsolutePath() + File.separator + "appium.cmd";
            } else {
                appiumBin = appiumHome.getAbsolutePath() + File.separator + "appium";
            }
            getLog().debug("appium binary: " + appiumBin);
            processBuilder.command(appiumBin, "--log-timestamp");
            processBuilder.redirectError(new File(target, "appiumErrorLog.txt"));
            processBuilder.redirectOutput(new File(target, "appiumOutputLog.txt"));
            getLog().info("Starting Appium server...");
            Process startProcess = processBuilder.start();
            getLog().info("Appium server started");
            session.getUserProperties().put(PROCESS_PROPERTY_NAME, startProcess);
        } catch (IOException ex) {
            getLog().error("Error while executing start goal", ex);
            throw new MojoExecutionException("Error while executing start goal", ex);
        }
    }
}

{'fraction_non_alphanumeric': 0.11205915813424346, 'fraction_numerical': 0.0030337504740235114, 'mean_word_length': 3.3308702791461413, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3113208', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1367, 'n_words': 398}