// Path: src/main/java/ch/sbb/maven/plugins/iib/utils/SkipUtil.java
// public class SkipUtil {
// 
//     @SuppressWarnings("rawtypes")
//     static LinkedHashMap<Class, String> classGoalMap = new LinkedHashMap<Class, String>();
//     List<String> skipGoals = new ArrayList<String>();
//     String skipToGoal = null;
// 
//     static
//     {
//         classGoalMap.put(InitializeBarBuildWorkspaceMojo.class, "initialize");
//         classGoalMap.put(PrepareBarBuildWorkspaceMojo.class, "generate-resources");
//         classGoalMap.put(ValidateBarBuildWorkspaceMojo.class, "process-resources");
//         classGoalMap.put(PackageBarMojo.class, "compile");
//         classGoalMap.put(String.class, "test-compile");
//         classGoalMap.put(ApplyBarOverridesMojo.class, "process-classes");
//         classGoalMap.put(ValidateClassloaderApproachMojo.class, "process-classes");
//         classGoalMap.put(MqsiDeployMojo.class, "pre-integration-test");
//         classGoalMap.put(Integer.class, "integration-test");
//         classGoalMap.put(Double.class, "verify");
//         classGoalMap.put(DeployBarMojo.class, "deploy");
// 
// 
//     }
// 
//     private static String getValidGoals()
//     {
//         boolean first = true;
//         StringBuilder sb = new StringBuilder();
//         for (String goal : classGoalMap.values())
//         {
//             if (!first)
//             {
//                 sb.append(",");
//             }
//             sb.append(goal);
//             first = false;
//         }
//         return sb.toString();
//     }
// 
// 
//     @SuppressWarnings("rawtypes")
//     public boolean isSkip(Class clazz)
//     {
//         // / determine goals to skip from comma-separated list
//         String skip = System.getProperty("skip");
//         if (skip != null && !skip.trim().isEmpty())
//         {
//             String[] sa = skip.split(Pattern.quote(","));
//             for (String goal : sa)
//             {
//                 if (goal == null) {
//                     continue;
//                 }
//                 if (goal.trim().isEmpty()) {
//                     continue;
//                 }
//                 goal = goal.trim().toLowerCase();
//                 if (!classGoalMap.values().contains(goal)) {
//                     throw new RuntimeException("The '-Dskip=...' value(s) must be a comma-separated list of goal(s) from the group:" + getValidGoals());
// 
//                 }
//                 skipGoals.add(goal);
//             }
//         }
// 
//         // / determine goals to skip from comma-separated list
//         String skipTo = System.getProperty("skipTo");
//         if (skipTo != null && !skipTo.trim().isEmpty())
//         {
//             skipTo = skipTo.toLowerCase().trim();
// 
//             if (!classGoalMap.values().contains(skipTo))
//             {
//                 throw new RuntimeException("The '-DskipTo=...' value must be a single goal from the group:" + getValidGoals());
//             }
//             skipToGoal = skipTo;
// 
//         }
// 
// 
//         if (skipGoals.isEmpty() && skipToGoal == null) {
//             return false;
//         }
// 
//         String currentGoal = classGoalMap.get(clazz);
//         if (skipGoals.contains(currentGoal))
//         {
//             return true;
//         }
// 
//         // / see if skipToGoal
//         if (skipToGoal == null)
//         {
//             return false;
//         }
// 
// 
//         // / go through the list to determine if goal is before current
//         if (skipToGoal.equals(currentGoal)) {
//             return false;
//         }
// 
//         List<String> goalsBefore = new ArrayList<String>();
//         List<String> goalsAfter = new ArrayList<String>();
//         boolean skipToGoalFound = false;
//         for (String goal : classGoalMap.values())
//         {
//             if (goal.equals(skipToGoal))
//             {
//                 skipToGoalFound = true;
//                 continue;
//             }
//             if (skipToGoalFound)
//             {
//                 goalsAfter.add(goal);
//             }
//             else
//             {
//                 goalsBefore.add(goal);
//             }
//         }
// 
//         if (goalsBefore.contains(currentGoal)) {
//             return true;
//         }
//         if (goalsAfter.contains(currentGoal)) {
//             return false;
//         }
//         return false;
// 
// 
//     }
// 
// 
// }


import java.io.File;
import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.FileUtils;
import ch.sbb.maven.plugins.iib.utils.SkipUtil;
package ch.sbb.maven.plugins.iib.mojos;




/**
 * Cleans up the ${iib.workspace} directory. Build errors will appear in the IIB Toolkit if .msgflow files are left under the ${iib.workspace} - the path determines the Namespace of the flow and that
 * certainly won't match the original directory structure.
 */
@Mojo(name = "clean-bar-build-workspace", requiresProject = false)
public class CleanBarBuildWorkspaceMojo extends AbstractMojo {

    /**
     * The path of the workspace in which the projects were created.
     */
    @Parameter(property = "workspace", defaultValue = "${project.build.directory}/iib/workspace", required = true)
    protected File workspace;

    /**
     * set to true to disable the workspace cleaning
     */
    @Parameter(property = "wipeoutWorkspace", defaultValue = "false")
    protected boolean wipeoutWorkspace;

