Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public Object execute(ParseResult parseResult) throws RuntimeException {
synchronized (mutex) {
Assert.isTrue(isReadyForCommands(), "SimpleExecutionStrategy not yet ready for commands");
Object target = parseResult.getInstance();
if (target instanceof ExecutionProcessor) {
ExecutionProcessor processor = ((ExecutionProcessor) target);
if (target instanceof ExecutionProcessor executionProcessor) {
ExecutionProcessor processor = executionProcessor;
parseResult = processor.beforeInvocation(parseResult);
try {
Object result = invoke(parseResult);
Expand Down Expand Up @@ -94,11 +94,11 @@ private Object invoke(ParseResult parseResult) {
}

private Object handleThrowable(Throwable th) {
if (th instanceof Error) {
throw ((Error) th);
if (th instanceof Error error) {
throw error;
}
if (th instanceof RuntimeException) {
throw ((RuntimeException) th);
if (th instanceof RuntimeException exception) {
throw exception;
}
throw new RuntimeException(th);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void build(@CliOption(key = "", mandatory = true) TrainIteration iteratio

project.ifPresent(it -> build.triggerBuild(iteration.getModule(it)));

if (!project.isPresent()) {
if (project.isEmpty()) {
build.build(iteration);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ public <M extends ProjectAware> M triggerDistributionBuild(M module) {
return module;
}

DefaultDeploymentInformation deploymentInformation = module instanceof ModuleIteration
? new DefaultDeploymentInformation((ModuleIteration) module, properties)
DefaultDeploymentInformation deploymentInformation = module instanceof ModuleIteration mi
? new DefaultDeploymentInformation(mi, properties)
: null;

logger.log(project, "Triggering distribution build…");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public MavenInvocationResult execute(SupportedProject project, CommandLine argum

return invocationResult;
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
if (e instanceof RuntimeException exception) {
throw exception;
}
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,24 @@ public void distributeRelease(TrainIteration train, String releaseName, String v

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
String body = "{\n" + "\t\"auto_create_missing_repositories\": \"false\",\n" + "\t\"distribution_rules\": [\n"
+ "\t\t{\n" + "\t\t\t\"site_name\": \"JP-SaaS\"\n" + "\t\t}\n" + "\t],\n" + "\t\"modifications\": {\n"
+ "\t\t\"mappings\": [\n" + "\t\t\t{\n" + "\t\t\t\t\"input\": \"spring-enterprise-maven-prod-local/(.*)\",\n"
+ "\t\t\t\t\"output\": \"spring-enterprise/$1\"\n" + "\t\t\t}\n" + "\t\t]\n" + "\t}\n" + "}";
String body = """
{
"auto_create_missing_repositories": "false",
"distribution_rules": [
{
"site_name": "JP-SaaS"
}
],
"modifications": {
"mappings": [
{
"input": "spring-enterprise-maven-prod-local/(.*)",
"output": "spring-enterprise/$1"
}
]
}
}\
""";
HttpEntity<String> entity = new HttpEntity<>(body, headers);

Map<String, Object> parameters = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Table checkLinks(@CliOption(key = "", mandatory = true) TrainIteration it
return path.map(it -> operations.checkDocumentation(module.getProject(), it));
});

return render(optionals.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()),
return render(optionals.stream().flatMap(Optional::stream).collect(Collectors.toList()),
options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private Branch getBranch(Train train, org.springframework.data.release.model.Mod
ModuleIteration gaIteration = train.getModuleIteration(project.getProject(), Iteration.GA);
Optional<Tag> gaTag = findTagFor(project, ArtifactVersion.of(gaIteration));

if (!gaTag.isPresent()) {
if (gaTag.isEmpty()) {
logger.log(project, "Checking out main branch as no GA release tag could be found!");
}

Expand Down Expand Up @@ -611,7 +611,7 @@ protected ObjectId resolveLowerBoundary(SupportStatus supportStatus, Project pro

Optional<Tag> fromTag = tags.filter(iteration.getTrain()).findTag(it);

if (!fromTag.isPresent()) {
if (fromTag.isEmpty()) {

// commercial releases might not have a previous tag as commercial releases are seeded without OSS tags.
if (supportStatus == SupportStatus.COMMERCIAL && (it.isServiceIteration() || it.isGAIteration())) {
Expand Down Expand Up @@ -1020,7 +1020,7 @@ public void removeTags(TrainIteration iteration) {

Optional<Tag> tag = findTagFor(project, artifactVersion);

if (!tag.isPresent()) {
if (tag.isEmpty()) {
logger.log(module, "No tag %s found project %s, skipping.", artifactVersion, project);
return;
}
Expand Down Expand Up @@ -1335,8 +1335,8 @@ public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCreden
}

for (CredentialItem item : items) {
if (item instanceof CharArrayType) {
((CharArrayType) item).setValueNoCopy(gpg.getPassphrase().toString().toCharArray());
if (item instanceof CharArrayType type) {
type.setValueNoCopy(gpg.getPassphrase().toString().toCharArray());

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ Map<Tag, TrainIteration> withIterations() {
for (Tag tag : tags) {

Optional<ArtifactVersion> artifactVersion = tag.getArtifactVersion();
if (!artifactVersion.isPresent()) {
if (artifactVersion.isEmpty()) {
continue;
}

ArtifactVersion version = artifactVersion.get();
Optional<Iteration> iteration = toIteration(version);

if (!iteration.isPresent()) {
if (iteration.isEmpty()) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -139,7 +139,7 @@ public void upgrade(@CliOption(key = "", mandatory = true) TrainIteration iterat

private DependencyVersions loadDependencyUpgrades(ModuleIteration iteration) throws IOException {

if (!Files.exists(Paths.get(BUILD_PROPERTIES))) {
if (!Files.exists(Path.of(BUILD_PROPERTIES))) {
logger.log(iteration, "Cannot upgrade dependencies: " + BUILD_PROPERTIES + " does not exist.");
}

Expand Down Expand Up @@ -168,7 +168,7 @@ private void checkModuleDependencies(TrainIteration iteration, boolean reportAll
proposals = proposals.mergeWith(operations.getDependencyUpgradeProposals(project, iteration.getIteration()));
}

Files.write(Paths.get(propertiesFile), proposals.asProperties(iteration).getBytes());
Files.write(Path.of(propertiesFile), proposals.asProperties(iteration).getBytes());

Table summary = proposals.toTable(reportAll);

Expand All @@ -188,7 +188,7 @@ private void checkBuildDependencies(TrainIteration iteration, boolean reportAll,
SupportedProject project = iteration.getSupportedProject(Projects.BUILD);
DependencyUpgradeProposals proposals = operations.getDependencyUpgradeProposals(project, iteration.getIteration());

Files.write(Paths.get(propertiesFile), proposals.asProperties(iteration).getBytes());
Files.write(Path.of(propertiesFile), proposals.asProperties(iteration).getBytes());

Table summary = proposals.toTable(reportAll);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ List<DependencyVersion> getAvailableVersions(Dependency dependency) {

} catch (Exception o_O) {

if (o_O instanceof HttpClientErrorException) {
if (((HttpClientErrorException) o_O).getStatusCode() == HttpStatus.NOT_FOUND) {
if (o_O instanceof HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Collections.emptyList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.List;

import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -79,7 +79,7 @@ public void check(@CliOption(key = "", mandatory = true) TrainIteration iteratio

DependencyUpgradeProposals proposals = operations.getMavenWrapperDependencyUpgradeProposals(iteration);

Files.write(Paths.get(InfrastructureOperations.MAVEN_PROPERTIES), proposals.asProperties(iteration).getBytes());
Files.write(Path.of(InfrastructureOperations.MAVEN_PROPERTIES), proposals.asProperties(iteration).getBytes());

Table summary = proposals.toTable(reportAll == null ? false : reportAll);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -160,7 +160,7 @@ public void upgradeMavenVersion(TrainIteration iteration) {
@SneakyThrows
private DependencyVersions loadDependencyUpgrades(TrainIteration iteration) {

if (!Files.exists(Paths.get(MAVEN_PROPERTIES))) {
if (!Files.exists(Path.of(MAVEN_PROPERTIES))) {
logger.log(iteration, "Cannot upgrade dependencies: " + MAVEN_PROPERTIES + " does not exist.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ private Stream<GitHubReadIssue> getIssuesFor(ModuleIteration moduleIteration, bo

Optional<Milestone> optionalMilestone = findMilestone(moduleIteration);

if (ignoreMissingMilestone && !optionalMilestone.isPresent()) {
if (ignoreMissingMilestone && optionalMilestone.isEmpty()) {
return Stream.empty();
}

Expand Down