Added missing beans

This commit is contained in:
Marcin Grzejszczak
2019-09-05 11:46:33 +02:00
parent a2983ffa56
commit c77ae8397e
12 changed files with 255 additions and 62 deletions

View File

@@ -22,7 +22,7 @@ import java.util.List;
/**
* Parses the bom and returns all parsed versions.
*/
interface BomParser {
public interface BomParser {
/**
* @param clonedBom - location of the cloned BOM repository

View File

@@ -16,9 +16,7 @@
package org.springframework.cloud.release.internal.buildsystem;
import java.io.File;
import java.util.Collections;
import java.util.Set;
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParser;
import org.springframework.cloud.release.internal.ReleaserProperties;
@@ -30,15 +28,4 @@ public class MavenBomParserAccessor {
Collections.singletonList(new SpringCloudMavenBomParser()));
}
public static BomParser testCloudBomParser(ReleaserProperties properties) {
return new MavenBomParser(properties,
Collections.singletonList(new SpringCloudMavenBomParser() {
@Override
public boolean isApplicable(File root, ReleaserProperties properties,
Set<Project> projects) {
return true;
}
}));
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.release.internal;
package org.springframework.cloud.release;
import java.io.File;
import java.io.IOException;

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2013-2019 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 org.springframework.cloud.release.cloud.buildsystem;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
class SpringCloudBuildsystemConfiguration {
@Bean
SpringCloudMavenBomParser springCloudMavenBomParser() {
return new SpringCloudMavenBomParser();
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2013-2019 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
*
* https://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 org.springframework.cloud.release.cloud.docs;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
class SpringCloudDocsConfiguration {
@Bean
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(
ProjectGitHandler handler) {
return new SpringCloudCustomProjectDocumentationUpdater(handler);
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2013-2019 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
*
* https://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 org.springframework.cloud.release.internal.buildsystem;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
class BuildsystemConfiguration {
@Autowired
ReleaserProperties releaserProperties;
@Autowired(required = false)
List<CustomBomParser> customBomParsers = new ArrayList<>();
@Bean
BomParser mavenBomParser() {
return new MavenBomParser(this.releaserProperties, this.customBomParsers);
}
@Bean
BomParser gradleBomParser() {
return new MavenBomParser(this.releaserProperties, this.customBomParsers);
}
@Bean
ProjectPomUpdater pomUpdater(List<BomParser> bomParsers) {
return new ProjectPomUpdater(this.releaserProperties, bomParsers);
}
}

View File

@@ -16,13 +16,18 @@
package org.springframework.cloud.release.internal.spring;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.release.internal.Releaser;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater;
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
import org.springframework.cloud.release.internal.docs.ProjectDocumentationUpdater;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
import org.springframework.cloud.release.internal.options.Parser;
@@ -61,11 +66,6 @@ class ReleaserConfiguration {
return new ProjectCommandExecutor(this.properties);
}
@Bean
ProjectPomUpdater pomUpdater() {
return new ProjectPomUpdater(this.properties, bomParsers);
}
@Bean
VersionsFetcher versionsFetcher(ProjectPomUpdater updater) {
return new VersionsFetcher(this.properties, updater);
@@ -106,10 +106,22 @@ class ReleaserConfiguration {
projectCommandExecutor, releaserProperties, versionsFetcher);
}
@Autowired(required = false)
List<CustomProjectDocumentationUpdater> customProjectDocumentationUpdaters = new ArrayList<>();
@Bean
ProjectDocumentationUpdater projectDocumentationUpdater(
ProjectGitHandler projectGitHandler) {
return new ProjectDocumentationUpdater(this.properties, projectGitHandler,
this.customProjectDocumentationUpdaters);
}
@Bean
DocumentationUpdater documentationUpdater(ProjectGitHandler projectGitHandler,
ReleaserProperties properties, TemplateGenerator templateGenerator) {
return new DocumentationUpdater(projectGitHandler, properties, templateGenerator);
ReleaserProperties properties, TemplateGenerator templateGenerator,
ProjectDocumentationUpdater projectDocumentationUpdater) {
return new DocumentationUpdater(projectGitHandler, properties, templateGenerator,
projectDocumentationUpdater);
}
@Bean

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2013-2019 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
*
* https://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 org.springframework.cloud.release.cloud.docs;
import java.io.File;
import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
public class SpringCloudDocsAccessor {
public static CustomProjectDocumentationUpdater updater(ProjectGitHandler handler) {
return new SpringCloudCustomProjectDocumentationUpdater(handler);
}
public static CustomProjectDocumentationUpdater testUpdater(ProjectGitHandler handler,
String version) {
return new TestCustomProjectDocumentationUpdater(handler, version);
}
}
class TestCustomProjectDocumentationUpdater
extends SpringCloudCustomProjectDocumentationUpdater {
private final String version;
public TestCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler,
String version) {
super(gitHandler);
this.version = version;
}
@Override
String readIndexHtmlContents(File indexHtml) {
return response();
}
private String response() {
return "<!DOCTYPE HTML>\n" + "\n" + "<meta charset=\"UTF-8\">\n"
+ "<meta http-equiv=\"refresh\" content=\"1; url=https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/\">\n" + "\n" + "<script>\n"
+ " window.location.href = \"https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/\"\n" + "</script>\n" + "\n"
+ "<title>Page Redirection</title>\n" + "\n"
+ "<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->\n"
+ "If you are not redirected automatically, follow the <a href='https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/'>link to latest release</a>\n";
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2013-2019 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
*
* https://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 org.springframework.cloud.release.internal.buildsystem;
import java.util.Collections;
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParser;
import org.springframework.cloud.release.internal.ReleaserProperties;
public class MavenBomParserAccessor {
public static BomParser cloudMavenBomParser(ReleaserProperties properties) {
return new MavenBomParser(properties,
Collections.singletonList(new SpringCloudMavenBomParser()));
}
}

View File

@@ -18,6 +18,8 @@ package org.springframework.cloud.release.internal.docs;
import java.io.File;
import edu.emory.mathcs.backport.java.util.Collections;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
import org.springframework.cloud.release.internal.project.Projects;
@@ -29,9 +31,10 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator;
public class TestDocumentationUpdater extends DocumentationUpdater {
public TestDocumentationUpdater(ReleaserProperties properties,
TestCustomProjectDocumentationUpdater updater,
CustomProjectDocumentationUpdater updater, ProjectGitHandler handler,
TestReleaseContentsUpdater testRelease) {
super(properties, updater, testRelease);
super(properties, new ProjectDocumentationUpdater(properties, handler,
Collections.singletonList(updater)), testRelease);
}
public static class TestReleaseContentsUpdater extends ReleaseTrainContentsUpdater {
@@ -48,34 +51,4 @@ public class TestDocumentationUpdater extends DocumentationUpdater {
}
public static class TestCustomProjectDocumentationUpdater
extends CustomProjectDocumentationUpdater {
private final String version;
public TestCustomProjectDocumentationUpdater(ReleaserProperties properties,
ProjectGitHandler gitHandler, String version) {
super(properties, gitHandler);
this.version = version;
}
@Override
String readIndexHtmlContents(File indexHtml) {
return response();
}
private String response() {
return "<!DOCTYPE HTML>\n" + "\n" + "<meta charset=\"UTF-8\">\n"
+ "<meta http-equiv=\"refresh\" content=\"1; url=https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/\">\n" + "\n" + "<script>\n"
+ " window.location.href = \"https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/\"\n" + "</script>\n" + "\n"
+ "<title>Page Redirection</title>\n" + "\n"
+ "<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->\n"
+ "If you are not redirected automatically, follow the <a href='https://cloud.spring.io/spring-cloud-static/"
+ this.version + "/'>link to latest release</a>\n";
}
}
}

View File

@@ -45,9 +45,12 @@ import org.mockito.BDDMockito;
import org.mockito.Mockito;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.cloud.release.cloud.docs.SpringCloudDocsAccessor;
import org.springframework.cloud.release.internal.Releaser;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.buildsystem.BomParser;
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
import org.springframework.cloud.release.internal.buildsystem.MavenBomParserAccessor;
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
import org.springframework.cloud.release.internal.buildsystem.ProjectVersion;
import org.springframework.cloud.release.internal.buildsystem.TestPomReader;
@@ -697,7 +700,8 @@ public class AcceptanceTests {
private Releaser defaultReleaser(String expectedVersion, String projectName,
ReleaserProperties properties) {
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties, bomParsers);
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties,
bomParsers(properties));
ProjectCommandExecutor projectCommandExecutor = new ProjectCommandExecutor(
properties);
ProjectGitHandler gitHandler = new ProjectGitHandler(properties);
@@ -710,10 +714,9 @@ public class AcceptanceTests {
this.releaserProperties);
DocumentationUpdater documentationUpdater = new TestDocumentationUpdater(
properties,
new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater(
properties, gitHandler, "Brixton.SR1"),
new TestDocumentationUpdater.TestReleaseContentsUpdater(properties,
gitHandler, templateGenerator)) {
SpringCloudDocsAccessor.testUpdater(gitHandler, "Brixton.SR1"),
gitHandler, new TestDocumentationUpdater.TestReleaseContentsUpdater(
properties, gitHandler, templateGenerator)) {
@Override
public File updateDocsRepo(ProjectVersion currentProject,
String bomReleaseBranch) {
@@ -731,7 +734,8 @@ public class AcceptanceTests {
}
private Releaser defaultMetaReleaser(ReleaserProperties properties) {
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties, bomParsers);
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties,
bomParsers(properties));
ProjectCommandExecutor projectCommandExecutor = new ProjectCommandExecutor(
properties);
NonAssertingTestProjectGitHubHandler handler = new NonAssertingTestProjectGitHubHandler(
@@ -745,8 +749,9 @@ public class AcceptanceTests {
.spy(new SaganUpdater(this.saganClient, this.releaserProperties));
DocumentationUpdater documentationUpdater = Mockito
.spy(new TestDocumentationUpdater(properties,
new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater(
properties, nonAssertingGitHandler, "Brixton.SR1"),
SpringCloudDocsAccessor.testUpdater(nonAssertingGitHandler,
"Brixton.SR1"),
nonAssertingGitHandler,
new TestDocumentationUpdater.TestReleaseContentsUpdater(
properties, nonAssertingGitHandler, templateGenerator) {
@Override
@@ -777,6 +782,11 @@ public class AcceptanceTests {
return releaser;
}
private List<BomParser> bomParsers(ReleaserProperties properties) {
return Collections
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties));
}
private ReleaserProperties releaserProperties(File project, String branch)
throws URISyntaxException {
ReleaserProperties releaserProperties = new ReleaserProperties();

View File

@@ -63,6 +63,8 @@ public class ReleaserApplicationEventTests {
@Configuration
@EnableAutoConfiguration
@ComponentScan({ "org.springframework.cloud.release.internal.options",
"org.springframework.cloud.release.cloud",
"org.springframework.cloud.release.internal.buildsystem",
"org.springframework.cloud.release.internal.sagan",
"org.springframework.cloud.release.internal.spring" })
static class Config {