Attach documentation for Spring Data Commons for Spring Data project.
Closes #167
This commit is contained in:
@@ -29,7 +29,7 @@ public class DocumentationMetadata {
|
|||||||
|
|
||||||
private static String DOCS_BASE = "https://docs.spring.io/spring-data/%s/docs/%s";
|
private static String DOCS_BASE = "https://docs.spring.io/spring-data/%s/docs/%s";
|
||||||
private static String DOCS = DOCS_BASE.concat("/reference/html/");
|
private static String DOCS = DOCS_BASE.concat("/reference/html/");
|
||||||
private static String JAVADOC = DOCS_BASE.concat("/api");
|
private static String JAVADOC = DOCS_BASE.concat("/api/");
|
||||||
|
|
||||||
Project project;
|
Project project;
|
||||||
ArtifactVersion version;
|
ArtifactVersion version;
|
||||||
@@ -41,9 +41,15 @@ public class DocumentationMetadata {
|
|||||||
*/
|
*/
|
||||||
public String getApiDocUrl(Train train) {
|
public String getApiDocUrl(Train train) {
|
||||||
|
|
||||||
return version.isSnapshotVersion() || Projects.BUILD.equals(project) //
|
if (version.isSnapshotVersion()) {
|
||||||
? "" //
|
return "";
|
||||||
: String.format(JAVADOC, project.getName().toLowerCase(Locale.US), getVersion(train));
|
}
|
||||||
|
|
||||||
|
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
|
||||||
|
return String.format(JAVADOC, Projects.COMMONS.getName().toLowerCase(Locale.US), version.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format(JAVADOC, project.getName().toLowerCase(Locale.US), getVersion(train));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,9 +59,15 @@ public class DocumentationMetadata {
|
|||||||
*/
|
*/
|
||||||
public String getReferenceDocUrl(Train train) {
|
public String getReferenceDocUrl(Train train) {
|
||||||
|
|
||||||
return version.isSnapshotVersion() || Projects.BUILD.equals(project) //
|
if (version.isSnapshotVersion()) {
|
||||||
? "" //
|
return "";
|
||||||
: String.format(DOCS, project.getName().toLowerCase(Locale.US), getVersion(train));
|
}
|
||||||
|
|
||||||
|
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
|
||||||
|
return String.format(DOCS, Projects.COMMONS.getName().toLowerCase(Locale.US), version.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format(DOCS, project.getName().toLowerCase(Locale.US), getVersion(train));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion(Train train) {
|
public String getVersion(Train train) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.data.release.model.Project;
|
import org.springframework.data.release.model.Project;
|
||||||
|
import org.springframework.data.release.model.Projects;
|
||||||
import org.springframework.data.release.utils.Logger;
|
import org.springframework.data.release.utils.Logger;
|
||||||
import org.springframework.web.client.RestOperations;
|
import org.springframework.web.client.RestOperations;
|
||||||
|
|
||||||
@@ -82,6 +83,10 @@ class DefaultSaganClient implements SaganClient {
|
|||||||
@Override
|
@Override
|
||||||
public void updateProjectMetadata(Project project, MaintainedVersions versions) {
|
public void updateProjectMetadata(Project project, MaintainedVersions versions) {
|
||||||
|
|
||||||
|
if (project != Projects.BUILD) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
URI resource = properties.getProjectReleasesResource(project);
|
URI resource = properties.getProjectReleasesResource(project);
|
||||||
|
|
||||||
String versionsString = versions.stream()//
|
String versionsString = versions.stream()//
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 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.data.release.model;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {@link DocumentationMetadata}.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
*/
|
||||||
|
class DocumentationMetadataUnitTests {
|
||||||
|
|
||||||
|
@Test // gh-167
|
||||||
|
void shouldReportCorrectDocumentationUrls() {
|
||||||
|
|
||||||
|
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0"));
|
||||||
|
|
||||||
|
assertThat(metadata.getApiDocUrl(ReleaseTrains.OCKHAM))
|
||||||
|
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/api/");
|
||||||
|
assertThat(metadata.getReferenceDocUrl(ReleaseTrains.OCKHAM))
|
||||||
|
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/reference/html/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // gh-167
|
||||||
|
void shouldReportCorrectCommonsDocumentationUrlsForBuildProject() {
|
||||||
|
|
||||||
|
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"));
|
||||||
|
|
||||||
|
assertThat(metadata.getApiDocUrl(ReleaseTrains.OCKHAM))
|
||||||
|
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/api/");
|
||||||
|
assertThat(metadata.getReferenceDocUrl(ReleaseTrains.OCKHAM))
|
||||||
|
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/reference/html/");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user