use of com.microsoft.azure.toolkit.intellij.springcloud.dependency.DependencyArtifact in project azure-tools-for-java by Microsoft.
the class SpringCloudDependencyManager method getCompatibleVersions.
public static List<DependencyArtifact> getCompatibleVersions(List<DependencyArtifact> dependencies, String springBootVersionStr) throws AzureExecutionException, IOException, DocumentException {
List<DependencyArtifact> res = new ArrayList<>();
DefaultArtifactVersion springBootVersion = new DefaultArtifactVersion(springBootVersionStr);
for (DependencyArtifact dependency : dependencies) {
if (StringUtils.isNotEmpty(dependency.getCurrentVersion()) && isCompatibleVersion(dependency.getCurrentVersion(), springBootVersionStr)) {
continue;
}
List<String> latestVersions = getMavenCentralVersions(dependency.getGroupId(), dependency.getArtifactId());
String targetVersionText = getCompatibleVersionWithBootVersion(latestVersions, springBootVersion);
if (StringUtils.isEmpty(targetVersionText)) {
if (isGreaterOrEqualVersion(springBootVersionStr, LATEST_SPRING_BOOT_RELEASE) && !latestVersions.isEmpty()) {
// to handle the ege case: spring-cloud-starter-config 2.2.5.RELEASE supports spring boot 2.3.0
// here for newest spring boot versions, use the latest versions
targetVersionText = latestVersions.get(latestVersions.size() - 1);
} else {
throw new AzureExecutionException(String.format("Cannot get compatible version for %s:%s with Spring Boot with version %s", dependency.getGroupId(), dependency.getArtifactId(), springBootVersionStr));
}
}
dependency.setCompatibleVersion(targetVersionText);
if (!StringUtils.equals(dependency.getCurrentVersion(), targetVersionText)) {
res.add(dependency);
}
}
return res;
}
use of com.microsoft.azure.toolkit.intellij.springcloud.dependency.DependencyArtifact in project azure-tools-for-java by Microsoft.
the class SpringCloudDependencyManager method collectDependencyVersionsFromNodes.
private static void collectDependencyVersionsFromNodes(List<Node> nodes, Map<String, DependencyArtifact> versionMap) {
for (Node node : nodes) {
String groupId = ((Element) node).elementTextTrim("groupId");
String artifactId = ((Element) node).elementTextTrim("artifactId");
DependencyArtifact artifact = new DependencyArtifact(groupId, artifactId, ((Element) node).elementTextTrim("version"));
versionMap.put(artifact.getKey(), artifact);
}
}
Aggregations