public RepositorySystemSession newSystemSession(RepositorySystem sys, Settings settings) { DefaultRepositorySystemSession session = new MavenRepositorySystemSession(); Map<String, Object> configProps = new LinkedHashMap<String, Object>(); putAllEnvProperties(configProps); session.setConfigProperties(configProps); session.setOffline(settings.isOffline()); // session.setUserProperties(settings.getUserProperties()); LocalRepository localRepo = new LocalRepository(getDefaultLocalRepoDir(settings)); session.setLocalRepositoryManager(sys.newLocalRepositoryManager(localRepo)); // session.setProxySelector(getProxySelector()); session.setMirrorSelector(getMirrorSelector(settings)); // session.setAuthenticationSelector(getAuthSelector()); session.setCache(new DefaultRepositoryCache()); // session.setRepositoryListener(new AntRepositoryListener(task)); // session.setWorkspaceReader(ProjectWorkspaceReader.getInstance()); return session; }
/** * Gets manager for local repository * * @return the manager */ public LocalRepositoryManager localRepositoryManager( final RepositorySystemSession session, boolean legacyLocalRepository) { Validate.notNull(session, "session must be specified"); String localRepositoryPath = settings.getLocalRepository(); Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined"); SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED; // here we rely either on system property or flag passed by caller if (useLegacyLocalRepository || legacyLocalRepository) { factory = SWRLocalRepositoryManager.LEGACY; } if (settings.isOffline()) { factory = SWRLocalRepositoryManager.SIMPLE; } LocalRepositoryManager manager = factory.localRepositoryManager(system, session, new File(localRepositoryPath)); return manager; }