// Path: src/main/java/com/tobedevoured/naether/aether/ValidSystemScopeDependencySelector.java
// public class ValidSystemScopeDependencySelector implements DependencySelector {
// 
//     private static final String SYSTEM_SCOPE = "system";
//     
//     public boolean selectDependency(Dependency dependency) {
//         if ( SYSTEM_SCOPE.equals( dependency.getScope() ) ) {
//             String localPath = dependency.getArtifact().getProperties().get( "localPath" );
//             if ( localPath == null || !(new File( localPath )).exists() ) {
//                 return false;
//             }
//         }
//         
//         return true;
//     }
// 
//     public DependencySelector deriveChildSelector( DependencyCollectionContext context) {
//         return this;
//     }
// 
// }


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.repository.internal.DefaultServiceLocator;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.collection.CollectRequest;
import org.sonatype.aether.collection.CollectResult;
import org.sonatype.aether.collection.DependencyCollectionException;
import org.sonatype.aether.connector.wagon.WagonProvider;
import org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory;
import org.sonatype.aether.deployment.DeployRequest;
import org.sonatype.aether.deployment.DeploymentException;
import org.sonatype.aether.installation.InstallRequest;
import org.sonatype.aether.installation.InstallationException;
import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.resolution.DependencyRequest;
import org.sonatype.aether.resolution.DependencyResolutionException;
import org.sonatype.aether.resolution.DependencyResult;
import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
import org.sonatype.aether.util.graph.selector.AndDependencySelector;
import com.tobedevoured.naether.aether.ValidSystemScopeDependencySelector;
    }
    
    
    /**
     * Set the {@link BuildWorkspaceReader}
     * 
     * @param artifacts List
     */
    public void setBuildWorkspaceReader(List<Artifact> artifacts) {
        BuildWorkspaceReader reader = new BuildWorkspaceReader();
        
        for ( Artifact artifact : artifacts ) {
            reader.addArtifact( artifact );
        }
        
        systemSession = (MavenRepositorySystemSession)systemSession.setWorkspaceReader( reader );
        
    }

    /**
     * Create new {@link RepositorySystem}
     */
    public void newRepositorySystem() {
        DefaultServiceLocator locator = new DefaultServiceLocator();
        locator.setServices(WagonProvider.class, new ManualWagonProvider());
        locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);

        repositorySystem = locator.getService(RepositorySystem.class);

        MavenRepositorySystemSession session = new MavenRepositorySystemSession();
// Path: src/main/java/com/tobedevoured/naether/aether/ValidSystemScopeDependencySelector.java
// public class ValidSystemScopeDependencySelector implements DependencySelector {
// 
//     private static final String SYSTEM_SCOPE = "system";
//     
//     public boolean selectDependency(Dependency dependency) {
//         if ( SYSTEM_SCOPE.equals( dependency.getScope() ) ) {
//             String localPath = dependency.getArtifact().getProperties().get( "localPath" );
//             if ( localPath == null || !(new File( localPath )).exists() ) {
//                 return false;
//             }
//         }
//         
//         return true;
//     }
// 
//     public DependencySelector deriveChildSelector( DependencyCollectionContext context) {
//         return this;
//     }
// 
// }


// Path: src/main/java/com/tobedevoured/naether/repo/RepositoryClient.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.repository.internal.DefaultServiceLocator;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.collection.CollectRequest;
import org.sonatype.aether.collection.CollectResult;
import org.sonatype.aether.collection.DependencyCollectionException;
import org.sonatype.aether.connector.wagon.WagonProvider;
import org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory;
import org.sonatype.aether.deployment.DeployRequest;
import org.sonatype.aether.deployment.DeploymentException;
import org.sonatype.aether.installation.InstallRequest;
import org.sonatype.aether.installation.InstallationException;
import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.resolution.DependencyRequest;
import org.sonatype.aether.resolution.DependencyResolutionException;
import org.sonatype.aether.resolution.DependencyResult;
import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
import org.sonatype.aether.util.graph.selector.AndDependencySelector;
import com.tobedevoured.naether.aether.ValidSystemScopeDependencySelector;

    }
    
    
    /**
     * Set the {@link BuildWorkspaceReader}
     * 
     * @param artifacts List
     */
    public void setBuildWorkspaceReader(List<Artifact> artifacts) {
        BuildWorkspaceReader reader = new BuildWorkspaceReader();
        
        for ( Artifact artifact : artifacts ) {
            reader.addArtifact( artifact );
        }
        
        systemSession = (MavenRepositorySystemSession)systemSession.setWorkspaceReader( reader );
        
    }

    /**
     * Create new {@link RepositorySystem}
     */
    public void newRepositorySystem() {
        DefaultServiceLocator locator = new DefaultServiceLocator();
        locator.setServices(WagonProvider.class, new ManualWagonProvider());
        locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);

        repositorySystem = locator.getService(RepositorySystem.class);

        MavenRepositorySystemSession session = new MavenRepositorySystemSession();
        session = (MavenRepositorySystemSession)session.setDependencySelector( new AndDependencySelector( session.getDependencySelector(), new ValidSystemScopeDependencySelector() ) );