diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java
index 3219acee..6fbdad5d 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java
@@ -18,18 +18,18 @@ package org.springframework.cloud.release.cloud.docs;
import java.io.File;
import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.nio.file.Files;
+import java.nio.file.Path;
-import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
import org.springframework.cloud.release.internal.project.ProjectVersion;
import org.springframework.cloud.release.internal.project.Projects;
+import org.springframework.util.FileSystemUtils;
import org.springframework.util.StringUtils;
/**
@@ -38,21 +38,17 @@ import org.springframework.util.StringUtils;
class SpringCloudCustomProjectDocumentationUpdater
implements CustomProjectDocumentationUpdater {
- private static final String HTTP_SC_STATIC_URL = "http://cloud.spring.io/spring-cloud-static/";
-
- private static final String HTTPS_SC_STATIC_URL = "https://cloud.spring.io/spring-cloud-static/";
-
- public static final String NO_PROJECT_NAME = "";
-
- private byte[] indexHtmlTemplate;
-
private static final Logger log = LoggerFactory
.getLogger(SpringCloudCustomProjectDocumentationUpdater.class);
private final ProjectGitHandler gitHandler;
- SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler) {
+ private final ReleaserProperties releaserProperties;
+
+ SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler,
+ ReleaserProperties releaserProperties) {
this.gitHandler = gitHandler;
+ this.releaserProperties = releaserProperties;
}
@Override
@@ -74,21 +70,26 @@ class SpringCloudCustomProjectDocumentationUpdater
public File updateDocsRepo(File clonedDocumentationProject,
ProjectVersion currentProject, Projects projects, String bomBranch) {
log.debug("Cloning the doc project to [{}]", clonedDocumentationProject);
- String pathToIndexHtml = "current/index.html";
- File indexHtml = indexHtmlWithRedirection(clonedDocumentationProject, "",
- bomBranch, pathToIndexHtml);
- File docsRepo = updateTheDocsRepo(NO_PROJECT_NAME, bomBranch,
- clonedDocumentationProject, indexHtml);
+ ProjectVersion releaseTrainProject = new ProjectVersion(
+ this.releaserProperties.getMetaRelease().getReleaseTrainProjectName(),
+ branchToReleaseVersion(bomBranch));
+ File currentReleaseFolder = new File(clonedDocumentationProject, currentFolder(
+ releaseTrainProject.projectName, releaseTrainProject.version));
+ // remove the old way
+ removeAFolderWithRedirection(currentReleaseFolder);
+ File docsRepo = updateTheDocsRepo(releaseTrainProject, clonedDocumentationProject,
+ currentReleaseFolder);
log.info(
"Updating all current links to documentation for release train projects");
projects.forEach(projectVersion -> {
- File index = indexHtmlWithRedirection(clonedDocumentationProject,
- projectVersion.projectName, projectVersion.version, pathToIndexHtml);
+ File currentProjectReleaseFolder = new File(clonedDocumentationProject,
+ currentFolder(projectVersion.projectName, projectVersion.version));
+ removeAFolderWithRedirection(currentProjectReleaseFolder);
try {
- updateTheDocsRepo(projectVersion.projectName, projectVersion.version,
- clonedDocumentationProject, index);
- log.info("Processed [{}] for project with name [{}]", index,
- projectVersion.projectName);
+ updateTheDocsRepo(projectVersion, clonedDocumentationProject,
+ currentProjectReleaseFolder);
+ log.info("Processed [{}] for project with name [{}]",
+ currentProjectReleaseFolder, projectVersion.projectName);
}
catch (Exception ex) {
log.warn(
@@ -100,55 +101,53 @@ class SpringCloudCustomProjectDocumentationUpdater
return pushChanges(docsRepo);
}
- private File indexHtmlWithRedirection(File clonedDocumentationProject,
- String projectName, String version, String pathToIndexHtml) {
- File indexHtml = indexHtml(clonedDocumentationProject,
- combinedPathToIndexHtml(projectName, version, pathToIndexHtml));
- if (!indexHtml.exists()) {
- return generateIndexHtml(projectName, version, pathToIndexHtml, indexHtml);
- }
- return indexHtml;
- }
-
- private File generateIndexHtml(String projectName, String projectVersion,
- String pathToIndexHtml, File indexHtml) {
- try {
- log.info("No file [{}] found, will create one", indexHtml);
- indexHtml.getParentFile().mkdirs();
- indexHtml.createNewFile();
- String newIndex = new String(indexHtmlTemplate()).replaceAll("\\{\\{URL}}",
- "https://cloud.spring.io/spring-cloud-static/"
- + concreteVersionIndexHtml(projectName,
- branchToReleaseVersion(projectVersion),
- "index.html"));
- Files.write(indexHtml.toPath(), newIndex.getBytes());
- return indexHtml;
- }
- catch (IOException ex) {
- throw new IllegalStateException(ex);
+ private void removeAFolderWithRedirection(File currentReleaseFolder) {
+ if (!isSymbolinkLink(currentReleaseFolder)) {
+ FileSystemUtils.deleteRecursively(currentReleaseFolder);
}
}
- private String combinedPathToIndexHtml(String projectName, String projectVersion,
- String pathToIndexHtml) {
+ private boolean isSymbolinkLink(File currentFolder) {
+ return Files.isSymbolicLink(currentFolder.toPath());
+ }
+
+ private String currentFolder(String projectName, String projectVersion) {
boolean releaseTrain = new ProjectVersion(projectName, projectVersion)
.isReleaseTrain();
- // release train -> static/current/index.html
- // project -> static/spring-cloud-sleuth/current/index.html
- String prefix = releaseTrain ? ""
- : (StringUtils.hasText(projectName) ? projectName : "") + "/";
- return prefix + pathToIndexHtml;
+ // release train -> static/current
+ // project -> static/spring-cloud-sleuth/current
+ return releaseTrain ? "current"
+ : (StringUtils.hasText(projectName) ? projectName : "") + "/current";
}
- private String concreteVersionIndexHtml(String projectName, String projectVersion,
- String pathToIndexHtml) {
- boolean releaseTrain = new ProjectVersion(projectName, projectVersion)
- .isReleaseTrain();
- // release train -> static/current/index.html
- // project -> static/spring-cloud-sleuth/current/index.html
- String prefix = releaseTrain ? projectVersion
- : (projectName + "/" + projectVersion);
- return prefix + "/" + pathToIndexHtml;
+ String linkToVersion(File file) {
+ if (Files.isSymbolicLink(file.toPath())) {
+ try {
+ Path path = Files.readSymbolicLink(file.toPath());
+ // current -> Hoxton.SR2
+ // spring-cloud-sleuth/current -> spring-cloud-sleuth/1.2.3.RELEASE
+ return folderName(path.toString());
+ }
+ catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ return "";
+ }
+
+ private String folderName(String path) {
+ int last = path.lastIndexOf(File.separator);
+ return last > 0 ? path.substring(last + 1) : path;
+ }
+
+ private String concreteVersionFolder(ProjectVersion projectVersion) {
+ String projectName = projectVersion.projectName;
+ boolean releaseTrain = projectVersion.isReleaseTrain();
+ // release train -> static/Hoxton.SR2/
+ // project -> static/spring-cloud-sleuth/1.2.3.RELEASE/
+ String prefix = releaseTrain ? projectVersion.version
+ : (projectName + "/" + projectVersion.version);
+ return prefix + "/";
}
private File pushChanges(File docsRepo) {
@@ -157,93 +156,56 @@ class SpringCloudCustomProjectDocumentationUpdater
return docsRepo;
}
- File indexHtml(File clonedDocumentationProject, String pathToIndexHtml) {
- return new File(clonedDocumentationProject, pathToIndexHtml);
- }
-
- private File updateTheDocsRepo(String projectName, String version,
- File documentationProject, File indexHtml) {
+ private File updateTheDocsRepo(ProjectVersion projectVersion,
+ File documentationProject, File currentVersionFolder) {
try {
- String indexHtmlText = readIndexHtmlContents(indexHtml);
- String httpSubstring = HTTP_SC_STATIC_URL
- + (StringUtils.hasText(projectName) ? (projectName + "/") : "");
- String httpsSubstring = HTTPS_SC_STATIC_URL
- + (StringUtils.hasText(projectName) ? (projectName + "/") : "");
- int httpIndex = indexHtmlText.indexOf(httpSubstring);
- int httpsIndex = indexHtmlText.indexOf(httpsSubstring);
- if (httpIndex == -1 && httpsIndex == -1) {
- throw new IllegalStateException(
- "The URL to the documentation repo not found in the index.html file");
- }
- int beginIndex = beginIndex(httpIndex, httpSubstring, httpsIndex,
- httpsSubstring);
- String storedVersionLine = indexHtmlText.substring(beginIndex);
- String storedVersion = storedVersionLine.substring(0,
- storedVersionLine.indexOf("/"));
- String currentVersion = branchToReleaseVersion(version);
- boolean newerVersion = isMoreMature(storedVersion, currentVersion);
+ String storedVersion = linkToVersion(currentVersionFolder);
+ String currentVersion = projectVersion.version;
+ boolean newerVersion = StringUtils.isEmpty(storedVersion)
+ || isMoreMature(storedVersion, currentVersion);
if (!newerVersion) {
log.info("Current version [{}] is not newer than the stored one [{}]",
currentVersion, storedVersion);
return documentationProject;
}
- return commitChanges(currentVersion, documentationProject, indexHtml,
- indexHtmlText, storedVersion);
+ boolean deleted = Files.deleteIfExists(currentVersionFolder.toPath())
+ || FileSystemUtils.deleteRecursively(currentVersionFolder.toPath());
+ if (deleted) {
+ log.info("Deleted current version folder link at [{}]",
+ currentVersionFolder);
+ }
+ currentVersionFolder.getParentFile().mkdirs();
+ File newTarget = new File(documentationProject,
+ concreteVersionFolder(projectVersion));
+ Files.createSymbolicLink(currentVersionFolder.toPath(), newTarget.toPath());
+ log.info("Updated the link [{}] to point to [{}]",
+ currentVersionFolder.toPath(),
+ Files.readSymbolicLink(currentVersionFolder.toPath()));
+ return commitChanges(currentVersion, documentationProject);
}
catch (IOException e) {
throw new IllegalStateException(e);
}
}
- boolean isMoreMature(String storedVersion, String currentVersion) {
+ private boolean isMoreMature(String storedVersion, String currentVersion) {
return new ProjectVersion("project", currentVersion)
.isMoreMature(new ProjectVersion("project", storedVersion));
}
- private int beginIndex(int httpIndex, String httpSubstring, int httpsIndex,
- String httpsSubstring) {
- if (httpIndex != -1) {
- return httpIndex + httpSubstring.length();
+ private String branchToReleaseVersion(String branch) {
+ if (branch.startsWith("v")) {
+ return branch.substring(1);
}
- return httpsIndex + httpsSubstring.length();
+ return branch;
}
- private String branchToReleaseVersion(String springCloudReleaseBranch) {
- if (springCloudReleaseBranch.startsWith("v")) {
- return springCloudReleaseBranch.substring(1);
- }
- return springCloudReleaseBranch;
- }
-
- private File commitChanges(String currentVersion, File documentationProject,
- File indexHtml, String indexHtmlText, String storedReleaseTrain)
+ private File commitChanges(String currentVersion, File documentationProject)
throws IOException {
- String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain,
- currentVersion);
- Files.write(indexHtml.toPath(), replacedIndexHtml.getBytes());
- log.info("Stored the version URL [{}] in [{}]", currentVersion,
- indexHtml.getAbsolutePath());
+ log.info("Updated the symbolic links");
this.gitHandler.commit(documentationProject,
"Updating the link to the current version to [" + currentVersion + "]");
return documentationProject;
}
- String readIndexHtmlContents(File indexHtml) throws IOException {
- return new String(Files.readAllBytes(indexHtml.toPath()));
- }
-
- private byte[] indexHtmlTemplate() {
- if (this.indexHtmlTemplate == null) {
- try {
- URI uri = CustomProjectDocumentationUpdater.class
- .getResource("/cloud/index.html").toURI();
- this.indexHtmlTemplate = IOUtils.toByteArray(uri);
- }
- catch (URISyntaxException | IOException ex) {
- throw new IllegalStateException(ex);
- }
- }
- return this.indexHtmlTemplate;
- }
-
}
diff --git a/spring-cloud-release-tools-core/src/main/resources/cloud/index.html b/spring-cloud-release-tools-core/src/main/resources/cloud/index.html
deleted file mode 100644
index 5081a0b6..00000000
--- a/spring-cloud-release-tools-core/src/main/resources/cloud/index.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
Page Redirection
-
-
-If you are not redirected automatically, follow the link to latest release
diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java
index 014aa05d..749d8ddb 100644
--- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java
+++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collections;
import javax.validation.constraints.NotNull;
@@ -80,56 +81,6 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
SpringCloudGithubIssuesAccessor.springCloud(this.properties)));
}
- @Test
- public void should_generate_a_new_index_html_when_original_one_is_not_found()
- throws URISyntaxException, IOException {
- ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release",
- "Hoxton.SR10");
- ReleaserProperties properties = new ReleaserProperties();
- properties.getGit().setDocumentationBranch("master");
- properties.getGit().setDocumentationUrl(
- file("/projects/spring-cloud-release/").toURI().toString());
-
- File updatedDocs = projectDocumentationUpdaterWithNoIndexHtml(properties)
- .updateDocsRepo(projects(), releaseTrainVersion, "vHoxton.SR10");
-
- String indexHtmlContent = new String(
- Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
- then(indexHtmlContent)
- .contains("cloud.spring.io/spring-cloud-static/Hoxton.SR10/");
- String sleuthIndexHtmlContent = new String(Files.readAllBytes(
- new File(updatedDocs, "spring-cloud-sleuth/current/index.html")
- .toPath()));
- then(sleuthIndexHtmlContent).contains(
- "cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/1.0.0.RELEASE/");
- }
-
- @Test
- public void should_throw_exception_if_index_found_but_doc_repo_url_missing()
- throws URISyntaxException {
- ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth",
- "1.3.4.SR10");
- ReleaserProperties properties = new ReleaserProperties();
- properties.getGit().setDocumentationUrl(
- file("/projects/spring-cloud-static/").toURI().toString());
-
- SpringCloudCustomProjectDocumentationUpdater customUpdater = new SpringCloudCustomProjectDocumentationUpdater(
- new ProjectGitHandler(properties)) {
- @Override
- String readIndexHtmlContents(File indexHtml) {
- return "";
- }
- };
-
- BDDAssertions
- .thenThrownBy(() -> new DocumentationUpdater(this.handler, properties,
- templateGenerator(properties),
- Collections.singletonList(customUpdater)).updateDocsRepo(
- projects(), releaseTrainVersion, "vAngel.SR33"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("The URL to the documentation repo not found");
- }
-
@Test
public void should_not_update_current_version_in_the_docs_if_current_release_is_not_ga_or_sr() {
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth",
@@ -146,30 +97,10 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
private DocumentationUpdater projectDocumentationUpdater(
ReleaserProperties properties) {
return new DocumentationUpdater(this.handler, properties,
- templateGenerator(properties), Collections.singletonList(
- new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
- @Override
- boolean isMoreMature(String first, String second) {
- return true;
- }
- }));
- }
-
- @NotNull
- private DocumentationUpdater projectDocumentationUpdaterWithNoIndexHtml(
- ReleaserProperties properties) {
- return new DocumentationUpdater(this.handler, properties,
- templateGenerator(properties), Collections.singletonList(
- new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
- @Override
- File indexHtml(File clonedDocumentationProject,
- String pathToIndexHtml) {
- File file = super.indexHtml(clonedDocumentationProject,
- pathToIndexHtml);
- file.delete();
- return file;
- }
- }));
+ templateGenerator(properties),
+ Collections.singletonList(
+ new SpringCloudCustomProjectDocumentationUpdater(this.handler,
+ properties)));
}
@NotNull
@@ -177,11 +108,6 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
return new TemplateGenerator(properties, this.gitHubHandler);
}
- @NotNull
- private ProjectGitHandler projectGitHandler(ReleaserProperties properties) {
- return new ProjectGitHandler(properties);
- }
-
@Test
public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_v_and_then_lower_letter_than_the_stored_release()
throws URISyntaxException, IOException {
@@ -192,13 +118,16 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
file("/projects/spring-cloud-static/").toURI().toString());
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
- new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
- releaseTrainVersion, projects(), "vAngel.SR33");
+ new ProjectGitHandler(properties), properties).updateDocsRepo(
+ this.clonedDocProject, releaseTrainVersion, projects(),
+ "vAngel.SR33");
- String indexHtmlContent = new String(
- Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
- then(indexHtmlContent).doesNotContain(
- "https://cloud.spring.io/spring-cloud-static/Angel.SR33/");
+ BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
+ .doesNotExist();
+ Path current = new File(updatedDocs, "current/").toPath();
+ BDDAssertions.then(current).isSymbolicLink();
+ BDDAssertions.then(Files.readSymbolicLink(current).toString())
+ .doesNotEndWith("Angel.SR33");
}
@Test
@@ -209,8 +138,9 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
- new SpringCloudCustomProjectDocumentationUpdater(handler).updateDocsRepo(
- this.clonedDocProject, releaseTrainVersion, projects(), "vDalston.SR3");
+ new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
+ .updateDocsRepo(this.clonedDocProject, releaseTrainVersion, projects(),
+ "vDalston.SR3");
BDDMockito.then(handler).should(BDDMockito.never())
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
@@ -225,13 +155,16 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
- new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
- releaseTrainVersion, projects(), "Angel.SR33");
+ new ProjectGitHandler(properties), properties).updateDocsRepo(
+ this.clonedDocProject, releaseTrainVersion, projects(),
+ "Angel.SR33");
- String indexHtmlContent = new String(
- Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
- then(indexHtmlContent).doesNotContain(
- "https://cloud.spring.io/spring-cloud-static/Angel.SR33/");
+ BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
+ .doesNotExist();
+ Path current = new File(updatedDocs, "current/").toPath();
+ BDDAssertions.then(current).isSymbolicLink();
+ BDDAssertions.then(Files.readSymbolicLink(current).toString())
+ .doesNotEndWith("Angel.SR33");
}
@Test
@@ -245,27 +178,40 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
File updatedDocs = projectDocumentationUpdater(properties)
.updateDocsRepo(projects(), releaseTrainVersion, "vFinchley.SR33");
- String indexHtmlContent = new String(
- Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
- then(indexHtmlContent)
- .contains("cloud.spring.io/spring-cloud-static/Finchley.SR33/");
+ BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
+ .doesNotExist();
+ Path current = new File(updatedDocs, "current/").toPath();
+ BDDAssertions.then(current).isSymbolicLink();
+ BDDAssertions.then(Files.readSymbolicLink(current).toString())
+ .endsWith("spring-cloud-static/Finchley.SR33");
}
@Test
public void should_update_current_version_in_the_docs_if_current_release_starts_with_higher_letter_than_the_stored_release()
throws IOException {
- ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth",
- "2.0.0.SR33");
+ ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release",
+ "Finchley.SR33");
ReleaserProperties properties = new ReleaserProperties();
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
- File updatedDocs = projectDocumentationUpdater(properties)
- .updateDocsRepo(projects(), releaseTrainVersion, "Finchley.SR33");
+ File updatedDocs = projectDocumentationUpdater(properties).updateDocsRepo(
+ new Projects(new ProjectVersion("spring-cloud-sleuth", "2.0.0.RELEASE")),
+ releaseTrainVersion, "vFinchley.SR33");
- String indexHtmlContent = new String(
- Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
- then(indexHtmlContent)
- .contains("cloud.spring.io/spring-cloud-static/Finchley.SR33/");
+ BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
+ .doesNotExist();
+ Path current = new File(updatedDocs, "current/").toPath();
+ BDDAssertions.then(current).isSymbolicLink();
+ BDDAssertions.then(Files.readSymbolicLink(current).toString())
+ .endsWith("spring-cloud-static/Finchley.SR33");
+
+ BDDAssertions.then(
+ new File(updatedDocs, "spring-cloud-sleuth/current/index.html").toPath())
+ .doesNotExist();
+ current = new File(updatedDocs, "spring-cloud-sleuth/current/").toPath();
+ BDDAssertions.then(current).isSymbolicLink();
+ BDDAssertions.then(Files.readSymbolicLink(current).toString())
+ .endsWith("spring-cloud-static/spring-cloud-sleuth/2.0.0.RELEASE");
}
@Test
diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsConfiguration.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsConfiguration.java
index 2020b870..3ccf7db8 100644
--- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsConfiguration.java
+++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsConfiguration.java
@@ -26,7 +26,7 @@ class SpringCloudDocsConfiguration {
@Bean
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(
ProjectGitHandler handler) {
- return new SpringCloudCustomProjectDocumentationUpdater(handler);
+ return new SpringCloudCustomProjectDocumentationUpdater(handler, releaserProperties);
}
}
diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsAccessor.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsAccessor.java
index 082e0fa3..b23cef7f 100644
--- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsAccessor.java
+++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudDocsAccessor.java
@@ -16,49 +16,20 @@
package org.springframework.cloud.release.cloud.docs;
-import java.io.File;
-
+import org.springframework.cloud.release.internal.ReleaserProperties;
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 updater(ProjectGitHandler handler, ReleaserProperties releaserProperties) {
+ return new SpringCloudCustomProjectDocumentationUpdater(handler, releaserProperties);
}
public static CustomProjectDocumentationUpdater testUpdater(ProjectGitHandler handler,
String version) {
- return new TestCustomProjectDocumentationUpdater(handler, version);
+ ReleaserProperties releaserProperties = new ReleaserProperties();
+ return new SpringCloudCustomProjectDocumentationUpdater(handler, releaserProperties);
}
-}
-
-class TestCustomProjectDocumentationUpdater
- extends SpringCloudCustomProjectDocumentationUpdater {
-
- private final String version;
-
- TestCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler, String version) {
- super(gitHandler);
- this.version = version;
- }
-
- @Override
- String readIndexHtmlContents(File indexHtml) {
- return response();
- }
-
- private String response() {
- return "\n" + "\n" + "\n"
- + "\n" + "\n" + "\n" + "\n"
- + "Page Redirection\n" + "\n"
- + "\n"
- + "If you are not redirected automatically, follow the link to latest release\n";
- }
-
-}
+}
\ No newline at end of file