#133 - Polishing.
Use Commons IO IOUtils for OS-specific line separator instead of Spring Shell. Remove Credentials in favor of HttpBasicCredentials.
This commit is contained in:
@@ -15,12 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.release.cli;
|
package org.springframework.data.release.cli;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import org.springframework.boot.SpringBootVersion;
|
import org.springframework.boot.SpringBootVersion;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.shell.plugin.BannerProvider;
|
import org.springframework.shell.plugin.BannerProvider;
|
||||||
import org.springframework.shell.support.util.FileUtils;
|
import org.springframework.shell.support.util.FileUtils;
|
||||||
import org.springframework.shell.support.util.OsUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
@@ -46,8 +47,8 @@ class SpringDataReleaseCliBannerProvider implements BannerProvider {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append(FileUtils.readBanner(SpringDataReleaseCliBannerProvider.class, "banner.txt"));
|
builder.append(FileUtils.readBanner(SpringDataReleaseCliBannerProvider.class, "banner.txt"));
|
||||||
builder.append(getVersion()).append(OsUtils.LINE_SEPARATOR);
|
builder.append(getVersion()).append(IOUtils.LINE_SEPARATOR);
|
||||||
builder.append(OsUtils.LINE_SEPARATOR);
|
builder.append(IOUtils.LINE_SEPARATOR);
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import org.springframework.data.release.model.ArtifactVersion;
|
import org.springframework.data.release.model.ArtifactVersion;
|
||||||
import org.springframework.data.release.model.ModuleIteration;
|
import org.springframework.data.release.model.ModuleIteration;
|
||||||
import org.springframework.format.datetime.DateFormatter;
|
import org.springframework.format.datetime.DateFormatter;
|
||||||
import org.springframework.shell.support.util.OsUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
@@ -48,13 +49,13 @@ public class Changelog {
|
|||||||
String headline = String.format("Changes in version %s (%s)", version,
|
String headline = String.format("Changes in version %s (%s)", version,
|
||||||
new DateFormatter("YYYY-MM-dd").print(new Date(), Locale.US));
|
new DateFormatter("YYYY-MM-dd").print(new Date(), Locale.US));
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder(headline).append(OsUtils.LINE_SEPARATOR);
|
StringBuilder builder = new StringBuilder(headline).append(IOUtils.LINE_SEPARATOR);
|
||||||
|
|
||||||
for (int i = 0; i < headline.length(); i++) {
|
for (int i = 0; i < headline.length(); i++) {
|
||||||
builder.append("-");
|
builder.append("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append(OsUtils.LINE_SEPARATOR);
|
builder.append(IOUtils.LINE_SEPARATOR);
|
||||||
|
|
||||||
for (Ticket ticket : tickets) {
|
for (Ticket ticket : tickets) {
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ public class Changelog {
|
|||||||
builder.append(".");
|
builder.append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append(OsUtils.LINE_SEPARATOR);
|
builder.append(IOUtils.LINE_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014-2016 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.data.release.issues.jira;
|
|
||||||
|
|
||||||
import lombok.Value;
|
|
||||||
|
|
||||||
import javax.xml.bind.DatatypeConverter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Oliver Gierke
|
|
||||||
*/
|
|
||||||
@Value
|
|
||||||
class Credentials {
|
|
||||||
|
|
||||||
String username, password;
|
|
||||||
|
|
||||||
public String asBase64() {
|
|
||||||
return DatatypeConverter.printBase64Binary(String.format("%s:%s", username, password).getBytes());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -702,7 +702,7 @@ class Jira implements JiraConnector {
|
|||||||
private HttpHeaders newUserScopedHttpHeaders() {
|
private HttpHeaders newUserScopedHttpHeaders() {
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Authorization", String.format("Basic %s", jiraProperties.getCredentials().asBase64()));
|
headers.set("Authorization", jiraProperties.getCredentials().toString());
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import lombok.Getter;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.data.release.model.Password;
|
||||||
|
import org.springframework.data.release.utils.HttpBasicCredentials;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@@ -36,23 +38,23 @@ import org.springframework.util.Assert;
|
|||||||
@ConfigurationProperties(prefix = "jira")
|
@ConfigurationProperties(prefix = "jira")
|
||||||
class JiraProperties {
|
class JiraProperties {
|
||||||
|
|
||||||
private @Getter(AccessLevel.PRIVATE) String password;
|
private @Getter(AccessLevel.PRIVATE) Password password;
|
||||||
private String username, apiUrl;
|
private String username, apiUrl;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
Assert.hasText(username, "No Jira username (jira.username) configured!");
|
Assert.hasText(username, "No Jira username (jira.username) configured!");
|
||||||
Assert.hasText(password, "No Jira password (jira.password) configured!");
|
Assert.notNull(password, "No Jira password (jira.password) configured!");
|
||||||
Assert.hasText(apiUrl, "No Jira url (jira.api-url) configured!");
|
Assert.hasText(apiUrl, "No Jira url (jira.api-url) configured!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Credentials} to be used.
|
* Returns the {@link HttpBasicCredentials} to be used.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Credentials getCredentials() {
|
public HttpBasicCredentials getCredentials() {
|
||||||
return new Credentials(username, password);
|
return new HttpBasicCredentials(username, password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.release.Streamable;
|
||||||
import org.springframework.shell.support.util.OsUtils;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,12 +166,12 @@ public class Train implements Streamable<Module> {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append(name).//
|
builder.append(name).//
|
||||||
append(OsUtils.LINE_SEPARATOR).//
|
append(IOUtils.LINE_SEPARATOR).//
|
||||||
append(OsUtils.LINE_SEPARATOR);
|
append(IOUtils.LINE_SEPARATOR);
|
||||||
|
|
||||||
builder.append(modules.stream().//
|
builder.append(modules.stream().//
|
||||||
map(Module::toString).//
|
map(Module::toString).//
|
||||||
collect(Collectors.joining(OsUtils.LINE_SEPARATOR)));
|
collect(Collectors.joining(IOUtils.LINE_SEPARATOR)));
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user