// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java
// public static void warn(String message) {
//     log.log(status(Status.WARNING, message));
// }
// 
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java
// public interface MavenAndroidProject {
// 
//     public String getName();
// 
//     public String getGroup();
// 
//     public String getVersion();
// 
//     public boolean isAndroidProject();
// 
//     public boolean isLibrary();
// 
//     public List<Dependency> getNonRuntimeDependencies();
// 
//     public List<Dependency> getLibraryDependencies();
// 
//     public File getAssetsDirectory();
// 
//     public File getResourceFolder();
// 
//     public File getAndroidManifestFile();
//     
//     public File getDestinationManifestFile();
// 
//     public List<String> getPlatformProvidedDependencies();
// 
//     public List<String> getSourcePaths();
//     
//     public String getOutputDirectory();
// 
//     public boolean isIgnoreOptionalWarningsInGenFolder();
// 
//     public List<String> getTestSourcePaths();
// 
//     public List<String> getResourcePaths();
// 
//     public List<String> getTestResourcePaths();
// 
// }


import static com.google.common.collect.Iterables.filter;
import static me.gladwell.eclipse.m2e.android.Log.warn;
import java.io.FileNotFoundException;
import java.util.List;
import me.gladwell.eclipse.m2e.android.project.AndroidProjectFactory;
import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
    @Override
    public Iterable<IClasspathEntry> load(IJavaProject project) throws FileNotFoundException {
        final Iterable<IClasspathEntry> nonRuntimeDependencies = super.load(project);

        IMavenProjectFacade facade = projectRegistry.getProject(project.getProject());
        if(facade != null) {
            try {
                MavenProject mavenProject = facade.getMavenProject(new NullProgressMonitor());
                
                final MavenAndroidProject androidProject = mavenProjectFactory.createAndroidProject(mavenProject);
                final List<String> platformProvidedDependencies = androidProject.getPlatformProvidedDependencies();

                if (platformProvidedDependencies != null) {
                    final Iterable<IClasspathEntry> prunedNonRuntimeDependencies = filter(nonRuntimeDependencies,
                            new Predicate<IClasspathEntry>() {
                                public boolean apply(IClasspathEntry entry) {
                                    if (!platformProvidedDependencies.contains(entry.getPath().toOSString())) {
                                        return true;
                                    } else {
                                        return false;
                                    }
                                }
                            });

                    return prunedNonRuntimeDependencies;
                }
            } catch (CoreException e) {
                throw new ProjectConfigurationException(e);
            }
        } else {
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java
// public static void warn(String message) {
//     log.log(status(Status.WARNING, message));
// }
// 
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java
// public interface MavenAndroidProject {
// 
//     public String getName();
// 
//     public String getGroup();
// 
//     public String getVersion();
// 
//     public boolean isAndroidProject();
// 
//     public boolean isLibrary();
// 
//     public List<Dependency> getNonRuntimeDependencies();
// 
//     public List<Dependency> getLibraryDependencies();
// 
//     public File getAssetsDirectory();
// 
//     public File getResourceFolder();
// 
//     public File getAndroidManifestFile();
//     
//     public File getDestinationManifestFile();
// 
//     public List<String> getPlatformProvidedDependencies();
// 
//     public List<String> getSourcePaths();
//     
//     public String getOutputDirectory();
// 
//     public boolean isIgnoreOptionalWarningsInGenFolder();
// 
//     public List<String> getTestSourcePaths();
// 
//     public List<String> getResourcePaths();
// 
//     public List<String> getTestResourcePaths();
// 
// }


// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/PrunePlatformProvidedDependenciesClasspathLoader.java
import static com.google.common.collect.Iterables.filter;
import static me.gladwell.eclipse.m2e.android.Log.warn;
import java.io.FileNotFoundException;
import java.util.List;
import me.gladwell.eclipse.m2e.android.project.AndroidProjectFactory;
import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import com.google.common.base.Predicate;
import com.google.inject.Inject;

    @Override
    public Iterable<IClasspathEntry> load(IJavaProject project) throws FileNotFoundException {
        final Iterable<IClasspathEntry> nonRuntimeDependencies = super.load(project);

        IMavenProjectFacade facade = projectRegistry.getProject(project.getProject());
        if(facade != null) {
            try {
                MavenProject mavenProject = facade.getMavenProject(new NullProgressMonitor());
                
                final MavenAndroidProject androidProject = mavenProjectFactory.createAndroidProject(mavenProject);
                final List<String> platformProvidedDependencies = androidProject.getPlatformProvidedDependencies();

                if (platformProvidedDependencies != null) {
                    final Iterable<IClasspathEntry> prunedNonRuntimeDependencies = filter(nonRuntimeDependencies,
                            new Predicate<IClasspathEntry>() {
                                public boolean apply(IClasspathEntry entry) {
                                    if (!platformProvidedDependencies.contains(entry.getPath().toOSString())) {
                                        return true;
                                    } else {
                                        return false;
                                    }
                                }
                            });

                    return prunedNonRuntimeDependencies;
                }
            } catch (CoreException e) {
                throw new ProjectConfigurationException(e);
            }
        } else {
            warn("maven project not yet registered for " + project);