package org.jbehave.mojo;

import java.util.List;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Mojo to run scenarios
 * 
 * @author Mauro Talevi
 * @goal run-scenarios
 */
public class ScenarioRunnerMojo extends AbstractJBehaveMojo {

    /**
     * Scenario class names
     * 
     * @parameter
     */
    private List<String> scenarioClassNames;

    public void execute() throws MojoExecutionException, MojoFailureException {
        List<String> scenarios = scenarioClassNames;
        if ( scenarios == null || scenarios.isEmpty() ){
            scenarios = findScenarioClassNames();
        }
        for (String scenario : scenarios) {
            try {
                getLog().info("Running scenario "+scenario);
                createScenarioClassLoader().newScenario(scenario).runUsingSteps();
            } catch (Throwable e) {
                throw new MojoExecutionException("Failed to run scenario " + scenario, e);
            }
        }
    }

}

package org.jbehave.mojo;

import java.util.List;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Mojo to run scenarios
 * 
 * @author Mauro Talevi
 * @goal run-scenarios
 */
public class ScenarioRunnerMojo extends AbstractJBehaveMojo {

    /**
     * Scenario class names
     * 
     * @parameter
     */
    private List<String> scenarioClassNames;

    public void execute() throws MojoExecutionException, MojoFailureException {
        List<String> scenarios = scenarioClassNames;
        if (scenarios == null || scenarios.isEmpty()) {
            scenarios = findScenarioClassNames();
        }
        if (scenarios.isEmpty()) {
            getLog().info("No scenarios to run.");
        } else {
            for (String scenario : scenarios) {
                try {
                    getLog().info("Running scenario " + scenario);
                    createScenarioClassLoader().newScenario(scenario).runUsingSteps();
                } catch (Throwable e) {
                    throw new MojoExecutionException("Failed to run scenario " + scenario, e);
                }
            }
        }
    }

}

Add log message when no scenario are found.
Add log message when no scenario are found.

git-svn-id: 1c3b30599278237804f5418c838e2a3e6391d478@825 df8dfae0-ecdd-0310-b8d8-a050f7ac8317
