#99 - Polishing.
Avoid CGlib subclasses for configuration classes. Move ExecutorService to top-level config. Use lazy HTTP client creation to speed up test bootstrap.
This commit is contained in:
@@ -33,7 +33,7 @@ import org.xmlbeam.config.DefaultXMLFactoriesConfig.NamespacePhilosophy;
|
|||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration(proxyBeanMethods = false)
|
||||||
class BuildConfiguration {
|
class BuildConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -18,19 +18,14 @@ package org.springframework.data.release.build;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collector;
|
import java.util.stream.Collector;
|
||||||
@@ -66,12 +61,7 @@ class BuildExecutor {
|
|||||||
|
|
||||||
this.buildSystems = buildSystems;
|
this.buildSystems = buildSystems;
|
||||||
this.mavenProperties = mavenProperties;
|
this.mavenProperties = mavenProperties;
|
||||||
|
this.executor = buildExecutor;
|
||||||
if (this.mavenProperties.isParallelize()) {
|
|
||||||
this.executor = buildExecutor;
|
|
||||||
} else {
|
|
||||||
this.executor = ImmediateExecutorService.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
@@ -270,82 +260,4 @@ class BuildExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImmediateExecutorService implements ExecutorService {
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Runnable> shutdownNow() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShutdown() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTerminated() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean awaitTermination(long timeout, TimeUnit unit) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> submit(Callable<T> task) {
|
|
||||||
try {
|
|
||||||
return CompletableFuture.completedFuture(task.call());
|
|
||||||
} catch (Exception e) {
|
|
||||||
CompletableFuture<T> f = new CompletableFuture<>();
|
|
||||||
f.completeExceptionally(e);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Future<T> submit(Runnable task, T result) {
|
|
||||||
return submit(() -> {
|
|
||||||
task.run();
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<?> submit(Runnable task) {
|
|
||||||
return submit(task, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(Runnable command) {
|
|
||||||
submit(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class ReleaseCommands extends TimedCommand {
|
|||||||
|
|
||||||
git.prepare(iteration);
|
git.prepare(iteration);
|
||||||
|
|
||||||
// rebuild.runPreReleaseChecks(iteration);
|
build.runPreReleaseChecks(iteration);
|
||||||
|
|
||||||
misc.prepareChangelogs(iteration);
|
misc.prepareChangelogs(iteration);
|
||||||
misc.updateResources(iteration);
|
misc.updateResources(iteration);
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration(proxyBeanMethods = false)
|
||||||
class DeploymentConfiguration {
|
class DeploymentConfiguration {
|
||||||
|
|
||||||
@Autowired DeploymentProperties properties;
|
@Autowired DeploymentProperties properties;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ArtifactoryClient client(Logger logger) {
|
public ArtifactoryClient client(Logger logger, RestTemplate artifactoryRestTemplate) {
|
||||||
return new ArtifactoryClient(artifactoryRestTemplate(), logger, properties);
|
return new ArtifactoryClient(artifactoryRestTemplate, logger, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -27,8 +27,14 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.springframework.data.release.issues.TicketReference;
|
import org.springframework.data.release.issues.TicketReference;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Value object representing a parsed commit message. The {@link #parse(String)} method inspects a commit message to
|
||||||
|
* extract a {@link TicketReference}, related tickets, a pull request reference and summary/body from the commit. Commit
|
||||||
|
* messages may used {@code <ticket> - summary} syntax for Jira and GitHub tickets (gh- and # notation). This
|
||||||
|
* parser also supports {@code Original pull request}, {@code Related ticket} and GitHub close keywords.
|
||||||
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@@ -54,38 +60,103 @@ class ParsedCommitMessage {
|
|||||||
"Related (?>tickets|ticket):(?>\\s+)?((" + A_TICKET.pattern() + "(?>[\\s,]*))+)", Pattern.CASE_INSENSITIVE);
|
"Related (?>tickets|ticket):(?>\\s+)?((" + A_TICKET.pattern() + "(?>[\\s,]*))+)", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
private final String summary;
|
private final String summary;
|
||||||
private final String body;
|
private final @Nullable String body;
|
||||||
|
|
||||||
private final TicketReference ticketReference;
|
private final TicketReference ticketReference;
|
||||||
private final TicketReference pullRequestReference;
|
private final TicketReference pullRequestReference;
|
||||||
private final List<TicketReference> relatedTickets;
|
private final List<TicketReference> relatedTickets;
|
||||||
|
|
||||||
private ParsedCommitMessage(String summary, String body, TicketReference ticketReference,
|
private ParsedCommitMessage(String summary, @Nullable String body) {
|
||||||
TicketReference pullRequestReference, List<TicketReference> relatedTickets) {
|
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
|
|
||||||
|
TicketReference ticketReference = null;
|
||||||
|
TicketReference pullRequestReference = null;
|
||||||
|
|
||||||
|
// DATACASS-nnn - syntax
|
||||||
|
Optional<TicketReference> jiraTicket = tryParseJiraTicketReference(summary);
|
||||||
|
|
||||||
|
if (jiraTicket.isPresent()) {
|
||||||
|
ticketReference = jiraTicket.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closes (gh-nnn|#nnn) syntax
|
||||||
|
Matcher gitHubMatcher = GITHUB_CLOSE_SYNTAX.matcher(summary + "\n" + body);
|
||||||
|
|
||||||
|
// #nnn syntax
|
||||||
|
Optional<TicketReference> gitHubTicket = tryParseGitHubTicketReference(summary);
|
||||||
|
|
||||||
|
if (gitHubTicket.isPresent()) {
|
||||||
|
ticketReference = gitHubTicket.get();
|
||||||
|
} else {
|
||||||
|
if (gitHubMatcher.find()) {
|
||||||
|
ticketReference = new TicketReference(gitHubMatcher.group(1), summary, TicketReference.Style.GitHub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TicketReference> relatedTickets = parseRelatedTickets(body, gitHubMatcher);
|
||||||
|
Optional<TicketReference> optionalOriginalPr = parsePullRequestReference(body);
|
||||||
|
|
||||||
|
if (optionalOriginalPr.isPresent()) {
|
||||||
|
|
||||||
|
pullRequestReference = optionalOriginalPr.get();
|
||||||
|
|
||||||
|
if (ticketReference == null) {
|
||||||
|
ticketReference = pullRequestReference;
|
||||||
|
pullRequestReference = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.ticketReference = ticketReference;
|
this.ticketReference = ticketReference;
|
||||||
this.pullRequestReference = pullRequestReference;
|
this.pullRequestReference = pullRequestReference;
|
||||||
this.relatedTickets = relatedTickets;
|
this.relatedTickets = relatedTickets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a commit message into {@link ParsedCommitMessage}.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static ParsedCommitMessage parse(String message) {
|
public static ParsedCommitMessage parse(String message) {
|
||||||
|
|
||||||
int lineBreak = message.indexOf('\n');
|
int lineBreak = message.indexOf('\n');
|
||||||
|
|
||||||
String summary = null;
|
String summary;
|
||||||
String body = null;
|
String body;
|
||||||
TicketReference ticketReference = null;
|
|
||||||
TicketReference pullRequestReference = null;
|
|
||||||
|
|
||||||
if (lineBreak > -1) {
|
if (lineBreak > -1) {
|
||||||
summary = message.substring(0, lineBreak).trim();
|
summary = message.substring(0, lineBreak).trim();
|
||||||
body = message.substring(lineBreak + 1).trim();
|
body = message.substring(lineBreak + 1).trim();
|
||||||
} else {
|
} else {
|
||||||
summary = message.trim();
|
summary = message.trim();
|
||||||
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATACASS-nnn - syntax
|
return new ParsedCommitMessage(summary, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Optional<TicketReference> tryParseGitHubTicketReference(String summary) {
|
||||||
|
|
||||||
|
Matcher gitHubPrefixMatcher = GITHUB_PREFIX_SYNTAX.matcher(summary);
|
||||||
|
|
||||||
|
if (gitHubPrefixMatcher.find()) {
|
||||||
|
|
||||||
|
MatchResult mr = gitHubPrefixMatcher.toMatchResult();
|
||||||
|
if (mr.start(1) == 0) {
|
||||||
|
int summaryStart = findSummaryIndex(summary, mr.end(1));
|
||||||
|
|
||||||
|
return Optional.of(new TicketReference(gitHubPrefixMatcher.group(1).toUpperCase(Locale.ROOT),
|
||||||
|
summaryStart > -1 ? summary.substring(summaryStart) : summary, TicketReference.Style.GitHub));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Optional<TicketReference> tryParseJiraTicketReference(String summary) {
|
||||||
|
|
||||||
Matcher jiraMatcher = JIRA_TICKET.matcher(summary);
|
Matcher jiraMatcher = JIRA_TICKET.matcher(summary);
|
||||||
|
|
||||||
if (jiraMatcher.find()) {
|
if (jiraMatcher.find()) {
|
||||||
@@ -96,33 +167,30 @@ class ParsedCommitMessage {
|
|||||||
if (mr.start(1) < 2) {
|
if (mr.start(1) < 2) {
|
||||||
int summaryStart = findSummaryIndex(summary, mr.end(1));
|
int summaryStart = findSummaryIndex(summary, mr.end(1));
|
||||||
|
|
||||||
ticketReference = new TicketReference(jiraMatcher.group(1).toUpperCase(Locale.ROOT),
|
return Optional.of(new TicketReference(jiraMatcher.group(1).toUpperCase(Locale.ROOT),
|
||||||
summaryStart > -1 ? summary.substring(summaryStart) : summary, TicketReference.Style.Jira);
|
summaryStart > -1 ? summary.substring(summaryStart) : summary, TicketReference.Style.Jira));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes (gh-nnn|#nnn) syntax
|
return Optional.empty();
|
||||||
Matcher gitHubMatcher = GITHUB_CLOSE_SYNTAX.matcher(message);
|
}
|
||||||
|
|
||||||
// #nnn syntax
|
protected static Optional<TicketReference> parsePullRequestReference(String body) {
|
||||||
Matcher gitHubPrefixMatcher = GITHUB_PREFIX_SYNTAX.matcher(summary);
|
|
||||||
|
|
||||||
if (gitHubPrefixMatcher.find()) {
|
if (body != null) {
|
||||||
|
|
||||||
MatchResult mr = gitHubPrefixMatcher.toMatchResult();
|
Matcher prMatcher = ORIGINAL_PULL_REQUEST.matcher(body);
|
||||||
if (mr.start(1) == 0) {
|
|
||||||
int summaryStart = findSummaryIndex(summary, mr.end(1));
|
|
||||||
|
|
||||||
ticketReference = new TicketReference(gitHubPrefixMatcher.group(1).toUpperCase(Locale.ROOT),
|
if (prMatcher.find()) {
|
||||||
summaryStart > -1 ? summary.substring(summaryStart) : summary, TicketReference.Style.GitHub);
|
return extractTicket(prMatcher.group(1));
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (gitHubMatcher.find()) {
|
|
||||||
ticketReference = new TicketReference(gitHubMatcher.group(1), summary, TicketReference.Style.GitHub);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static List<TicketReference> parseRelatedTickets(String body, Matcher gitHubMatcher) {
|
||||||
|
|
||||||
List<TicketReference> relatedTickets = new ArrayList<>();
|
List<TicketReference> relatedTickets = new ArrayList<>();
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
Matcher relatedTicketsMatcher = RELATED_TICKET.matcher(body);
|
Matcher relatedTicketsMatcher = RELATED_TICKET.matcher(body);
|
||||||
@@ -141,26 +209,7 @@ class ParsedCommitMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body != null) {
|
return relatedTickets;
|
||||||
|
|
||||||
Matcher prMatcher = ORIGINAL_PULL_REQUEST.matcher(body);
|
|
||||||
|
|
||||||
if (prMatcher.find()) {
|
|
||||||
|
|
||||||
Optional<TicketReference> pullRequest = extractTicket(prMatcher.group(1));
|
|
||||||
|
|
||||||
if (pullRequest.isPresent()) {
|
|
||||||
pullRequestReference = pullRequest.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ticketReference == null && pullRequestReference != null) {
|
|
||||||
ticketReference = pullRequestReference;
|
|
||||||
pullRequestReference = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ParsedCommitMessage(summary, body, ticketReference, pullRequestReference, relatedTickets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Optional<TicketReference> extractTicket(String ticketId) {
|
protected static Optional<TicketReference> extractTicket(String ticketId) {
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ public class Changelog {
|
|||||||
|
|
||||||
builder.append("* ").append(ticket.getId()).append(" - ").append(summary != null ? summary.trim() : "");
|
builder.append("* ").append(ticket.getId()).append(" - ").append(summary != null ? summary.trim() : "");
|
||||||
|
|
||||||
if (summary == null) {
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
if (!summary.endsWith(".")) {
|
if (!summary.endsWith(".")) {
|
||||||
builder.append(".");
|
builder.append(".");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,18 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
*/
|
*/
|
||||||
Changelog getChangelogFor(ModuleIteration module);
|
Changelog getChangelogFor(ModuleIteration module);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link Changelog} for the given {@link ModuleIteration} using {@link TicketReference}s.
|
||||||
|
*
|
||||||
|
* @param module must not be {@literal null}.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default Changelog getChangelogFor(ModuleIteration module, List<TicketReference> ticketReferences) {
|
||||||
|
|
||||||
|
Tickets tickets = resolve(module, ticketReferences);
|
||||||
|
return Changelog.of(module, tickets);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the given {@link ModuleIteration}.
|
* Closes the given {@link ModuleIteration}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.release.issues;
|
package org.springframework.data.release.issues;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
@@ -40,6 +42,9 @@ import org.springframework.data.release.issues.github.GitHubProperties;
|
|||||||
import org.springframework.data.release.issues.jira.JiraProperties;
|
import org.springframework.data.release.issues.jira.JiraProperties;
|
||||||
import org.springframework.data.release.model.Project;
|
import org.springframework.data.release.model.Project;
|
||||||
import org.springframework.data.release.utils.HttpBasicCredentials;
|
import org.springframework.data.release.utils.HttpBasicCredentials;
|
||||||
|
import org.springframework.data.util.Lazy;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.client.ClientHttpRequest;
|
||||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
@@ -60,7 +65,7 @@ import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
|||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableCaching(proxyTargetClass = true)
|
@EnableCaching(proxyTargetClass = true)
|
||||||
class IssueTrackerConfiguration {
|
class IssueTrackerConfiguration {
|
||||||
|
|
||||||
@@ -93,9 +98,17 @@ class IssueTrackerConfiguration {
|
|||||||
addPreemptiveAuth(credsProvider, authCache, jiraProperties.getApiUrl(), jiraProperties.getCredentials());
|
addPreemptiveAuth(credsProvider, authCache, jiraProperties.getApiUrl(), jiraProperties.getCredentials());
|
||||||
addPreemptiveAuth(credsProvider, authCache, gitHubProperties.getApiUrl(), gitHubProperties.getHttpCredentials());
|
addPreemptiveAuth(credsProvider, authCache, gitHubProperties.getApiUrl(), gitHubProperties.getHttpCredentials());
|
||||||
|
|
||||||
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build();
|
Lazy<CloseableHttpClient> lazy = Lazy
|
||||||
|
.of(() -> HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build());
|
||||||
|
|
||||||
|
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory() {
|
||||||
|
@Override
|
||||||
|
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
|
||||||
|
setHttpClient(lazy.get());
|
||||||
|
return super.createRequest(uri, httpMethod);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
|
||||||
factory.setHttpContextFactory((httpMethod, uri) -> {
|
factory.setHttpContextFactory((httpMethod, uri) -> {
|
||||||
HttpClientContext context = HttpClientContext.create();
|
HttpClientContext context = HttpClientContext.create();
|
||||||
context.setAuthCache(authCache);
|
context.setAuthCache(authCache);
|
||||||
@@ -107,13 +120,13 @@ class IssueTrackerConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Qualifier("tracker")
|
@Qualifier("tracker")
|
||||||
RestTemplateBuilder restTemplate(ClientHttpRequestFactory clientHttpRequestFactory) {
|
RestTemplateBuilder restTemplate(ClientHttpRequestFactory clientHttpRequestFactory,
|
||||||
|
ObjectMapper jacksonObjectMapper) {
|
||||||
|
|
||||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||||
converter.setObjectMapper(jacksonObjectMapper());
|
converter.setObjectMapper(jacksonObjectMapper);
|
||||||
|
|
||||||
return new RestTemplateBuilder().messageConverters(converter)
|
return new RestTemplateBuilder().messageConverters(converter).requestFactory(() -> clientHttpRequestFactory);
|
||||||
.requestFactory(() -> clientHttpRequestFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.springframework.data.release.misc;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,6 +29,7 @@ import org.springframework.data.release.git.GitOperations;
|
|||||||
import org.springframework.data.release.io.Workspace;
|
import org.springframework.data.release.io.Workspace;
|
||||||
import org.springframework.data.release.issues.Changelog;
|
import org.springframework.data.release.issues.Changelog;
|
||||||
import org.springframework.data.release.issues.IssueTracker;
|
import org.springframework.data.release.issues.IssueTracker;
|
||||||
|
import org.springframework.data.release.issues.Ticket;
|
||||||
import org.springframework.data.release.issues.TicketReference;
|
import org.springframework.data.release.issues.TicketReference;
|
||||||
import org.springframework.data.release.issues.Tickets;
|
import org.springframework.data.release.issues.Tickets;
|
||||||
import org.springframework.data.release.model.Iteration;
|
import org.springframework.data.release.model.Iteration;
|
||||||
@@ -84,6 +86,7 @@ public class ReleaseOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void prepareChangelog(TrainIteration iteration, TrainIteration previousIteration, ModuleIteration module) {
|
protected void prepareChangelog(TrainIteration iteration, TrainIteration previousIteration, ModuleIteration module) {
|
||||||
|
|
||||||
IssueTracker issueTracker = trackers.getRequiredPluginFor(module.getProject(),
|
IssueTracker issueTracker = trackers.getRequiredPluginFor(module.getProject(),
|
||||||
() -> String.format("No issue tracker found for project %s!", module.getProject()));
|
() -> String.format("No issue tracker found for project %s!", module.getProject()));
|
||||||
|
|
||||||
@@ -116,14 +119,22 @@ public class ReleaseOperations {
|
|||||||
|
|
||||||
protected Changelog getChangelog(TrainIteration iteration, TrainIteration previousIteration, ModuleIteration module,
|
protected Changelog getChangelog(TrainIteration iteration, TrainIteration previousIteration, ModuleIteration module,
|
||||||
IssueTracker issueTracker) {
|
IssueTracker issueTracker) {
|
||||||
|
|
||||||
Changelog changelog;
|
Changelog changelog;
|
||||||
|
|
||||||
if (COMMIT_BASED_CHANGELOG) {
|
if (COMMIT_BASED_CHANGELOG) {
|
||||||
|
|
||||||
List<TicketReference> ticketReferences = git.getTicketReferencesBetween(module.getProject(), previousIteration,
|
List<TicketReference> ticketReferences = git.getTicketReferencesBetween(module.getProject(), previousIteration,
|
||||||
iteration);
|
iteration);
|
||||||
Tickets resolvedTickets = issueTracker.resolve(module, ticketReferences);
|
|
||||||
changelog = Changelog.of(module, resolvedTickets);
|
// TODO: Remove once all tickets are migrated to GitHub
|
||||||
|
List<Ticket> tickets = new ArrayList<>();
|
||||||
|
|
||||||
|
for (IssueTracker tracker : trackers) {
|
||||||
|
tickets.addAll(tracker.resolve(module, ticketReferences).getTickets());
|
||||||
|
}
|
||||||
|
|
||||||
|
changelog = Changelog.of(module, new Tickets(tickets));
|
||||||
} else {
|
} else {
|
||||||
changelog = issueTracker.getChangelogFor(module);
|
changelog = issueTracker.getChangelogFor(module);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.release.git.GitOperations;
|
import org.springframework.data.release.git.GitOperations;
|
||||||
|
import org.springframework.data.release.git.GitProperties;
|
||||||
import org.springframework.data.release.utils.Logger;
|
import org.springframework.data.release.utils.Logger;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@@ -31,26 +32,24 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration(proxyBeanMethods = false)
|
||||||
class SaganConfiguration {
|
class SaganConfiguration {
|
||||||
|
|
||||||
|
@Autowired GitProperties gitProperties;
|
||||||
@Autowired SaganProperties properties;
|
@Autowired SaganProperties properties;
|
||||||
@Autowired Logger logger;
|
@Autowired Logger logger;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SaganOperations saganOperations(GitOperations operations, Executor executor) {
|
public SaganOperations saganOperations(GitOperations operations, SaganClient saganClient, Executor executor) {
|
||||||
return new SaganOperations(operations, executor, saganClient(), logger);
|
return new SaganOperations(operations, executor, saganClient, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
SaganClient saganClient() {
|
SaganClient saganClient() {
|
||||||
|
|
||||||
return new DefaultSaganClient(saganRestTemplate(), properties, logger);
|
RestTemplate restTemplate = new RestTemplateBuilder()
|
||||||
// return new DummySaganClient(logger, new ObjectMapper().writerWithDefaultPrettyPrinter());
|
.basicAuthentication(gitProperties.getUsername(), properties.key).build();
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
return new DefaultSaganClient(restTemplate, properties, logger);
|
||||||
RestTemplate saganRestTemplate() {
|
|
||||||
return new RestTemplateBuilder().basicAuthentication("mp911de", properties.key).build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ package org.springframework.data.release.utils;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;
|
import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;
|
||||||
@@ -29,7 +39,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;
|
|||||||
class ExecutorConfiguration {
|
class ExecutorConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ThreadPoolExecutorFactoryBean executorService() {
|
@ConditionalOnProperty(prefix = "maven", name = "parallelize")
|
||||||
|
public ThreadPoolExecutorFactoryBean threadPoolExecutorFactoryBean() {
|
||||||
|
|
||||||
int processors = Runtime.getRuntime().availableProcessors();
|
int processors = Runtime.getRuntime().availableProcessors();
|
||||||
int threadCount = Math.max(2, processors - 4);
|
int threadCount = Math.max(2, processors - 4);
|
||||||
@@ -41,4 +52,88 @@ class ExecutorConfiguration {
|
|||||||
|
|
||||||
return scheduler;
|
return scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "maven", name = "parallelize", matchIfMissing = true, havingValue = "false")
|
||||||
|
public ExecutorService executorService() {
|
||||||
|
return ImmediateExecutorService.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ImmediateExecutorService implements ExecutorService {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Runnable> shutdownNow() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isShutdown() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTerminated() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean awaitTermination(long timeout, TimeUnit unit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Future<T> submit(Callable<T> task) {
|
||||||
|
try {
|
||||||
|
return CompletableFuture.completedFuture(task.call());
|
||||||
|
} catch (Exception e) {
|
||||||
|
CompletableFuture<T> f = new CompletableFuture<>();
|
||||||
|
f.completeExceptionally(e);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Future<T> submit(Runnable task, T result) {
|
||||||
|
return submit(() -> {
|
||||||
|
task.run();
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Future<?> submit(Runnable task) {
|
||||||
|
return submit(task, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Runnable command) {
|
||||||
|
submit(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ logging.level.org.springframework=WARN
|
|||||||
logging.level.org.springframework.data.release=INFO
|
logging.level.org.springframework.data.release=INFO
|
||||||
logging.level.org.springframework.web.client=TRACE
|
logging.level.org.springframework.web.client=TRACE
|
||||||
logging.level.org.springframework.http=DEBUG
|
logging.level.org.springframework.http=DEBUG
|
||||||
|
|
||||||
# Deployment
|
# Deployment
|
||||||
deployment.repository-prefix=test-
|
deployment.repository-prefix=test-
|
||||||
|
maven.parallelize=false
|
||||||
jira.username=dummy
|
jira.username=dummy
|
||||||
jira.password=dummy
|
jira.password=dummy
|
||||||
jira.api-url=http://localhost:8888
|
jira.api-url=http://localhost:8888
|
||||||
|
|
||||||
git.username=dummy
|
git.username=dummy
|
||||||
git.password=dummy
|
git.password=dummy
|
||||||
git.email=dummy@dummy.com
|
git.email=dummy@dummy.com
|
||||||
|
|||||||
14
release-tools/src/test/resources/logback-test.xml
Normal file
14
release-tools/src/test/resources/logback-test.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user