Polishing.
Improve command logging. Refine Git operations on dependency upgrade. See #209
This commit is contained in:
@@ -98,7 +98,7 @@ class MavenRuntime {
|
|||||||
|
|
||||||
File javaHome = getJavaHome();
|
File javaHome = getJavaHome();
|
||||||
mavenLogger.info(String.format("Java Home: %s", jdk));
|
mavenLogger.info(String.format("Java Home: %s", jdk));
|
||||||
mavenLogger.info(String.format("Executing mvn %s", arguments));
|
mavenLogger.info(String.format("Executing: mvn %s", arguments));
|
||||||
|
|
||||||
InvocationRequest request = new DefaultInvocationRequest();
|
InvocationRequest request = new DefaultInvocationRequest();
|
||||||
request.setJavaHome(javaHome);
|
request.setJavaHome(javaHome);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class DependencyCommands extends TimedCommand {
|
|||||||
public void check(@CliOption(key = "", mandatory = true) TrainIteration iteration,
|
public void check(@CliOption(key = "", mandatory = true) TrainIteration iteration,
|
||||||
@CliOption(key = "all", mandatory = false) Boolean reportAll) throws IOException {
|
@CliOption(key = "all", mandatory = false) Boolean reportAll) throws IOException {
|
||||||
|
|
||||||
git.checkout(iteration.getTrain());
|
git.prepare(iteration);
|
||||||
|
|
||||||
checkBuildDependencies(iteration, reportAll != null ? reportAll : false);
|
checkBuildDependencies(iteration, reportAll != null ? reportAll : false);
|
||||||
checkModuleDependencies(iteration, reportAll != null ? reportAll : false);
|
checkModuleDependencies(iteration, reportAll != null ? reportAll : false);
|
||||||
@@ -77,7 +77,7 @@ public class DependencyCommands extends TimedCommand {
|
|||||||
@CliCommand(value = "dependency report")
|
@CliCommand(value = "dependency report")
|
||||||
public String report(@CliOption(key = "", mandatory = true) TrainIteration iteration) {
|
public String report(@CliOption(key = "", mandatory = true) TrainIteration iteration) {
|
||||||
|
|
||||||
git.checkout(iteration.getTrain());
|
git.prepare(iteration);
|
||||||
|
|
||||||
List<Project> projects = Projects.all().stream()
|
List<Project> projects = Projects.all().stream()
|
||||||
.filter(it -> it != Projects.BOM && it != Projects.BUILD && it != Projects.COMMONS)
|
.filter(it -> it != Projects.BOM && it != Projects.BUILD && it != Projects.COMMONS)
|
||||||
@@ -113,8 +113,6 @@ public class DependencyCommands extends TimedCommand {
|
|||||||
ModuleIteration module = iteration.getModule(Projects.BUILD);
|
ModuleIteration module = iteration.getModule(Projects.BUILD);
|
||||||
DependencyVersions dependencyVersions = loadDependencyUpgrades(module);
|
DependencyVersions dependencyVersions = loadDependencyUpgrades(module);
|
||||||
|
|
||||||
git.checkout(iteration.getTrain(), false);
|
|
||||||
|
|
||||||
DependencyVersions upgradesToApply = operations.getDependencyUpgradesToApply(module.getProject(),
|
DependencyVersions upgradesToApply = operations.getDependencyUpgradesToApply(module.getProject(),
|
||||||
dependencyVersions);
|
dependencyVersions);
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,11 @@ import org.springframework.data.release.model.TrainIteration;
|
|||||||
import org.springframework.data.release.utils.ExecutionUtils;
|
import org.springframework.data.release.utils.ExecutionUtils;
|
||||||
import org.springframework.data.release.utils.Logger;
|
import org.springframework.data.release.utils.Logger;
|
||||||
import org.springframework.data.util.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestOperations;
|
import org.springframework.web.client.RestOperations;
|
||||||
|
|
||||||
import org.xmlbeam.ProjectionFactory;
|
import org.xmlbeam.ProjectionFactory;
|
||||||
@@ -424,8 +426,7 @@ public class DependencyOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<DependencyVersion> findLatestMinor(DependencyUpgradePolicy policy,
|
private static Optional<DependencyVersion> findLatestMinor(DependencyUpgradePolicy policy,
|
||||||
DependencyVersion currentVersion,
|
DependencyVersion currentVersion, List<DependencyVersion> availableVersions) {
|
||||||
List<DependencyVersion> availableVersions) {
|
|
||||||
|
|
||||||
return availableVersions.stream().filter(it -> {
|
return availableVersions.stream().filter(it -> {
|
||||||
|
|
||||||
@@ -498,14 +499,13 @@ public class DependencyOperations {
|
|||||||
String baseUrl = String.format("https://repo1.maven.org/maven2/%s/%s/", dependency.getGroupId().replace('.', '/'),
|
String baseUrl = String.format("https://repo1.maven.org/maven2/%s/%s/", dependency.getGroupId().replace('.', '/'),
|
||||||
dependency.getArtifactId());
|
dependency.getArtifactId());
|
||||||
|
|
||||||
ResponseEntity<byte[]> mavenMetadata = restOperations.getForEntity(baseUrl + "/maven-metadata.xml", byte[].class);
|
|
||||||
ResponseEntity<String> directoryListing = restOperations.getForEntity(baseUrl, String.class);
|
|
||||||
|
|
||||||
Map<String, LocalDateTime> creationDates = parseCreationDates(directoryListing.getBody());
|
|
||||||
|
|
||||||
XBStreamInput io = projectionFactory.io().stream(new ByteArrayInputStream(mavenMetadata.getBody()));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ResponseEntity<byte[]> mavenMetadata = restOperations.getForEntity(baseUrl + "/maven-metadata.xml", byte[].class);
|
||||||
|
ResponseEntity<String> directoryListing = restOperations.getForEntity(baseUrl, String.class);
|
||||||
|
|
||||||
|
Map<String, LocalDateTime> creationDates = parseCreationDates(directoryListing.getBody());
|
||||||
|
|
||||||
|
XBStreamInput io = projectionFactory.io().stream(new ByteArrayInputStream(mavenMetadata.getBody()));
|
||||||
|
|
||||||
MavenMetadata metadata = io.read(MavenMetadata.class);
|
MavenMetadata metadata = io.read(MavenMetadata.class);
|
||||||
|
|
||||||
@@ -528,6 +528,13 @@ public class DependencyOperations {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
} catch (Exception o_O) {
|
} catch (Exception o_O) {
|
||||||
|
|
||||||
|
if (o_O instanceof HttpClientErrorException) {
|
||||||
|
if (((HttpClientErrorException) o_O).getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new RuntimeException(String.format("Cannot determine available versions for %s", dependency), o_O);
|
throw new RuntimeException(String.format("Cannot determine available versions for %s", dependency), o_O);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user