    public void execute() throws MojoFailureException {
// Path: src/main/java/ch/sbb/maven/plugins/iib/utils/SkipUtil.java
// public class SkipUtil {
// 
//     @SuppressWarnings("rawtypes")
//     static LinkedHashMap<Class, String> classGoalMap = new LinkedHashMap<Class, String>();
//     List<String> skipGoals = new ArrayList<String>();
//     String skipToGoal = null;
// 
//     static
//     {
//         classGoalMap.put(InitializeBarBuildWorkspaceMojo.class, "initialize");
//         classGoalMap.put(PrepareBarBuildWorkspaceMojo.class, "generate-resources");
//         classGoalMap.put(ValidateBarBuildWorkspaceMojo.class, "process-resources");
//         classGoalMap.put(PackageBarMojo.class, "compile");
//         classGoalMap.put(String.class, "test-compile");
//         classGoalMap.put(ApplyBarOverridesMojo.class, "process-classes");
//         classGoalMap.put(ValidateClassloaderApproachMojo.class, "process-classes");
//         classGoalMap.put(MqsiDeployMojo.class, "pre-integration-test");
//         classGoalMap.put(Integer.class, "integration-test");
//         classGoalMap.put(Double.class, "verify");
//         classGoalMap.put(DeployBarMojo.class, "deploy");
// 
// 
//     }
// 
//     private static String getValidGoals()
//     {
//         boolean first = true;
//         StringBuilder sb = new StringBuilder();
//         for (String goal : classGoalMap.values())
//         {
//             if (!first)
//             {
//                 sb.append(",");
//             }
//             sb.append(goal);
//             first = false;
//         }
//         return sb.toString();
//     }
// 
// 
//     @SuppressWarnings("rawtypes")
//     public boolean isSkip(Class clazz)
//     {
//         // / determine goals to skip from comma-separated list
//         String skip = System.getProperty("skip");
//         if (skip != null && !skip.trim().isEmpty())
//         {
//             String[] sa = skip.split(Pattern.quote(","));
//             for (String goal : sa)
//             {
//                 if (goal == null) {
//                     continue;
//                 }
//                 if (goal.trim().isEmpty()) {
//                     continue;
//                 }
//                 goal = goal.trim().toLowerCase();
//                 if (!classGoalMap.values().contains(goal)) {
//                     throw new RuntimeException("The '-Dskip=...' value(s) must be a comma-separated list of goal(s) from the group:" + getValidGoals());
// 
//                 }
//                 skipGoals.add(goal);
//             }
//         }
// 
//         // / determine goals to skip from comma-separated list
//         String skipTo = System.getProperty("skipTo");
//         if (skipTo != null && !skipTo.trim().isEmpty())
//         {
//             skipTo = skipTo.toLowerCase().trim();
// 
//             if (!classGoalMap.values().contains(skipTo))
//             {
//                 throw new RuntimeException("The '-DskipTo=...' value must be a single goal from the group:" + getValidGoals());
//             }
//             skipToGoal = skipTo;
// 
//         }
// 
// 
//         if (skipGoals.isEmpty() && skipToGoal == null) {
//             return false;
//         }
// 
//         String currentGoal = classGoalMap.get(clazz);
//         if (skipGoals.contains(currentGoal))
//         {
//             return true;
//         }
// 
//         // / see if skipToGoal
//         if (skipToGoal == null)
//         {
//             return false;
//         }
// 
// 
//         // / go through the list to determine if goal is before current
//         if (skipToGoal.equals(currentGoal)) {
//             return false;
//         }
// 
//         List<String> goalsBefore = new ArrayList<String>();
//         List<String> goalsAfter = new ArrayList<String>();
//         boolean skipToGoalFound = false;
//         for (String goal : classGoalMap.values())
//         {
//             if (goal.equals(skipToGoal))
//             {
//                 skipToGoalFound = true;
//                 continue;
//             }
//             if (skipToGoalFound)
//             {
//                 goalsAfter.add(goal);
//             }
//             else
//             {
//                 goalsBefore.add(goal);
//             }
//         }
// 
//         if (goalsBefore.contains(currentGoal)) {
//             return true;
//         }
//         if (goalsAfter.contains(currentGoal)) {
//             return false;
//         }
//         return false;
// 
// 
//     }
// 
// 
// }


// Path: src/main/java/ch/sbb/maven/plugins/iib/mojos/CleanBarBuildWorkspaceMojo.java
import java.io.File;
import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.FileUtils;
import ch.sbb.maven.plugins.iib.utils.SkipUtil;

package ch.sbb.maven.plugins.iib.mojos;




/**
 * Cleans up the ${iib.workspace} directory. Build errors will appear in the IIB Toolkit if .msgflow files are left under the ${iib.workspace} - the path determines the Namespace of the flow and that
 * certainly won't match the original directory structure.
 */
@Mojo(name = "clean-bar-build-workspace", requiresProject = false)
public class CleanBarBuildWorkspaceMojo extends AbstractMojo {

    /**
     * The path of the workspace in which the projects were created.
     */
    @Parameter(property = "workspace", defaultValue = "${project.build.directory}/iib/workspace", required = true)
    protected File workspace;

    /**
     * set to true to disable the workspace cleaning
     */
    @Parameter(property = "wipeoutWorkspace", defaultValue = "false")
    protected boolean wipeoutWorkspace;

    public void execute() throws MojoFailureException {
        if (new SkipUtil().isSkip(this.getClass())) {