io.spring.initializr.metadata.InitializrProperties Java Examples

The following examples show how to use io.spring.initializr.metadata.InitializrProperties. 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: VersionsFetcher.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
private ProjectVersion latestBomVersion() {
	String latestVersionsUrl = this.properties.getVersions().getAllVersionsFileUrl();
	InitializrProperties initializrProperties = this.toPropertiesConverter
			.toProperties(latestVersionsUrl);
	if (initializrProperties == null) {
		return null;
	}
	ProjectVersion springCloudVersion = initializrProperties.getEnv().getBoms()
			.getOrDefault(
					this.properties.getVersions().getBomName(), new BillOfMaterials())
			.getMappings().stream()
			.map(mapping -> new ProjectVersion(
					this.properties.getVersions().getBomName(), mapping.getVersion()))
			.filter(ProjectVersion::isReleaseOrServiceRelease)
			.max(ProjectVersion::compareTo).orElse(new ProjectVersion(
					this.properties.getVersions().getBomName(), ""));
	log.info("Latest BOM version is [{}]", springCloudVersion.version);
	return springCloudVersion;
}
 
Example #2
Source File: VersionsFetcher.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
InitializrProperties toProperties(String url) {
	return CACHE.computeIfAbsent(url, s -> {
		String retrievedFile = this.rawGithubRetriever.raw(s);
		if (StringUtils.isEmpty(retrievedFile)) {
			return null;
		}
		YamlPropertiesFactoryBean yamlProcessor = new YamlPropertiesFactoryBean();
		yamlProcessor.setResources(new InputStreamResource(new ByteArrayInputStream(
				retrievedFile.getBytes(StandardCharsets.UTF_8))));
		Properties properties = yamlProcessor.getObject();
		return new Binder(
				new MapConfigurationPropertySource(properties.entrySet().stream()
						.collect(Collectors.toMap(e -> e.getKey().toString(),
								e -> e.getValue().toString()))))
										.bind("initializr",
												InitializrProperties.class)
										.get();
	});
}
 
Example #3
Source File: InitializrConfig.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Bean
public InitializrMetadataProvider initializrMetadataProvider(
        InitializrProperties properties) {
    InitializrMetadata metadata = InitializrMetadataBuilder
            .fromInitializrProperties(properties).build();
    return new SimpleInitializrMetadataProvider(metadata);
}
 
Example #4
Source File: InitializrAutoConfiguration.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(InitializrMetadataProvider.class)
public InitializrMetadataProvider initializrMetadataProvider(InitializrProperties properties,
		ObjectProvider<InitializrMetadataUpdateStrategy> initializrMetadataUpdateStrategy) {
	InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(properties).build();
	return new DefaultInitializrMetadataProvider(metadata,
			initializrMetadataUpdateStrategy.getIfAvailable(() -> (current) -> current));
}
 
Example #5
Source File: VersionsFetcher.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
/**
 * Checks if the given project version is the latest GA available.
 * @param version version to check
 * @return {@code true} if this version is the latest GA
 */
public boolean isLatestGa(ProjectVersion version) {
	if (!version.isReleaseOrServiceRelease()) {
		if (log.isDebugEnabled()) {
			log.debug("Version [" + version.toString()
					+ "] is non GA, will not fetch any versions.");
		}
		return false;
	}
	if (!this.properties.getGit().isUpdateSpringGuides()) {
		log.info("Will not file an issue to Spring Guides, since the switch to do so "
				+ "is off. Set [releaser.git.update-spring-guides] to [true] to change that");
		return false;
	}
	String latestVersionsUrl = this.properties.getVersions().getAllVersionsFileUrl();
	InitializrProperties initializrProperties = this.toPropertiesConverter
			.toProperties(latestVersionsUrl);
	if (initializrProperties == null) {
		return false;
	}
	ProjectVersion bomVersion = latestBomVersion();
	if (bomVersion == null) {
		log.info("No BOM mapping with name [{}] found",
				this.properties.getVersions().getBomName());
		return false;
	}
	Projects projectVersions = null;
	try {
		projectVersions = this.projectPomUpdater.retrieveVersionsFromReleaseTrainBom(
				"v" + bomVersion.toString(), false);
	}
	catch (Exception ex) {
		log.error(
				"Failed to check the project versions. Will return that the project is not GA",
				ex);
		return false;
	}
	boolean containsProject = projectVersions.containsProject(version.projectName);
	if (containsProject) {
		return bomVersion.compareTo(projectVersions.forName(version.projectName)) > 0;
	}
	log.info("The project [" + version.projectName
			+ "] is not present in the BOM with projects [" + projectVersions.stream()
					.map(v -> v.projectName).collect(Collectors.joining(", "))
			+ "]");
	return false;
}