/** * Loads default Maven settings from standard location or from a location specified by a property * * @return The built default maven {@link Settings} */ public Settings buildDefaultSettings() { return buildSettings(getDefaultSettingsBuildingRequest()); }
/** * Creates a Maven repository system */ public MavenRepositorySystem() { this.system = getRepositorySystem(); }
/** * Finds a current implementation of repository system. A {@link RepositorySystem} is an entry point to dependency * resolution * * @return A repository system * @throws UnsupportedOperationException if {@link RepositorySystem} was not bootstrapped correctly */ private RepositorySystem getRepositorySystem() throws UnsupportedOperationException { final ShrinkWrapResolverServiceLocator locator = new ShrinkWrapResolverServiceLocator(); // if running from inside plugin, we required Maven 3.1.0 or newer // that happens because Maven handles Aether dependencies in plugins a special way so we can't provide our own // implementation, it is simply removed from classpath and not available at all // // locator will throw an exception if repository system cannot be set up return locator.getService(RepositorySystem.class); } }
/** * Returns an instance of the {@link Settings}, if it hasn't been created yet, it generates it from the default settings. * * @return an instance of the {@link Settings} */ protected Settings getSettings() { if (this.settings == null) { this.settings = new MavenSettingsBuilder().buildDefaultSettings(); // ensure we keep offline(boolean) if previously set propagateProgrammaticOfflineIntoSettings(); } return this.settings; }
private <T> ShrinkWrapResolverServiceLocator addService(Class<T> type, Class<? extends T> implementationType) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.addImplementation(implementationType); cache.put(type, item); return this; }
/** * Sets the instances for a service. * * @param <T> The service type. * @param type The interface describing the service, must not be {@code null}. * @param services The instances of the service, may be {@code null} but must not contain {@code null} elements. * @return This locator for chaining, never {@code null}. */ @SuppressWarnings("unchecked") private <T> ShrinkWrapResolverServiceLocator setServices(Class<T> type, T... services) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.replaceInstances(services); cache.put(type, item); return this; }
/** * Creates a builder which has access to Maven system and current settings * * @param system * the Maven system * @param settings * Maven and resolver settings */ MavenManagerBuilder(RepositorySystem system, Settings settings) { this.system = system; this.settings = settings; this.useLegacyLocalRepository = Boolean.parseBoolean(SecurityActions.getProperty(USE_LEGACY_REPO_KEY)); }
public ConfigurableMavenWorkingSessionImpl() { this.system = new MavenRepositorySystem(); this.settingsManager = new SettingsManager(); }
/** * Generates an instance of the {@link DefaultRepositorySystemSession} and takes into account related properties */ private void generateSession() { this.session = this.system.getSession(getSettings(), this.useLegacyLocalRepository); if (this.disableClassPathWorkspaceReader) { ((DefaultRepositorySystemSession) this.session).setWorkspaceReader(null); } } }
/** * Loads default Maven settings from standard location or from a location specified by a property * * @return The built default maven {@link Settings} */ public Settings buildDefaultSettings() { return buildSettings(getDefaultSettingsBuildingRequest()); }
/** * Returns an instance of the {@link Settings}, if it hasn't been created yet, it generates it from the default settings. * * @return an instance of the {@link Settings} */ protected Settings getSettings() { if (this.settings == null) { this.settings = new MavenSettingsBuilder().buildDefaultSettings(); // ensure we keep offline(boolean) if previously set propagateProgrammaticOfflineIntoSettings(); } return this.settings; }
/** * Finds a current implementation of repository system. A {@link RepositorySystem} is an entry point to dependency * resolution * * @return A repository system * @throws UnsupportedOperationException if {@link RepositorySystem} was not bootstrapped correctly */ private RepositorySystem getRepositorySystem() throws UnsupportedOperationException { final ShrinkWrapResolverServiceLocator locator = new ShrinkWrapResolverServiceLocator(); // if running from inside plugin, we required Maven 3.1.0 or newer // that happens because Maven handles Aether dependencies in plugins a special way so we can't provide our own // implementation, it is simply removed from classpath and not available at all // // locator will throw an exception if repository system cannot be set up return locator.getService(RepositorySystem.class); } }
private <T> ShrinkWrapResolverServiceLocator addService(Class<T> type, Class<? extends T> implementationType) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.addImplementation(implementationType); cache.put(type, item); return this; }
/** * Sets the instances for a service. * * @param <T> The service type. * @param type The interface describing the service, must not be {@code null}. * @param services The instances of the service, may be {@code null} but must not contain {@code null} elements. * @return This locator for chaining, never {@code null}. */ @SuppressWarnings("unchecked") private <T> ShrinkWrapResolverServiceLocator setServices(Class<T> type, T... services) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.replaceInstances(services); cache.put(type, item); return this; }
/** * Creates a builder which has access to Maven system and current settings * * @param system * the Maven system * @param settings * Maven and resolver settings */ MavenManagerBuilder(RepositorySystem system, Settings settings) { this.system = system; this.settings = settings; this.useLegacyLocalRepository = Boolean.parseBoolean(SecurityActions.getProperty(USE_LEGACY_REPO_KEY)); }
/** * Creates a Maven repository system */ public MavenRepositorySystem() { this.system = getRepositorySystem(); }
public ConfigurableMavenWorkingSessionImpl() { this.system = new MavenRepositorySystem(); this.settingsManager = new SettingsManager(); }
/** * Generates an instance of the {@link DefaultRepositorySystemSession} and takes into account related properties */ private void generateSession() { this.session = this.system.getSession(getSettings(), this.useLegacyLocalRepository); if (this.disableClassPathWorkspaceReader) { ((DefaultRepositorySystemSession) this.session).setWorkspaceReader(null); } } }
private Settings enrichWithLocalRepository(Settings settings) { // set default value if not set at all if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) { settings.setLocalRepository(DEFAULT_REPOSITORY_PATH); } // override any value with system property based location String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION); if (altLocalRepository != null && altLocalRepository.length() > 0) { settings.setLocalRepository(altLocalRepository); } return settings; }
private Settings enrichWithLocalRepository(Settings settings) { // set default value if not set at all if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) { settings.setLocalRepository(DEFAULT_REPOSITORY_PATH); } // override any value with system property based location String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION); if (altLocalRepository != null && altLocalRepository.length() > 0) { settings.setLocalRepository(altLocalRepository); } return settings; }