/** * Returns the complete path to artifact as stated by Maven 2 repository layout. * * @return artifact path */ public String getArtifactPath() { return getArtifactPath( m_version ); }
public File download(String url) throws IOException { Parser parser = Parser.parsePathWithSchemePrefix(url); return resolveFile( parser.getGroup(), parser.getArtifact(), parser.getClassifier(), parser.getType(), parser.getVersion(), parser.getRepositoryURL() ); }
public String getGlobalUpdatePolicy() { final String propertyName = m_pid + ServiceConstants.PROPERTY_GLOBAL_UPDATE_POLICY; if (contains(propertyName)) { return get(propertyName); } final String propertyValue = m_propertyResolver.get(propertyName); if (propertyValue != null) { set(propertyName, propertyValue); return propertyValue; } return null; }
/** * Creates a new service configuration. * * @param propertyResolver * propertyResolver used to resolve properties; mandatory * @param pid * configuration PID; mandatory */ public MavenConfigurationImpl(final PropertyResolver propertyResolver, final String pid) { NullArgumentException.validateNotNull(propertyResolver, "Property resolver"); m_pid = pid == null ? "" : pid + "."; m_propertyResolver = propertyResolver; settings = buildSettings(getLocalRepoPath(propertyResolver), getSettingsPath(), useFallbackRepositories()); }
public File getLocalRepository() { assertValid(); // Attempt to retrieve local repository location from MavenConfiguration MavenConfiguration configuration = retrieveMavenConfiguration(); if (configuration != null) { MavenRepositoryURL localRepositoryURL = configuration.getLocalRepository(); if (localRepositoryURL != null) { return localRepositoryURL.getFile().getAbsoluteFile(); } } // If local repository not found assume default. String localRepo = System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository"; return new File(localRepo).getAbsoluteFile(); }
private List<RemoteRepository> selectRepositories() { List<RemoteRepository> list = new ArrayList<RemoteRepository>(); List<MavenRepositoryURL> urls = Collections.emptyList(); try { urls = m_config.getRepositories(); } catch( MalformedURLException exc ) { LOG.error( "invalid repository URLs", exc ); } for( MavenRepositoryURL r : urls ) { if( r.isMulti() ) { addSubDirs( list, r.getFile() ); } else { addRepo( list, r ); } } return list; }
List<LocalRepository> selectDefaultRepositories() { List<LocalRepository> list = new ArrayList<LocalRepository>(); List<MavenRepositoryURL> urls = Collections.emptyList(); try { urls = m_config.getDefaultRepositories(); } catch( MalformedURLException exc ) { LOG.error( "invalid repository URLs", exc ); } for( MavenRepositoryURL r : urls ) { if( r.isMulti() ) { addLocalSubDirs(list, r.getFile()); } else { addLocalRepo(list, r); } } return list; }
public static boolean isSnapshot(Parser parser) { String version = parser.getVersion(); return version != null && version.contains("SNAPSHOT"); }
public Map<String, Map<String, String>> getProxySettings(String... protocols) { Map<String, Map<String, String>> pr = new HashMap<String, Map<String, String>>(); if (isProtocolSupportEnabled(protocols)) { parseSystemWideProxySettings(pr); parseProxiesFromProperty( m_propertyResolver.get(m_pid + ServiceConstants.PROPERTY_PROXIES), pr); // if( pr.isEmpty() ) { // if( m_settings == null ) { return Collections.emptyMap(); } // // return m_settings.getProxySettings(); // } } return pr; }
public static String groupId(Parser parser) { String group = parser.getGroup(); int idx = group.indexOf(':'); if (idx > 0) { group = group.substring(idx + 1); } return group; }
private String getSettingsPath() { URL url = getSettingsFileUrl(); return url == null ? null : url.getPath(); }
/** * Lets trim any kind of "mvn:" prefix before parsing */ public static Parser parsePathWithSchemePrefix(String location) throws MalformedURLException { String withoutMvnPrefix = location; boolean done = false; while (!done) { int idx = withoutMvnPrefix.indexOf(':'); if (idx >= 0) { withoutMvnPrefix = withoutMvnPrefix.substring(idx + 1); } // there may be a inlined maven repo location (assuming http), so we are done if we find that if (withoutMvnPrefix.startsWith("http:") || withoutMvnPrefix.startsWith("https:")) { done = true; } else if (withoutMvnPrefix.indexOf(':') < 0) { done = true; } } return new Parser(withoutMvnPrefix); }
private void parseSystemWideProxySettings(Map<String, Map<String, String>> pr) { String httpHost = m_propertyResolver.get("http.proxyHost"); String httpPort = m_propertyResolver.get("http.proxyPort"); String httpnonProxyHosts = m_propertyResolver.get("http.nonProxyHosts"); if (httpHost != null) { parseProxiesFromProperty("http:host=" + httpHost + ",port=" + httpPort + ",nonProxyHosts=" + httpnonProxyHosts, pr); } }
/** * Create a AetherBasedResolver * * @param configuration (must be not null) */ public AetherBasedResolver( final MavenConfiguration configuration, final Mirror mirror ) { m_config = configuration; m_settings = configuration.getSettings(); m_repoSystem = newRepositorySystem(); decryptSettings(); m_proxySelector = selectProxies(); m_mirrorSelector = selectMirrors( mirror ); }
public String getGlobalChecksumPolicy() { final String propertyName = m_pid + ServiceConstants.PROPERTY_GLOBAL_CHECKSUM_POLICY; if (contains(propertyName)) { return get(propertyName); } final String propertyValue = m_propertyResolver.get(propertyName); if (propertyValue != null) { set(propertyName, propertyValue); return propertyValue; } return null; }
/** * {@inheritDoc} */ public Boolean useFallbackRepositories() { if (!contains(m_pid + ServiceConstants.PROPERTY_USE_FALLBACK_REPOSITORIES)) { String useFallbackRepoProp = m_propertyResolver.get(m_pid + ServiceConstants.PROPERTY_USE_FALLBACK_REPOSITORIES); return set(m_pid + ServiceConstants.PROPERTY_USE_FALLBACK_REPOSITORIES, Boolean.valueOf(useFallbackRepoProp == null ? "true" : useFallbackRepoProp)); } return get(m_pid + ServiceConstants.PROPERTY_USE_FALLBACK_REPOSITORIES); }
/** * @see MavenConfiguration#isOffline() */ public boolean isOffline() { if (!contains(m_pid + ServiceConstants.PROPERTY_OFFLINE)) { return set( m_pid + ServiceConstants.PROPERTY_OFFLINE, Boolean.valueOf(m_propertyResolver.get(m_pid + ServiceConstants.PROPERTY_OFFLINE))); } return get(m_pid + ServiceConstants.PROPERTY_OFFLINE); }
/** * @see MavenConfiguration#getCertificateCheck() */ public boolean getCertificateCheck() { if (!contains(m_pid + ServiceConstants.PROPERTY_CERTIFICATE_CHECK)) { return set( m_pid + ServiceConstants.PROPERTY_CERTIFICATE_CHECK, Boolean.valueOf(m_propertyResolver.get(m_pid + ServiceConstants.PROPERTY_CERTIFICATE_CHECK))); } return get(m_pid + ServiceConstants.PROPERTY_CERTIFICATE_CHECK); }
public Integer getTimeout() { if (!contains(m_pid + ServiceConstants.PROPERTY_TIMEOUT)) { String timeout = m_propertyResolver.get(m_pid + ServiceConstants.PROPERTY_TIMEOUT); return set(m_pid + ServiceConstants.PROPERTY_TIMEOUT, Integer.valueOf(timeout == null ? DEFAULT_TIMEOUT : timeout)); } return get(m_pid + ServiceConstants.PROPERTY_TIMEOUT); }