package org.strategoxt.imp.metatooling;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;

import org.eclipse.ant.core.IAntPropertyValueProvider;
import org.eclipse.core.runtime.FileLocator;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;

/**
 * Ant property provider that generates a classpath from all installed plugins, to be used for Java compilation in a
 * Spoofax ant build.
 */
public class PluginClasspathProvider implements IAntPropertyValueProvider {
    public String getAntPropertyValue(String antPropertyName) {
        final StringBuilder classpathBuilder = new StringBuilder();
        boolean first = true;
        final BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
        final Bundle[] bundles = bundleContext.getBundles();
        for (final Bundle bundle : bundles) {
            try {
                if (!first) {
                    classpathBuilder.append(File.pathSeparator);
                }
                first = false;

                final File file = FileLocator.getBundleFile(bundle);
                final String path = file.getAbsolutePath();
                if (path.endsWith(".jar")) {
                    /*
                     * An installed JAR plugin.
                     */
                    classpathBuilder.append(path);
                } else {
                    final File targetClasses = Paths.get(path, "target", "classes").toFile();
                    if (targetClasses.exists()) {
                        /*
                         * A plugin under development. Plugins under development have a target/classes directory with
                         * all their classes.
                         */
                        classpathBuilder.append(targetClasses);
                    } else {
                        /*
                         * An installed unpacked plugin. Class files are extracted in this directory.
                         */
                        classpathBuilder.append(path);
                    }
                }
            } catch (IOException e) {

            }
        }

        return classpathBuilder.toString();
    }
}

@@ -1088,16 +1088,32 @@
  false;%0A
+                
 %0A       
@@ -1540,24 +1540,94 @@
 ).toFile();%0A
+                    final File bin = Paths.get(path, %22bin%22).toFile();%0A
             
@@ -1748,117 +1748,321 @@
 ment
-. Plugins under development have a target/classes directory with%0A                         * all their classes
+ with all its classes in the target/classes directory.%0A                         */%0A                        classpathBuilder.append(targetClasses);%0A                    %7D else if (bin.exists()) %7B%0A                    %09/*%0A                         * A plugin under development with all its classes in the bin directory
 .%0A  
@@ -2131,37 +2131,27 @@
 lder.append(
-targetClasses
+bin
 );%0A         

Add support for plugins with "bin" as target directory