#159 - Remove Spring Framework/Reactor from dependency upgrade process.

Also, consider groupId when resolving dependencies to avoid artifactId clashes.
This commit is contained in:
Mark Paluch
2020-12-07 11:03:21 +01:00
parent 13ba67268c
commit 724d3797be
7 changed files with 27 additions and 25 deletions

View File

@@ -54,8 +54,6 @@ public class Dependencies {
public static final Dependency QUERYDSL = Dependency.of("Querydsl", "com.querydsl:querydsl-jpa");
public static final Dependency PROJECT_REACTOR = Dependency.of("Project Reactor", "io.projectreactor:reactor-bom");
public static final Dependency RXJAVA1 = Dependency.of("RxJava", "io.reactivex:rxjava");
public static final Dependency RXJAVA2 = Dependency.of("RxJava", "io.reactivex.rxjava2:rxjava");
@@ -65,9 +63,6 @@ public class Dependencies {
public static final Dependency RXJAVA_RS = Dependency.of("RxJava Reactive Streams",
"io.reactivex:rxjava-reactive-streams");
public static final Dependency SPRING_FRAMEWORK = Dependency.of("Spring Framework",
"org.springframework:spring-core");
public static final Dependency SPRING_HATEOAS = Dependency.of("Spring Hateoas",
"org.springframework.hateoas:spring-hateoas");
@@ -136,9 +131,10 @@ public class Dependencies {
.orElseThrow(() -> new IllegalArgumentException(String.format("No such dependency: %s", name)));
}
public static Dependency getRequiredByArtifactId(String artifactId) {
public static Dependency getRequiredDepependency(String groupId, String artifactId) {
return dependencies.stream().filter(it -> it.getArtifactId().equals(artifactId)).findFirst()
return dependencies.stream().filter(it -> it.getGroupId().equals(groupId) && it.getArtifactId().equals(artifactId))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(String.format("No such dependency: %s", artifactId)));
}

View File

@@ -98,7 +98,8 @@ public class DependencyOperations {
DependencyVersion currentVersion = currentDependencies.get(dependency);
List<DependencyVersion> versions = getAvailableVersions(dependency);
DependencyUpgradeProposal proposal = getDependencyUpgradeProposal(iteration, currentVersion, versions);
DependencyUpgradeProposal proposal = getDependencyUpgradeProposal(iteration, dependency, currentVersion,
versions);
proposals.put(dependency, proposal);
});
@@ -223,9 +224,9 @@ public class DependencyOperations {
}
protected static DependencyUpgradeProposal getDependencyUpgradeProposal(Iteration iteration,
DependencyVersion currentVersion, List<DependencyVersion> allVersions) {
Dependency dependency, DependencyVersion currentVersion, List<DependencyVersion> allVersions) {
DependencyVersion latestMinor = findLatestMinor(iteration, currentVersion, allVersions);
DependencyVersion latestMinor = findLatestMinor(iteration, dependency, currentVersion, allVersions);
DependencyVersion latest = findLatest(iteration, allVersions);
List<DependencyVersion> newerVersions = allVersions.stream() //
.sorted() //
@@ -249,7 +250,8 @@ public class DependencyOperations {
() -> new IllegalArgumentException("Cannot determine new latest version from " + availableVersions));
}
private static DependencyVersion findLatestMinor(Iteration iteration, DependencyVersion currentVersion,
private static DependencyVersion findLatestMinor(Iteration iteration, Dependency dependency,
DependencyVersion currentVersion,
List<DependencyVersion> availableVersions) {
return availableVersions.stream().filter(it -> {
@@ -275,7 +277,9 @@ public class DependencyOperations {
}) //
.max(DependencyVersion::compareTo) //
.orElseThrow(
() -> new IllegalArgumentException("Cannot determine new minor version from " + availableVersions));
() -> new IllegalArgumentException(String.format(
"Cannot determine new minor version from %s for %s (%s). Current version: %s", availableVersions,
dependency.getName(), dependency.getArtifactId(), currentVersion.getIdentifier())));
}
DependencyVersions getCurrentDependencies(Project project) {
@@ -296,7 +300,7 @@ public class DependencyOperations {
Dependency dependency = projectDependency.getDependency();
if (!((project == Projects.MONGO_DB && projectDependency.getProperty().equals("mongo.reactivestreams"))
|| project == Projects.NEO4J)) {
|| project == Projects.NEO4J || project == Projects.BUILD)) {
if (it.getDependencyVersion(dependency.getArtifactId()) == null
&& it.getManagedDependency(dependency.getArtifactId()) == null) {

View File

@@ -162,8 +162,9 @@ public class DependencyUpgradeProposals {
throw new IllegalArgumentException(String.format("Unexpected key: %s", k));
}
String groupId = matcher.group(1);
String artifactId = matcher.group(2);
Dependency dependency = Dependencies.getRequiredByArtifactId(artifactId);
Dependency dependency = Dependencies.getRequiredDepependency(groupId, artifactId);
result.put(dependency, DependencyVersion.of(v.toString()));

View File

@@ -48,13 +48,12 @@ public class ProjectDependencies implements Streamable<ProjectDependencies.Proje
config.add(Projects.BUILD, ProjectDependency.ofProperty("kotlin", Dependencies.KOTLIN));
config.add(Projects.BUILD, ProjectDependency.ofProperty("kotlin-coroutines", Dependencies.KOTLIN_COROUTINES));
config.add(Projects.BUILD, ProjectDependency.ofProperty("mockito", Dependencies.MOCKITO));
config.add(Projects.BUILD, ProjectDependency.ofProperty("mockk", Dependencies.MOCKK));
config.add(Projects.BUILD, ProjectDependency.ofProperty("querydsl", Dependencies.QUERYDSL));
config.add(Projects.BUILD, ProjectDependency.ofProperty("reactor", Dependencies.PROJECT_REACTOR));
config.add(Projects.BUILD, ProjectDependency.ofProperty("rxjava", Dependencies.RXJAVA1));
config.add(Projects.BUILD, ProjectDependency.ofProperty("rxjava2", Dependencies.RXJAVA2));
config.add(Projects.BUILD, ProjectDependency.ofProperty("rxjava3", Dependencies.RXJAVA3));
config.add(Projects.BUILD, ProjectDependency.ofProperty("rxjava-reactive-streams", Dependencies.RXJAVA_RS));
config.add(Projects.BUILD, ProjectDependency.ofProperty("spring", Dependencies.SPRING_FRAMEWORK));
config.add(Projects.BUILD, ProjectDependency.ofProperty("spring-hateoas", Dependencies.SPRING_HATEOAS));
config.add(Projects.BUILD, ProjectDependency.ofProperty("spring-plugin", Dependencies.SPRING_PLUGIN));
config.add(Projects.BUILD, ProjectDependency.ofProperty("testcontainers", Dependencies.TESTCONTAINERS));

View File

@@ -64,7 +64,7 @@ class DependencyOperationsIntegrationTests extends AbstractIntegrationTests {
@Test
void shouldDiscoverDependencyVersions() {
assertThat(operations.getAvailableVersions(Dependencies.PROJECT_REACTOR)).isNotEmpty();
assertThat(operations.getAvailableVersions(Dependencies.SPRING_HATEOAS)).isNotEmpty();
}
@Test

View File

@@ -41,7 +41,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.SR1,
DependencyVersion.of("5.7.0"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.0"), availableVersions);
assertThat(proposal.getCurrent()).isEqualTo(DependencyVersion.of("5.7.0"));
assertThat(proposal.getLatestMinor()).isEqualTo(DependencyVersion.of("5.7.0"));
@@ -58,7 +58,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.SR1,
DependencyVersion.of("5.7.0"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.0"), availableVersions);
assertThat(proposal.getCurrent()).isEqualTo(DependencyVersion.of("5.7.0"));
assertThat(proposal.getLatestMinor()).isEqualTo(DependencyVersion.of("5.7.1"));
@@ -75,7 +75,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.M1,
DependencyVersion.of("5.7.0"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.0"), availableVersions);
assertThat(proposal.getCurrent()).isEqualTo(DependencyVersion.of("5.7.0"));
assertThat(proposal.getLatestMinor()).isEqualTo(DependencyVersion.of("5.7.1"));
@@ -92,7 +92,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.SR1,
DependencyVersion.of("5.7.1"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.1"), availableVersions);
assertThat(proposal.getNewerVersions()).extracting(DependencyVersion::getIdentifier).containsExactly("5.7.2-M2",
"5.7.2", "5.8.0");
@@ -107,7 +107,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.M1,
DependencyVersion.of("5.7.1"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.1"), availableVersions);
assertThat(proposal.getLatest()).extracting(DependencyVersion::getIdentifier).isEqualTo("5.7.2-M2");
assertThat(proposal.getProposal()).extracting(DependencyVersion::getIdentifier).isEqualTo("5.7.2-M2");
@@ -123,7 +123,7 @@ class DependencyOperationsUnitTests {
.collect(Collectors.toList());
DependencyUpgradeProposal proposal = DependencyOperations.getDependencyUpgradeProposal(Iteration.RC1,
DependencyVersion.of("5.7.1"), availableVersions);
Dependencies.JUNIT5, DependencyVersion.of("5.7.1"), availableVersions);
assertThat(proposal.getLatest()).extracting(DependencyVersion::getIdentifier).isEqualTo("5.7.1");
assertThat(proposal.getProposal()).extracting(DependencyVersion::getIdentifier).isEqualTo("5.7.1");

View File

@@ -38,11 +38,13 @@ class DependencyUpgradeProposalsUnitTests {
properties.put("dependency.train", "Pascal");
properties.put("dependency.iteration", "M1");
properties.put("dependency[org.assertj:assertj-core]", "3.18.1");
properties.put("dependency[io.reactivex.rxjava3:rxjava]", "1.2.3");
DependencyVersions dependencies = DependencyUpgradeProposals
.fromProperties(ReleaseTrains.PASCAL.getIteration(Iteration.M1), properties);
assertThat(dependencies.getVersions()).hasSize(1).containsEntry(Dependencies.ASSERTJ,
DependencyVersion.of("3.18.1"));
assertThat(dependencies.getVersions()).hasSize(2)
.containsEntry(Dependencies.ASSERTJ, DependencyVersion.of("3.18.1"))
.containsEntry(Dependencies.RXJAVA3, DependencyVersion.of("1.2.3"));
}
}