public void addRepo(String id, String url, boolean snapshot) { synchronized (repos) { delRepo(id); RemoteRepository rr = new RemoteRepository(id, "default", url); rr.setPolicy(snapshot, new RepositoryPolicy( true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)); repos.add(rr); } }
public void addRepo(String id, String url, boolean snapshot, Authentication auth, Proxy proxy) { synchronized (repos) { delRepo(id); RemoteRepository rr = new RemoteRepository(id, "default", url); rr.setPolicy(snapshot, new RepositoryPolicy( true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)); rr.setAuthentication(auth); rr.setProxy(proxy); repos.add(rr); } }
/** * Sets the enabled flag for the associated repository. * * @param enabled {@code true} if the repository should be contacted, {@code false} otherwise. * @return The new policy, never {@code null}. */ public RepositoryPolicy setEnabled( boolean enabled ) { if ( this.enabled == enabled ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the enabled flag for the associated repository. * * @param enabled {@code true} if the repository should be contacted, {@code false} otherwise. * @return The new policy, never {@code null}. */ public RepositoryPolicy setEnabled( boolean enabled ) { if ( this.enabled == enabled ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the enabled flag for the associated repository. * * @param enabled {@code true} if the repository should be contacted, {@code false} otherwise. * @return The new policy, never {@code null}. */ public RepositoryPolicy setEnabled( boolean enabled ) { if ( this.enabled == enabled ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the policy to apply for snapshot/release artifacts. * * @param snapshot {@code true} to set the snapshot policy, {@code false} to set the release policy. * @param policy The repository policy to set, may be {@code null} to use a default policy. * @return This repository for chaining, never {@code null}. */ public RemoteRepository setPolicy( boolean snapshot, RepositoryPolicy policy ) { if ( policy == null ) { policy = new RepositoryPolicy(); } if ( snapshot ) { snapshotPolicy = policy; } else { releasePolicy = policy; } return this; }
/** * Sets the policy to apply for snapshot/release artifacts. * * @param snapshot {@code true} to set the snapshot policy, {@code false} to set the release policy. * @param policy The repository policy to set, may be {@code null} to use a default policy. * @return This repository for chaining, never {@code null}. */ public RemoteRepository setPolicy( boolean snapshot, RepositoryPolicy policy ) { if ( policy == null ) { policy = new RepositoryPolicy(); } if ( snapshot ) { snapshotPolicy = policy; } else { releasePolicy = policy; } return this; }
/** * Sets the policy to apply for snapshot/release artifacts. * * @param snapshot {@code true} to set the snapshot policy, {@code false} to set the release policy. * @param policy The repository policy to set, may be {@code null} to use a default policy. * @return This repository for chaining, never {@code null}. */ public RemoteRepository setPolicy( boolean snapshot, RepositoryPolicy policy ) { if ( policy == null ) { policy = new RepositoryPolicy(); } if ( snapshot ) { snapshotPolicy = policy; } else { releasePolicy = policy; } return this; }
/** * Sets the policy for checksum validation. Well-known policies are {@link #CHECKSUM_POLICY_FAIL}, * {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_IGNORE}. * * @param checksumPolicy The checksum policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setChecksumPolicy( String checksumPolicy ) { if ( this.checksumPolicy.equals( checksumPolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the update policy for locally cached data from the repository. Well-known policies are * {@link #UPDATE_POLICY_NEVER}, {@link #UPDATE_POLICY_ALWAYS}, {@link #UPDATE_POLICY_DAILY} and * {@link #UPDATE_POLICY_INTERVAL} * * @param updatePolicy The update policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setUpdatePolicy( String updatePolicy ) { if ( this.updatePolicy.equals( updatePolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the policy for checksum validation. Well-known policies are {@link #CHECKSUM_POLICY_FAIL}, * {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_IGNORE}. * * @param checksumPolicy The checksum policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setChecksumPolicy( String checksumPolicy ) { if ( this.checksumPolicy.equals( checksumPolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the policy for checksum validation. Well-known policies are {@link #CHECKSUM_POLICY_FAIL}, * {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_IGNORE}. * * @param checksumPolicy The checksum policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setChecksumPolicy( String checksumPolicy ) { if ( this.checksumPolicy.equals( checksumPolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the update policy for locally cached data from the repository. Well-known policies are * {@link #UPDATE_POLICY_NEVER}, {@link #UPDATE_POLICY_ALWAYS}, {@link #UPDATE_POLICY_DAILY} and * {@link #UPDATE_POLICY_INTERVAL} * * @param updatePolicy The update policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setUpdatePolicy( String updatePolicy ) { if ( this.updatePolicy.equals( updatePolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
/** * Sets the update policy for locally cached data from the repository. Well-known policies are * {@link #UPDATE_POLICY_NEVER}, {@link #UPDATE_POLICY_ALWAYS}, {@link #UPDATE_POLICY_DAILY} and * {@link #UPDATE_POLICY_INTERVAL} * * @param updatePolicy The update policy, may be {@code null}. * @return The new policy, never {@code null}. */ public RepositoryPolicy setUpdatePolicy( String updatePolicy ) { if ( this.updatePolicy.equals( updatePolicy ) ) { return this; } return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); }
protected List<RemoteRepository> getRemoteRepositories() { List<RemoteRepository> repos = new ArrayList<RemoteRepository>(); for( int i = 0; i < repositories.length; i++ ) { String text = repositories[i].trim(); boolean snapshot = false; while (true) { int idx = text.lastIndexOf('@'); if (idx <= 0) { break; } String postfix = text.substring(idx + 1); if (postfix.equals("snapshots")) { snapshot = true; } else if (postfix.equals("noreleases")) { // TODO } else { LOGGER.warn("Unknown postfix: @" + postfix + " on repository URL: " + text); break; } text = text.substring(0, idx); } RemoteRepository repository = new RemoteRepository("repos" + i, "default", text); RepositoryPolicy policy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN); repository.setPolicy(snapshot, policy); repos.add(repository); } return repos; }
repo.setPolicy(true, new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN)); repo.setPolicy(false, new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN));
private static RemoteRepository makeRemoteRepository(Metadata.Repository info, Server server, boolean snapshot) { return new RemoteRepository(info.getId(), "default", info.getUri()) .setPolicy(true, new RepositoryPolicy(snapshot, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_FAIL)) .setPolicy(false, new RepositoryPolicy(!snapshot, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_FAIL)) .setAuthentication(new Authentication(server.getUsername(), server.getPassword())); }
private static RepositoryPolicy convertMavenRepositoryPolicy(org.apache.maven.settings.RepositoryPolicy repositoryPolicy) { RepositoryPolicy policy = new RepositoryPolicy(); if (repositoryPolicy != null && repositoryPolicy.getChecksumPolicy() != null) { policy.setChecksumPolicy(repositoryPolicy.getChecksumPolicy()); } policy.setEnabled(repositoryPolicy.isEnabled()); policy.setUpdatePolicy(repositoryPolicy.getUpdatePolicy()); return policy; }
private static RepositoryPolicy convertMavenRepositoryPolicy(org.apache.maven.settings.RepositoryPolicy repositoryPolicy) { RepositoryPolicy policy = new RepositoryPolicy(); if (repositoryPolicy != null && repositoryPolicy.getChecksumPolicy() != null) { policy.setChecksumPolicy(repositoryPolicy.getChecksumPolicy()); } policy.setEnabled(repositoryPolicy.isEnabled()); policy.setUpdatePolicy(repositoryPolicy.getUpdatePolicy()); return policy; }
private RepositoryPolicy merge( RepositorySystemSession session, RepositoryPolicy policy1, RepositoryPolicy policy2 ) { RepositoryPolicy policy; if ( policy1.isEnabled() && policy2.isEnabled() ) { String checksums; if ( ordinalOfChecksumPolicy( policy2.getChecksumPolicy() ) < ordinalOfChecksumPolicy( policy1.getChecksumPolicy() ) ) { checksums = policy2.getChecksumPolicy(); } else { checksums = policy1.getChecksumPolicy(); } String updates = updateCheckManager.getEffectiveUpdatePolicy( session, policy1.getUpdatePolicy(), policy2.getUpdatePolicy() ); policy = new RepositoryPolicy( true, updates, checksums ); } else if ( policy2.isEnabled() ) { policy = policy2; } else { policy = policy1; } return policy; }