#133 - Upgrade to Spring Boot 2.2.

This commit is contained in:
Mark Paluch
2019-11-20 14:13:42 +01:00
parent 75c63aff1e
commit 989e6dd150
17 changed files with 161 additions and 153 deletions

View File

@@ -1 +1,2 @@
lombok.nonNull.exceptionType = IllegalArgumentException lombok.nonNull.exceptionType = IllegalArgumentException
lombok.anyConstructor.addConstructorProperties = true

58
pom.xml
View File

@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.data.build</groupId> <groupId>org.springframework.data.build</groupId>
@@ -8,13 +9,11 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version> <version>2.2.1.RELEASE</version>
</parent> </parent>
<properties> <properties>
<java.version>1.8</java.version> <spring-plugin.version>2.0.0.RELEASE</spring-plugin.version>
<jar.mainclass>org.springframework.data.release.Application</jar.mainclass>
<spring-plugin.version>2.0.0.BUILD-SNAPSHOT</spring-plugin.version>
</properties> </properties>
<dependencies> <dependencies>
@@ -52,7 +51,7 @@
<dependency> <dependency>
<groupId>org.springframework.shell</groupId> <groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId> <artifactId>spring-shell</artifactId>
<version>1.2.0.RC1</version> <version>1.2.0.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -75,13 +74,13 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.16.6</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.plugin</groupId> <groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId> <artifactId>spring-plugin-core</artifactId>
<version>${spring-plugin.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -120,57 +119,32 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.name}</finalName>
<plugins> <plugins>
<!-- Shell packaging -->
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>appassembler-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<programs>
<program>
<mainClass>${jar.mainclass}</mainClass>
<id>spring-data-release-shell</id>
</program>
</programs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>https://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>
</project> </project>

View File

@@ -21,7 +21,7 @@ See `application-local.template` for details.
### Build and execute the release shell ### Build and execute the release shell
Run `mvn package appassembler:assemble && sh target/appassembler/bin/spring-data-release-shell` Run `mvn package && java -jar target/spring-data-release-cli.jar`
## The release process ## The release process

View File

@@ -22,14 +22,14 @@ import org.springframework.util.StopWatch;
/** /**
* Base class for command implementations who want to get their execution time logged. * Base class for command implementations who want to get their execution time logged.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public abstract class TimedCommand implements ExecutionProcessor, CommandMarker { public abstract class TimedCommand implements ExecutionProcessor, CommandMarker {
private StopWatch watch; private StopWatch watch;
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.core.ExecutionProcessor#beforeInvocation(org.springframework.shell.event.ParseResult) * @see org.springframework.shell.core.ExecutionProcessor#beforeInvocation(org.springframework.shell.event.ParseResult)
*/ */
@@ -42,7 +42,7 @@ public abstract class TimedCommand implements ExecutionProcessor, CommandMarker
return invocationContext; return invocationContext;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.core.ExecutionProcessor#afterReturningInvocation(org.springframework.shell.event.ParseResult, java.lang.Object) * @see org.springframework.shell.core.ExecutionProcessor#afterReturningInvocation(org.springframework.shell.event.ParseResult, java.lang.Object)
*/ */
@@ -51,7 +51,7 @@ public abstract class TimedCommand implements ExecutionProcessor, CommandMarker
stopAndLog(); stopAndLog();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.core.ExecutionProcessor#afterThrowingInvocation(org.springframework.shell.event.ParseResult, java.lang.Throwable) * @see org.springframework.shell.core.ExecutionProcessor#afterThrowingInvocation(org.springframework.shell.event.ParseResult, java.lang.Throwable)
*/ */
@@ -63,6 +63,6 @@ public abstract class TimedCommand implements ExecutionProcessor, CommandMarker
private void stopAndLog() { private void stopAndLog() {
watch.stop(); watch.stop();
System.out.println(String.format("Took: %s sec.", watch.getTotalTimeSeconds())); System.out.println(String.format("Took: %.2f sec.", watch.getTotalTimeSeconds()));
} }
} }

View File

