/*
 * Copyright 2014-2015 Red Hat, Inc, and individual contributors.
 *
 * 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.projectodd.wunderboss;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class Utils {
    public static List<URL> classpathStringToURLS(String cp) {
        List<URL> urls = new ArrayList<>();
        try {
            for (File each : classpathStringToFiles(cp)) {
                urls.add(each.toURI().toURL());
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        return urls;
    }

    public static List<File> classpathStringToFiles(String cp) {
        List<File> files = new ArrayList<>();
        for(String each : classpathStringToArray(cp)) {
            files.add(new File(each));
        }

        return files;
    }
    
    public static String[] classpathStringToArray(String cp) {
        return cp.trim().split(":");
    }

    public static void deleteRecursively(File directory) {
        if (directory.isDirectory()) {
            File[] children = directory.listFiles();
            if (children != null) {
                for (File file : children) {
                    deleteRecursively(file);
                }
            }
        }
        directory.delete();
    }
}

@@ -1494,34 +1494,848 @@
     
-return cp.trim().split(%22:%22
+cp = cp.trim();%0A        String%5B%5D entries = cp.split(%22:%22);%0A        // Basic splitting on %22:%22 may break some entries under Windows of the%0A        // form C:%5Cfoo%5Cbar.jar%0A        List%3CString%3E results = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C entries.length; i++) %7B%0A            String entry = entries%5Bi%5D;%0A            if (i + 1 %3C entries.length) %7B%0A                String nextEntry = entries%5Bi + 1%5D;%0A                if (entry.matches(%22%5BA-Za-z%5D%22) && nextEntry.charAt(0) == '%5C%5C') %7B%0A                    // We split up a path containing a Windows drive letter so%0A                    // reassemble it%0A                    results.add(entry + %22:%22 + nextEntry);%0A                    i++;%0A                    continue;%0A                %7D%0A            %7D%0A            results.add(entry);%0A        %7D%0A        return results.toArray(new String%5Bresults.size()%5D
 );%0A 

Fix classpath splitting on Windows