org.apache.maven.model.RepositoryPolicy Java Examples

The following examples show how to use org.apache.maven.model.RepositoryPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void writeRepositoryPolicy(RepositoryPolicy repositoryPolicy, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (repositoryPolicy.getEnabled() != null) {
        writeValue(serializer, "enabled", repositoryPolicy.getEnabled(), repositoryPolicy);
    }
    if (repositoryPolicy.getUpdatePolicy() != null) {
        writeValue(serializer, "updatePolicy", repositoryPolicy.getUpdatePolicy(), repositoryPolicy);
    }
    if (repositoryPolicy.getChecksumPolicy() != null) {
        writeValue(serializer, "checksumPolicy", repositoryPolicy.getChecksumPolicy(), repositoryPolicy);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(repositoryPolicy, "", start, b.length());
}
 
Example #2
Source File: FlattenMojo.java    From flatten-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This method determines if the given {@link Repository} section is identical to what is defined from the super
 * POM.
 *
 * @param repo is the {@link Repository} section to check.
 * @return <code>true</code> if maven central default configuration, <code>false</code> otherwise.
 */
private static boolean isCentralRepositoryFromSuperPom( Repository repo )
{
    if ( repo != null )
    {
        if ( "central".equals( repo.getId() ) )
        {
            RepositoryPolicy snapshots = repo.getSnapshots();
            if ( snapshots != null && !snapshots.isEnabled() )
            {
                return true;
            }
        }
    }
    return false;
}
 
Example #3
Source File: YamlFileRepositoryLoader.java    From yaks with Apache License 2.0 5 votes vote down vote up
/**
 * Construct repository policy from given key-value model.
 * @param policyModel
 * @return
 */
private RepositoryPolicy getRepositoryPolicy(Map<String, Object> policyModel) {
    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled(Objects.toString(policyModel.getOrDefault("enabled", "true")));
    policy.setUpdatePolicy(Objects.toString(policyModel.getOrDefault("updatePolicy", "always")));
    return policy;
}
 
Example #4
Source File: JsonFileRepositoryLoader.java    From yaks with Apache License 2.0 5 votes vote down vote up
/**
 * Construct repository policy from given key-value model.
 * @param policyModel
 * @return
 */
private RepositoryPolicy getRepositoryPolicy(ObjectNode policyModel) {
    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled(Optional.ofNullable(policyModel.get("enabled")).map(Object::toString).orElse("true"));
    policy.setUpdatePolicy(Optional.ofNullable(policyModel.get("updatePolicy")).map(Objects::toString).orElse("always"));
    return policy;
}
 
Example #5
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void writeDeploymentRepository(DeploymentRepository deploymentRepository, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (deploymentRepository.isUniqueVersion() != true) {
        writeValue(serializer, "uniqueVersion", String.valueOf(deploymentRepository.isUniqueVersion()), deploymentRepository);
    }
    if (deploymentRepository.getReleases() != null) {
        writeRepositoryPolicy((RepositoryPolicy) deploymentRepository.getReleases(), "releases", serializer);
    }
    if (deploymentRepository.getSnapshots() != null) {
        writeRepositoryPolicy((RepositoryPolicy) deploymentRepository.getSnapshots(), "snapshots", serializer);
    }
    if (deploymentRepository.getId() != null) {
        writeValue(serializer, "id", deploymentRepository.getId(), deploymentRepository);
    }
    if (deploymentRepository.getName() != null) {
        writeValue(serializer, "name", deploymentRepository.getName(), deploymentRepository);
    }
    if (deploymentRepository.getUrl() != null) {
        writeValue(serializer, "url", deploymentRepository.getUrl(), deploymentRepository);
    }
    if ((deploymentRepository.getLayout() != null) && !deploymentRepository.getLayout().equals("default")) {
        writeValue(serializer, "layout", deploymentRepository.getLayout(), deploymentRepository);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(deploymentRepository, "", start, b.length());
}
 
Example #6
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void writeRepository(Repository repository, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (repository.getReleases() != null) {
        writeRepositoryPolicy((RepositoryPolicy) repository.getReleases(), "releases", serializer);
    }
    if (repository.getSnapshots() != null) {
        writeRepositoryPolicy((RepositoryPolicy) repository.getSnapshots(), "snapshots", serializer);
    }
    if (repository.getId() != null) {
        writeValue(serializer, "id", repository.getId(), repository);
    }
    if (repository.getName() != null) {
        writeValue(serializer, "name", repository.getName(), repository);
    }
    if (repository.getUrl() != null) {
        writeValue(serializer, "url", repository.getUrl(), repository);
    }
    if ((repository.getLayout() != null) && !repository.getLayout().equals("default")) {
        writeValue(serializer, "layout", repository.getLayout(), repository);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(repository, "", start, b.length());
}
 
Example #7
Source File: AbstractWSO2ProjectCreationWizard.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
protected Repository getGlobalRepositoryFromPreference() {

		String repoURL =
		                 preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
		                                              GLOBAL_REPOSITORY_URL, null, null);
		if (repoURL != null) {
			Repository repo = new Repository();
			repo.setUrl(repoURL);
			repo.setId(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                        GLOBAL_REPOSITORY_ID, null, null));
			RepositoryPolicy releasePolicy = new RepositoryPolicy();
			String releaseEnabled =
			                        preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                     RELEASES_ENABLED, null, null);
			releasePolicy.setEnabled(releaseEnabled != null);
			releasePolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                           RELEASES_UPDATE_POLICY, null, null));
			releasePolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                             RELEASES_CHECKSUM_POLICY, null, null));
			repo.setReleases(releasePolicy);

			RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
			String snapshotsEnabled =
			                          preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                       SNAPSHOTS_ENABLED, null, null);
			snapshotPolicy.setEnabled(snapshotsEnabled != null);
			snapshotPolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                            SNAPSHOTS_UPDATE_POLICY, null, null));
			snapshotPolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
			                                                              SNAPSHOTS_CHECKSUM_POLICY, null, null));
			repo.setSnapshots(snapshotPolicy);

			return repo;
		}
		return null;
	}