Upgrade to Spring Cloud Finchley.M3

Closes gh-535
This commit is contained in:
Stephane Nicoll
2017-10-31 17:06:01 +01:00
parent 8c5b9928e8
commit b64fe75a72
3 changed files with 1 additions and 126 deletions

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.service.extension;
import io.spring.initializr.generator.ProjectRequest;
import io.spring.initializr.generator.ProjectRequestPostProcessor;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.util.Version;
import org.springframework.stereotype.Component;
/**
* Temporary adapter for Spring Cloud to use a compatible Spring Boot version.
*
* @author Stephane Nicoll
*/
@Component
class SpringCloudCompatibilityRequestPostProcessor
implements ProjectRequestPostProcessor {
private static final Version VERSION_2_0_0_M4 = Version.parse("2.0.0.M4");
@Override
public void postProcessAfterResolution(ProjectRequest request, InitializrMetadata metadata) {
Version requestVersion = Version.safeParse(request.getBootVersion());
if (isIncompatibleMilestone(requestVersion) && hasSpringCloud(request)) {
request.setBootVersion("2.0.0.M3");
}
}
private boolean isIncompatibleMilestone(Version requestVersion) {
return VERSION_2_0_0_M4.compareTo(requestVersion) <= 0
&& "M".equals(requestVersion.getQualifier().getQualifier());
}
private boolean hasSpringCloud(ProjectRequest request) {
return request.getResolvedDependencies().stream()
.anyMatch(d -> d.getId().startsWith("cloud-"));
}
}

View File

@@ -47,7 +47,7 @@ initializr:
version: Edgware.RC1
repositories: spring-milestones
- versionRange: "[2.0.0.M2, 2.0.0.BUILD-SNAPSHOT)"
version: Finchley.M2
version: Finchley.M3
repositories: spring-milestones
- versionRange: "2.0.0.BUILD-SNAPSHOT"
version: Finchley.BUILD-SNAPSHOT

View File

@@ -1,70 +0,0 @@
/*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.service.extension;
import io.spring.initializr.generator.ProjectRequest;
import org.junit.Test;
/**
* Tests for {@link SpringCloudCompatibilityRequestPostProcessor}.
*
* @author Stephane Nicoll
*/
public class SpringCloudCompatibilityRequestPostProcessorTests
extends AbstractRequestPostProcessorTests {
@Test
public void springBoot2MilestoneDowngradedWithSpringCloud() {
ProjectRequest request = createProjectRequest("cloud-config-server");
request.setBootVersion("2.0.0.M7");
generateMavenPom(request)
.hasSpringBootParent("2.0.0.M3");
}
@Test
public void springBoot2SnapshotWithSpringCloudUsesLatest() {
ProjectRequest request = createProjectRequest("cloud-config-server");
request.setBootVersion("2.0.0.BUILD-SNAPSHOT");
generateMavenPom(request)
.hasSpringBootParent("2.0.0.BUILD-SNAPSHOT");
}
@Test
public void springBoot2MilestoneNotDowngradedWithoutSpringCloud() {
ProjectRequest request = createProjectRequest("web");
request.setBootVersion("2.0.0.M7");
generateMavenPom(request)
.hasSpringBootParent("2.0.0.M7");
}
@Test
public void onlySpringBoot2MilestoneHandled() {
ProjectRequest request = createProjectRequest("cloud-config-server");
request.setBootVersion("2.0.0.RC1");
generateMavenPom(request)
.hasSpringBootParent("2.0.0.RC1");
}
@Test
public void onlySpringBoot2Handled() {
ProjectRequest request = createProjectRequest("cloud-config-server");
request.setBootVersion("1.5.7.RELEASE");
generateMavenPom(request)
.hasSpringBootParent("1.5.7.RELEASE");
}
}