/*
 * Copyright 2012-2014 Thomas Bouffard (redfish4ktc)
 *
 * 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 org.ktc.soapui.maven.extension;

import static org.apache.commons.lang3.ArrayUtils.nullToEmpty;

import com.eviware.soapui.tools.AbstractSoapUIRunner;
import java.util.Properties;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

public abstract class AbstractSoapuiRunnerMojo extends AbstractSoapuiMojo {
    // already in smartbear implementation
    private String[] globalProperties;
    protected String projectFile;
    private String projectPassword;
    private String[] projectProperties;
    protected boolean saveAfterRun;
    private String settingsFile;
    private String settingsPassword;
    private boolean skip;
    private Properties soapuiProperties;

    // custom maven-soapui-extension-plugin
    protected String runnerType;

    @Override
    protected void performExecute() throws MojoExecutionException, MojoFailureException {
        if (skip || (System.getProperty("maven.test.skip", "false").equals("true"))) {
            getLog().info("SoapUI execution is skipped.");
            return;
        }

        // TODO this is managed by the plugin.xml (default value) + all soapui runners
        if (projectFile == null) {
            throw new MojoExecutionException("soapui-project-file setting is required");
        }
        performRunnerExecute();
    }

    protected abstract void performRunnerExecute() throws MojoExecutionException, MojoFailureException;

    protected void configureWithSharedParameters(AbstractSoapUIRunner runner) {
        configureWithSharedParameters(runner, projectFile);
    }

    protected void configureWithSharedParameters(AbstractSoapUIRunner runner, String currentProjectFile) {
        runner.setProjectFile(currentProjectFile);
        runner.setProjectPassword(projectPassword);
        runner.setSettingsFile(settingsFile);
        runner.setSoapUISettingsPassword(settingsPassword);
        runner.setGlobalProperties(nullToEmpty(globalProperties));
        runner.setProjectProperties(nullToEmpty(projectProperties));

        initializeSystemProperties();
    }

    private void initializeSystemProperties() {
        if (!isNullOrEmpty(soapuiProperties)) {
            for (Object keyObject : soapuiProperties.keySet()) {
                String key = (String) keyObject;
                getLog().info("Setting " + key + " value " + soapuiProperties.getProperty(key));
                System.setProperty(key, soapuiProperties.getProperty(key));
            }
        }
    }

    private static boolean isNullOrEmpty(Properties props) {
        return props == null || props.isEmpty();
    }

}

@@ -1717,229 +1717,8 @@
  %7D%0A%0A
-        // TODO this is managed by the plugin.xml (default value) + all soapui runners%0A        if (projectFile == null) %7B%0A            throw new MojoExecutionException(%22soapui-project-file setting is required%22);%0A        %7D%0A
     

Remove null check on project parameter #118