@@ -18,15 +18,19 @@ 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.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
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.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@@ -45,8 +49,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.google.common.util.concurrent.MoreExecutors;
/** /**
* Build executor service. * Build executor service.
* *
@@ -72,7 +74,7 @@ class BuildExecutor {
int parallelity = Math.max(2, (processors / 2)); int parallelity = Math.max(2, (processors / 2));
executor = new ThreadPoolExecutor(parallelity, parallelity, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<>(256)); executor = new ThreadPoolExecutor(parallelity, parallelity, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<>(256));
} else { } else {
executor = MoreExecutors.newDirectExecutorService(); executor = ImmediateExecutorService.INSTANCE;
} }
} }
@@ -266,4 +268,82 @@ 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);
}
}
} }

View File

@@ -24,6 +24,8 @@ import java.util.function.BiFunction;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.assertj.core.util.VisibleForTesting;
import org.springframework.data.release.deployment.DeploymentInformation; import org.springframework.data.release.deployment.DeploymentInformation;
import org.springframework.data.release.model.Module; import org.springframework.data.release.model.Module;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
@@ -36,8 +38,6 @@ import org.springframework.plugin.core.PluginRegistry;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import com.google.common.annotations.VisibleForTesting;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch * @author Mark Paluch

View File

@@ -15,6 +15,7 @@
*/ */
package org.springframework.data.release.cli; package org.springframework.data.release.cli;
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;
@@ -26,7 +27,7 @@ import org.springframework.stereotype.Component;
@Component @Component
class SpringDataReleaseCliBannerProvider implements BannerProvider { class SpringDataReleaseCliBannerProvider implements BannerProvider {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.plugin.NamedProvider#getProviderName() * @see org.springframework.shell.plugin.NamedProvider#getProviderName()
*/ */
@@ -35,7 +36,7 @@ class SpringDataReleaseCliBannerProvider implements BannerProvider {
return "Spring Data Release Shell"; return "Spring Data Release Shell";
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.plugin.BannerProvider#getBanner() * @see org.springframework.shell.plugin.BannerProvider#getBanner()
*/ */
@@ -51,16 +52,16 @@ class SpringDataReleaseCliBannerProvider implements BannerProvider {
return builder.toString(); return builder.toString();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.plugin.BannerProvider#getVersion() * @see org.springframework.shell.plugin.BannerProvider#getVersion()
*/ */
@Override @Override
public String getVersion() { public String getVersion() {
return "1.0"; return "1.0 on Spring Boot " + SpringBootVersion.getVersion();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.shell.plugin.BannerProvider#getWelcomeMessage() * @see org.springframework.shell.plugin.BannerProvider#getWelcomeMessage()
*/ */

View File

@@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor; import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Optional; import java.util.Optional;
import java.util.Scanner; import java.util.Scanner;
import java.util.function.Predicate; import java.util.function.Predicate;
@@ -192,10 +193,6 @@ public class Workspace {
} }
} }
public boolean processFiles(String pattern, Project project, LineCallback callback) {
return false;
}
public boolean processFile(String filename, Project project, LineCallback callback) { public boolean processFile(String filename, Project project, LineCallback callback) {
File file = getFile(filename, project); File file = getFile(filename, project);
@@ -226,7 +223,7 @@ public class Workspace {
private void writeContentToFile(String name, Project project, String content) throws IOException { private void writeContentToFile(String name, Project project, String content) throws IOException {
File file = getFile(name, project); File file = getFile(name, project);
com.google.common.io.Files.write(content, file, UTF_8); Files.write(file.toPath(), Collections.singleton(content), UTF_8);
} }
/** /**

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.issues; package org.springframework.data.release.issues;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager; import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
@@ -26,11 +26,9 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.release.model.Project; import org.springframework.data.release.model.Project;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.plugin.core.OrderAwarePluginRegistry; import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry; import org.springframework.plugin.core.PluginRegistry;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.annotation.JsonCreator.Mode; import com.fasterxml.jackson.annotation.JsonCreator.Mode;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -70,19 +68,13 @@ class IssueTrackerConfiguration {
@Bean @Bean
@Qualifier("tracker") @Qualifier("tracker")
RestTemplate restTemplate() { RestTemplateBuilder restTemplate() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(jacksonObjectMapper()); converter.setObjectMapper(jacksonObjectMapper());
List<HttpMessageConverter<?>> converters = new ArrayList<>(); return new RestTemplateBuilder().messageConverters(converter)
converters.add(converter); .requestFactory(HttpComponentsClientHttpRequestFactory.class);
RestTemplate template = new RestTemplate();
template.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
template.setMessageConverters(converters);
return template;
} }
@Bean @Bean

View File

@@ -30,6 +30,7 @@ import java.util.regex.Pattern;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
@@ -53,6 +54,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestOperations; import org.springframework.web.client.RestOperations;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriTemplate; import org.springframework.web.util.UriTemplate;
/** /**
@@ -62,13 +64,13 @@ import org.springframework.web.util.UriTemplate;
@Component @Component
class GitHub implements IssueTracker { class GitHub implements IssueTracker {
private static final String MILESTONE_URI = "{githubBaseUrl}/repos/spring-projects/{repoName}/milestones?state={state}"; private static final String MILESTONE_URI = "/repos/spring-projects/{repoName}/milestones?state={state}";
private static final String ISSUES_BY_MILESTONE_AND_ASSIGNEE_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/issues?milestone={id}&state=all&assignee={assignee}"; private static final String ISSUES_BY_MILESTONE_AND_ASSIGNEE_URI_TEMPLATE = "/repos/spring-projects/{repoName}/issues?milestone={id}&state=all&assignee={assignee}";
private static final String ISSUES_BY_MILESTONE_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/issues?milestone={id}&state=all"; private static final String ISSUES_BY_MILESTONE_URI_TEMPLATE = "/repos/spring-projects/{repoName}/issues?milestone={id}&state=all";
private static final String MILESTONES_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/milestones"; private static final String MILESTONES_URI_TEMPLATE = "/repos/spring-projects/{repoName}/milestones";
private static final String MILESTONE_BY_ID_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/milestones/{id}"; private static final String MILESTONE_BY_ID_URI_TEMPLATE = "/repos/spring-projects/{repoName}/milestones/{id}";
private static final String ISSUE_BY_ID_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/issues/{id}"; private static final String ISSUE_BY_ID_URI_TEMPLATE = "/repos/spring-projects/{repoName}/issues/{id}";
private static final String ISSUES_URI_TEMPLATE = "{githubBaseUrl}/repos/spring-projects/{repoName}/issues"; private static final String ISSUES_URI_TEMPLATE = "/repos/spring-projects/{repoName}/issues";
private static final ParameterizedTypeReference<List<Milestone>> MILESTONES_TYPE = new ParameterizedTypeReference<List<Milestone>>() {}; private static final ParameterizedTypeReference<List<Milestone>> MILESTONES_TYPE = new ParameterizedTypeReference<List<Milestone>>() {};
private static final ParameterizedTypeReference<List<GitHubIssue>> ISSUES_TYPE = new ParameterizedTypeReference<List<GitHubIssue>>() {}; private static final ParameterizedTypeReference<List<GitHubIssue>> ISSUES_TYPE = new ParameterizedTypeReference<List<GitHubIssue>>() {};
@@ -79,13 +81,13 @@ class GitHub implements IssueTracker {
private final GitHubProperties properties; private final GitHubProperties properties;
/** /**
* @param operations * @param templateBuilder
* @param logger * @param logger
* @param properties * @param properties
*/ */
public GitHub(@Qualifier("tracker") RestOperations operations, Logger logger, GitHubProperties properties) { public GitHub(@Qualifier("tracker") RestTemplateBuilder templateBuilder, Logger logger, GitHubProperties properties) {
this.operations = operations; this.operations = templateBuilder.uriTemplateHandler(new DefaultUriBuilderFactory(properties.getApiUrl())).build();
this.logger = logger; this.logger = logger;
this.properties = properties; this.properties = properties;
} }
@@ -353,8 +355,6 @@ class GitHub implements IssueTracker {
private Map<String, Object> newUrlTemplateVariables() { private Map<String, Object> newUrlTemplateVariables() {
Map<String, Object> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>();
parameters.put("githubBaseUrl", properties.getApiUrl());
return parameters; return parameters;
} }

View File

@@ -26,6 +26,7 @@ import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
@@ -52,6 +53,7 @@ import org.springframework.util.Assert;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestOperations; import org.springframework.web.client.RestOperations;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriTemplate; import org.springframework.web.util.UriTemplate;
/** /**
@@ -61,15 +63,14 @@ import org.springframework.web.util.UriTemplate;
@Component @Component
class Jira implements JiraConnector { class Jira implements JiraConnector {
private static final String BASE_URI = "{jiraBaseUrl}/rest/api/2"; private static final String CREATE_ISSUES_TEMPLATE = "/issue";
private static final String CREATE_ISSUES_TEMPLATE = BASE_URI + "/issue"; private static final String ISSUE_TEMPLATE = "/issue/{ticketId}";
private static final String ISSUE_TEMPLATE = BASE_URI + "/issue/{ticketId}"; private static final String TRANSITION_TEMPLATE = "/issue/{ticketId}/transitions";
private static final String TRANSITION_TEMPLATE = BASE_URI + "/issue/{ticketId}/transitions"; private static final String PROJECT_VERSIONS_TEMPLATE = "/project/{project}/version?startAt={startAt}";
private static final String PROJECT_VERSIONS_TEMPLATE = BASE_URI + "/project/{project}/version?startAt={startAt}"; private static final String PROJECT_COMPONENTS_TEMPLATE = "/project/{project}/components";
private static final String PROJECT_COMPONENTS_TEMPLATE = BASE_URI + "/project/{project}/components"; private static final String VERSIONS_TEMPLATE = "/version";
private static final String VERSIONS_TEMPLATE = BASE_URI + "/version"; private static final String VERSION_TEMPLATE = "/version/{id}";
private static final String VERSION_TEMPLATE = BASE_URI + "/version/{id}"; private static final String SEARCH_TEMPLATE = "/search?jql={jql}&fields={fields}&startAt={startAt}";
private static final String SEARCH_TEMPLATE = BASE_URI + "/search?jql={jql}&fields={fields}&startAt={startAt}";
private static final String INFRASTRUCTURE_COMPONENT_NAME = "Infrastructure"; private static final String INFRASTRUCTURE_COMPONENT_NAME = "Infrastructure";
private static final String IN_PROGRESS_STATUS_CATEGORY = "indeterminate"; private static final String IN_PROGRESS_STATUS_CATEGORY = "indeterminate";
@@ -87,13 +88,15 @@ class Jira implements JiraConnector {
private final JiraProperties jiraProperties; private final JiraProperties jiraProperties;
/** /**
* @param operations * @param templateBuilder
* @param logger * @param logger
* @param jiraProperties * @param jiraProperties
*/ */
public Jira(@Qualifier("tracker") RestOperations operations, Logger logger, JiraProperties jiraProperties) { public Jira(@Qualifier("tracker") RestTemplateBuilder templateBuilder, Logger logger, JiraProperties jiraProperties) {
this.operations = operations; String baseUri = String.format("%s/rest/api/2", jiraProperties.getApiUrl());
this.operations = templateBuilder.uriTemplateHandler(new DefaultUriBuilderFactory(baseUri)).build();
this.logger = logger; this.logger = logger;
this.jiraProperties = jiraProperties; this.jiraProperties = jiraProperties;
} }
@@ -556,7 +559,6 @@ class Jira implements JiraConnector {
return project.uses(Tracker.JIRA); return project.uses(Tracker.JIRA);
} }
@Cacheable("jira-components")
protected JiraComponents getJiraComponents(ProjectKey projectKey) { protected JiraComponents getJiraComponents(ProjectKey projectKey) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
@@ -706,7 +708,6 @@ class Jira implements JiraConnector {
private Map<String, Object> newUrlTemplateVariables() { private Map<String, Object> newUrlTemplateVariables() {
Map<String, Object> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>();
parameters.put("jiraBaseUrl", jiraProperties.getApiUrl());
return parameters; return parameters;
} }

View File

@@ -20,7 +20,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Wither; import lombok.With;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -42,11 +42,11 @@ public class Project implements Comparable<Project> {
private final @Getter ProjectKey key; private final @Getter ProjectKey key;
private final @Getter String name; private final @Getter String name;
private final @Wither String fullName; private final @With String fullName;
private final Collection<Project> dependencies; private final Collection<Project> dependencies;
private final @Getter Tracker tracker; private final @Getter Tracker tracker;
private final @Wither ArtifactCoordinates additionalArtifacts; private final @With ArtifactCoordinates additionalArtifacts;
private final @Wither boolean skipTests; private final @With boolean skipTests;
Project(String key, String name) { Project(String key, String name) {
this(key, name, null, Tracker.JIRA); this(key, name, null, Tracker.JIRA);

View File

@@ -22,7 +22,7 @@ import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import lombok.Value; import lombok.Value;
import lombok.experimental.Wither; import lombok.With;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -47,8 +47,8 @@ public class Train implements Streamable<Module> {
private final String name;; private final String name;;
private final Modules modules; private final Modules modules;
private @Wither Iterations iterations; private @With Iterations iterations;
private @Wither boolean alwaysUseBranch; private @With boolean alwaysUseBranch;
public Train(String name, Module... modules) { public Train(String name, Module... modules) {
this(name, Arrays.asList(modules)); this(name, Arrays.asList(modules));

View File

@@ -15,27 +15,17 @@
*/ */
package org.springframework.data.release.sagan; package org.springframework.data.release.sagan;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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.utils.Logger; import org.springframework.data.release.utils.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Configuration for the Sagan interaction subsystem. * Configuration for the Sagan interaction subsystem.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@Configuration @Configuration
@@ -58,29 +48,6 @@ class SaganConfiguration {
@Bean @Bean
RestTemplate saganRestTemplate() { RestTemplate saganRestTemplate() {
return new RestTemplateBuilder().basicAuthentication(properties.key, "").build();
RestTemplate template = new RestTemplate();
template.setInterceptors(Arrays.asList(new AuthenticatingClientHttpRequestInterceptor(properties)));
return template;
}
@RequiredArgsConstructor
private static class AuthenticatingClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
private final @NonNull SaganProperties properties;
/*
* (non-Javadoc)
* @see org.springframework.http.client.ClientHttpRequestInterceptor#intercept(org.springframework.http.HttpRequest, byte[], org.springframework.http.client.ClientHttpRequestExecution)
*/
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
request.getHeaders().add(HttpHeaders.AUTHORIZATION, properties.getCredentials().toString());
return execution.execute(request, body);
}
} }
} }

View File

@@ -1,25 +1,21 @@
spring.main.banner-mode=off
io.work-dir=~/temp/spring-data-shell/workspace io.work-dir=~/temp/spring-data-shell/workspace
io.logs=logs io.logs=logs
# Maven setup # Maven setup
maven.local-repository=~/temp/spring-data-shell/repository maven.local-repository=~/temp/spring-data-shell/repository
maven.plugins.versions=org.codehaus.mojo:versions-maven-plugin:2.2 maven.plugins.versions=org.codehaus.mojo:versions-maven-plugin:2.2
maven.console-logger=true maven.console-logger=true
deployment.server.uri=https://repo.spring.io deployment.server.uri=https://repo.spring.io
deployment.staging-repository=libs-staging-local deployment.staging-repository=libs-staging-local
deployment.distribution-repository=temp-private-local deployment.distribution-repository=temp-private-local
deployment.username=buildmaster deployment.username=buildmaster
#deployment.password <- local #deployment.password <- local
# GPG setup # GPG setup
deployment.gpg.executable=/usr/local/bin/gpg2 deployment.gpg.executable=/usr/local/bin/gpg2
# deployment.gpg.keyname # deployment.gpg.keyname
# deployment.gpg.password # deployment.gpg.password
# JIRA # JIRA
jira.api-url=https://jira.spring.io jira.api-url=https://jira.spring.io
# GitHub # GitHub
github.api-url=https://api.github.com github.api-url=https://api.github.com
logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(%-20.20logger{19}){cyan}%clr(:){faint} %m%n%wEx logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(%-20.20logger{19}){cyan}%clr(:){faint} %m%n%wEx

View File

@@ -15,7 +15,6 @@
*/ */
package org.springframework.data.release.deployment; package org.springframework.data.release.deployment;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.junit.Test; import org.junit.Test;
@@ -45,7 +44,7 @@ public class DeploymentOperationsUnitTests {
operations.promote(information); operations.promote(information);
verify(logger).log(eq(module), any()); verify(logger).log(eq(module), anyString());
verifyZeroInteractions(client); verifyNoInteractions(client);
} }
} }

View File

@@ -148,7 +148,7 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
github.createReleaseVersion(BUILD_HOPPER_RC1); github.createReleaseVersion(BUILD_HOPPER_RC1);
verify(postRequestedFor(urlPathMatching(MILESTONES_URI)).withRequestBody( verify(postRequestedFor(urlPathMatching(MILESTONES_URI)).withRequestBody(
equalToJson("{\"title\":\"1.8 RC1 (Hopper)\", \"description\":\"Hopper RC1\",\"open\":false}"))); equalToJson("{\"title\":\"1.8 RC1 (Hopper)\", \"description\":\"Hopper RC1\"}")));
} }
/** /**