Revise project dependencies.

Also introduce flag how the dependency is used/references whether to check for dependency/dependencyManagement instead of maintaining a list of exclusions.

Closes #107
This commit is contained in:
Mark Paluch
2025-04-17 09:50:07 +02:00
parent 152a1190db
commit 31745c6732
3 changed files with 110 additions and 83 deletions

View File

@@ -28,12 +28,16 @@ public class Dependencies {
static final List<Dependency> dependencies = new ArrayList<>();
public static final Dependency ANTLR = Dependency.of("ANTLR", "org.antlr:antlr4-runtime");
public static final Dependency APT = Dependency.of("APT", "com.mysema.maven:apt-maven-plugin");
public static final Dependency ASPECTJ = Dependency.of("AspectJ", "org.aspectj:aspectjrt");
public static final Dependency ASSERTJ = Dependency.of("AssertJ", "org.assertj:assertj-core");
public static final Dependency AWAITILITY = Dependency.of("Awaitility", "org.awaitility:awaitility");
public static final Dependency JACKSON = Dependency.of("Jackson", "com.fasterxml.jackson:jackson-bom");
public static final Dependency JACOCO = Dependency.of("Jacoco", "org.jacoco:jacoco");
@@ -94,32 +98,22 @@ public class Dependencies {
public static final Dependency MONGODB_CORE = Dependency.of("MongoDB", "org.mongodb:mongodb-driver-core");
public static final Dependency MONGODB_LEGACY = Dependency.of("MongoDB", "org.mongodb:mongo-java-driver");
public static final Dependency MONGODB_SYNC = Dependency.of("MongoDB", "org.mongodb:mongodb-driver-sync");
public static final Dependency MONGODB_ASYNC = Dependency.of("MongoDB", "org.mongodb:mongodb-driver-async");
public static final Dependency MONGODB_RS = Dependency.of("MongoDB Reactive Streams",
"org.mongodb:mongodb-driver-reactivestreams");
public static final Dependency MONGODB_BOM = Dependency.of("MongoDB", "org.mongodb:mongodb-driver-bom");
public static final Dependency LETTUCE = Dependency.of("Lettuce", "io.lettuce:lettuce-core");
public static final Dependency JEDIS = Dependency.of("Jedis", "redis.clients:jedis");
public static final Dependency JSQLPARSER = Dependency.of("JSqlParser", "com.github.jsqlparser:jsqlparser");
public static final Dependency JMOLECULES = Dependency.of("JMolecules", "org.jmolecules:jmolecules");
public static final Dependency JMOLECULES_INTEGRATION = Dependency.of("JMolecules",
"org.jmolecules.integrations:jmolecules-spring");
public static final Dependency CASSANDRA_DRIVER3 = Dependency.of("Cassandra Driver",
"com.datastax.cassandra:cassandra-driver-core");
public static final Dependency CASSANDRA_DRIVER4 = Dependency.of("Cassandra Driver",
"org.apache.cassandra:java-driver-bom");
public static final Dependency NEO4J_OGM = Dependency.of("Neo4j OGM", "org.neo4j:neo4j-ogm-api");
public static final Dependency NEO4J_DRIVER = Dependency.of("Neo4j Driver", "org.neo4j.driver:neo4j-java-driver");
public static final Dependency COUCHBASE = Dependency.of("Couchbase Client", "com.couchbase.client:java-client");
@@ -136,18 +130,33 @@ public class Dependencies {
public static final Dependency MAVEN = Dependency.of("Maven Wrapper", "org.apache.maven:apache-maven");
public static final Dependency H2 = Dependency.of("H2 Database", "com.h2database:h2");
public static final Dependency H2_R2DBC = Dependency.of("H2 R2DBC Driver", "io.r2dbc:r2dbc-h2");
public static final Dependency HSQLDB = Dependency.of("HSQL Database", "org.hsqldb:hsqldb");
public static final Dependency DB2_JDBC = Dependency.of("DB2 JDBC Driver", "com.ibm.db2:jcc");
public static final Dependency MARIADB_JDBC = Dependency.of("MariaDB JDBC Driver", "org.mariadb.jdbc:mariadb-java-client");
public static final Dependency MARIADB_R2DBC = Dependency.of("MariaDB R2DBC Driver", "rg.mariadb:r2dbc-mariadb");
public static final Dependency MS_SQLSERVER_JDBC = Dependency.of("Microsoft SqlServer JDBC Driver", "com.microsoft.sqlserver:mssql-jdbc");
public static final Dependency MS_SQLSERVER_R2DBC = Dependency.of("Microsoft SqlServer R2DBC Driver", "io.r2dbc:r2dbc-mssql");
public static final Dependency MYSQL_JDBC = Dependency.of("MySql JDBC Driver", "mysql:mysql-connector-java");
public static final Dependency LEGACY_MYSQL_JDBC = Dependency.of("MySql JDBC Driver", "mysql:mysql-connector-java");
public static final Dependency MYSQL_JDBC = Dependency.of("MySql JDBC Driver", "com.mysql:mysql-connector-j");
public static final Dependency MYSQL_R2DBC = Dependency.of("MySql R2DBC Driver", "io.asyncer:r2dbc-mysql");
public static final Dependency POSTGRES_JDBC = Dependency.of("Postgres JDBC Driver", "org.postgresql:postgresql");
public static final Dependency POSTGRES_R2DBC = Dependency.of("Postgres R2DBC Driver", "org.postgresql:r2dbc-postgresql");
public static final Dependency ORACLE_JDBC = Dependency.of("Oracle JDBC Driver", "com.oracle.database.jdbc:ojdbc11");
public static final Dependency ORACLE_R2DBC = Dependency.of("Oracle R2DBC Driver", "com.oracle.database.r2dbc:oracle-r2dbc");
static {

View File

@@ -29,7 +29,6 @@ import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -69,6 +68,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestOperations;
import org.xmlbeam.ProjectionFactory;
import org.xmlbeam.annotation.XBRead;
import org.xmlbeam.io.FileIO;
@@ -376,7 +376,7 @@ public class DependencyOperations {
return Optional.ofNullable(upgradeTickets.isEmpty() ? null : upgradeTickets.get(0));
}
protected static DependencyUpgradeProposal getDependencyUpgradeProposal(DependencyUpgradePolicy policy,
static DependencyUpgradeProposal getDependencyUpgradeProposal(DependencyUpgradePolicy policy,
DependencyVersion currentVersion, List<DependencyVersion> allVersions) {
Optional<DependencyVersion> latestMinor = findLatestMinor(policy, currentVersion, allVersions);
@@ -472,7 +472,7 @@ public class DependencyOperations {
ProjectDependencies dependencies = ProjectDependencies.get(supportedProject);
Set<Project> skipDependencyDeclarationCheck = new HashSet<>(
Arrays.asList(Projects.NEO4J, Projects.BUILD, Projects.JPA, Projects.RELATIONAL));
Collections.singletonList(Projects.BUILD));
return doWithPom(pom, Pom.class, it -> {
@@ -482,8 +482,7 @@ public class DependencyOperations {
Dependency dependency = projectDependency.getDependency();
if (!(project == Projects.MONGO_DB && projectDependency.getProperty().equals("mongo.reactivestreams")
|| skipDependencyDeclarationCheck.contains(project))) {
if (!skipDependencyDeclarationCheck.contains(project) && projectDependency.isVerifyUsage()) {
if (it.getDependencyVersion(dependency.getArtifactId()) == null
&& it.getManagedDependency(dependency.getArtifactId()) == null) {

View File

@@ -39,83 +39,96 @@ public class ProjectDependencies implements Streamable<ProjectDependencies.Proje
static {
config.add(Projects.BUILD, ProjectDependency.ofProperty("apt", Dependencies.APT));
config.add(Projects.BUILD, ProjectDependency.ofProperty("aspectj", Dependencies.ASPECTJ));
config.add(Projects.BUILD, ProjectDependency.ofProperty("assertj", Dependencies.ASSERTJ));
config.add(Projects.BUILD, ProjectDependency.ofProperty("jackson", Dependencies.JACKSON));
config.add(Projects.BUILD, ProjectDependency.ofProperty("jacoco", Dependencies.JACOCO));
config.add(Projects.BUILD, ProjectDependency.ofProperty("jodatime", Dependencies.JODA_TIME));
config.add(Projects.BUILD, ProjectDependency.ofProperty("junit5", Dependencies.JUNIT5));
config.add(Projects.BUILD, ProjectDependency.ofProperty("jmolecules", Dependencies.JMOLECULES));
config.add(Projects.BUILD, ProjectDependency.using("apt", Dependencies.APT));
config.add(Projects.BUILD, ProjectDependency.using("aspectj", Dependencies.ASPECTJ));
config.add(Projects.BUILD, ProjectDependency.using("assertj", Dependencies.ASSERTJ));
config.add(Projects.BUILD, ProjectDependency.using("jackson", Dependencies.JACKSON));
config.add(Projects.BUILD, ProjectDependency.using("jacoco", Dependencies.JACOCO));
config.add(Projects.BUILD, ProjectDependency.using("jodatime", Dependencies.JODA_TIME));
config.add(Projects.BUILD, ProjectDependency.using("junit5", Dependencies.JUNIT5));
config.add(Projects.BUILD, ProjectDependency.using("jmolecules", Dependencies.JMOLECULES));
config.add(Projects.BUILD,
ProjectDependency.ofProperty("jmolecules-integration", Dependencies.JMOLECULES_INTEGRATION));
config.add(Projects.BUILD, ProjectDependency.ofProperty("junit", Dependencies.JUNIT4));
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("micrometer", Dependencies.MICROMETER));
config.add(Projects.BUILD, ProjectDependency.ofProperty("micrometer-tracing", Dependencies.MICROMETER_TRACING));
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("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("smallrye-mutiny", Dependencies.SMALLRYE_MUTINY));
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));
config.add(Projects.BUILD, ProjectDependency.ofProperty("threetenbp", Dependencies.THREE_TEN_BP));
config.add(Projects.BUILD, ProjectDependency.ofProperty("webbeans", Dependencies.OPEN_WEB_BEANS));
ProjectDependency.using("jmolecules-integration", Dependencies.JMOLECULES_INTEGRATION));
config.add(Projects.BUILD, ProjectDependency.using("junit", Dependencies.JUNIT4));
config.add(Projects.BUILD, ProjectDependency.using("kotlin", Dependencies.KOTLIN));
config.add(Projects.BUILD, ProjectDependency.using("kotlin-coroutines", Dependencies.KOTLIN_COROUTINES));
config.add(Projects.BUILD, ProjectDependency.using("micrometer", Dependencies.MICROMETER));
config.add(Projects.BUILD, ProjectDependency.using("micrometer-tracing", Dependencies.MICROMETER_TRACING));
config.add(Projects.BUILD, ProjectDependency.using("mockito", Dependencies.MOCKITO));
config.add(Projects.BUILD, ProjectDependency.using("mockk", Dependencies.MOCKK));
config.add(Projects.BUILD, ProjectDependency.using("querydsl", Dependencies.QUERYDSL));
config.add(Projects.BUILD, ProjectDependency.using("rxjava", Dependencies.RXJAVA1));
config.add(Projects.BUILD, ProjectDependency.using("rxjava2", Dependencies.RXJAVA2));
config.add(Projects.BUILD, ProjectDependency.using("rxjava3", Dependencies.RXJAVA3));
config.add(Projects.BUILD, ProjectDependency.using("rxjava-reactive-streams", Dependencies.RXJAVA_RS));
config.add(Projects.BUILD, ProjectDependency.using("smallrye-mutiny", Dependencies.SMALLRYE_MUTINY));
config.add(Projects.BUILD, ProjectDependency.using("spring-hateoas", Dependencies.SPRING_HATEOAS));
config.add(Projects.BUILD, ProjectDependency.using("spring-plugin", Dependencies.SPRING_PLUGIN));
config.add(Projects.BUILD, ProjectDependency.using("testcontainers", Dependencies.TESTCONTAINERS));
config.add(Projects.BUILD, ProjectDependency.using("threetenbp", Dependencies.THREE_TEN_BP));
config.add(Projects.BUILD, ProjectDependency.using("webbeans", Dependencies.OPEN_WEB_BEANS));
config.add(Projects.COMMONS, ProjectDependency.ofProperty("vavr", Dependencies.VAVR));
config.add(Projects.COMMONS, ProjectDependency.ofProperty("xmlbeam", Dependencies.XML_BEAM));
config.add(Projects.COMMONS, ProjectDependency.using("vavr", Dependencies.VAVR));
config.add(Projects.COMMONS, ProjectDependency.using("xmlbeam", Dependencies.XML_BEAM));
config.add(Projects.JPA, ProjectDependency.ofProperty("hibernate", Dependencies.HIBERNATE));
config.add(Projects.JPA, ProjectDependency.ofProperty("eclipselink", Dependencies.ECLIPSELINK));
config.add(Projects.JPA, ProjectDependency.managedProperty("hibernate", Dependencies.HIBERNATE));
config.add(Projects.JPA, ProjectDependency.managedProperty("eclipselink", Dependencies.ECLIPSELINK));
config.add(Projects.JPA, ProjectDependency.managedProperty("jsqlparser", Dependencies.JSQLPARSER));
config.add(Projects.JPA, ProjectDependency.managedProperty("postgresql", Dependencies.POSTGRES_JDBC));
config.add(Projects.JPA, ProjectDependency.managedProperty("mysql-connector-java", Dependencies.MYSQL_JDBC));
config.add(Projects.JPA, ProjectDependency.managedProperty("h2", Dependencies.H2));
config.add(Projects.JPA, ProjectDependency.managedProperty("hsqldb", Dependencies.HSQLDB));
config.add(Projects.JPA, ProjectDependency.managedProperty("antlr", Dependencies.ANTLR));
config.add(Projects.MONGO_DB, ProjectDependency.ofProperty("mongo.reactivestreams", Dependencies.MONGODB_RS));
config.add(Projects.MONGO_DB, ProjectDependency.ofProperty("mongo", Dependencies.MONGODB_LEGACY));
config.add(Projects.MONGO_DB, ProjectDependency.ofProperty("mongo", Dependencies.MONGODB_CORE));
config.add(Projects.MONGO_DB, ProjectDependency.ofProperty("mongo", Dependencies.MONGODB_SYNC));
config.add(Projects.MONGO_DB, ProjectDependency.ofProperty("mongo", Dependencies.MONGODB_ASYNC));
config.add(Projects.MONGO_DB, ProjectDependency.managedProperty("awaitility.version", Dependencies.AWAITILITY));
config.add(Projects.MONGO_DB, ProjectDependency.using("mongo", Dependencies.MONGODB_BOM));
config.add(Projects.MONGO_DB, ProjectDependency.managedProperty("mongo", Dependencies.MONGODB_CORE));
config.add(Projects.REDIS, ProjectDependency.ofProperty("lettuce", Dependencies.LETTUCE));
config.add(Projects.REDIS, ProjectDependency.ofProperty("jedis", Dependencies.JEDIS));
config.add(Projects.REDIS, ProjectDependency.managedProperty("awaitility.version", Dependencies.AWAITILITY));
config.add(Projects.REDIS, ProjectDependency.using("lettuce", Dependencies.LETTUCE));
config.add(Projects.REDIS, ProjectDependency.using("jedis", Dependencies.JEDIS));
config.add(Projects.CASSANDRA,
ProjectDependency.ofProperty("cassandra-driver.version", Dependencies.CASSANDRA_DRIVER3));
config.add(Projects.CASSANDRA,
ProjectDependency.ofProperty("cassandra-driver.version", Dependencies.CASSANDRA_DRIVER4));
ProjectDependency.using("cassandra-driver.version", Dependencies.CASSANDRA_DRIVER4));
config.add(Projects.NEO4J, ProjectDependency.ofProperty("neo4j.ogm.version", Dependencies.NEO4J_OGM));
config.add(Projects.NEO4J, ProjectDependency.ofProperty("neo4j-java-driver.version", Dependencies.NEO4J_DRIVER));
config.add(Projects.NEO4J,
ProjectDependency.managedProperty("neo4j-java-driver.version", Dependencies.NEO4J_DRIVER));
config.add(Projects.COUCHBASE, ProjectDependency.ofProperty("couchbase", Dependencies.COUCHBASE));
config.add(Projects.COUCHBASE, ProjectDependency.using("couchbase", Dependencies.COUCHBASE));
config.add(Projects.ELASTICSEARCH, ProjectDependency.ofProperty("elasticsearch", Dependencies.ELASTICSEARCH_RHLC));
config.add(Projects.ELASTICSEARCH, ProjectDependency.using("elasticsearch", Dependencies.ELASTICSEARCH_RHLC));
config.add(Projects.ELASTICSEARCH,
ProjectDependency.ofProperty("elasticsearch-rhlc", Dependencies.ELASTICSEARCH_RHLC));
ProjectDependency.using("elasticsearch-rhlc", Dependencies.ELASTICSEARCH_RHLC));
config.add(Projects.ELASTICSEARCH,
ProjectDependency.ofProperty("elasticsearch-java", Dependencies.ELASTICSEARCH_REST_CLIENT));
ProjectDependency.using("elasticsearch-java", Dependencies.ELASTICSEARCH_REST_CLIENT));
config.add(Projects.LDAP, ProjectDependency.ofProperty("spring-ldap", Dependencies.SPRING_LDAP));
config.add(Projects.LDAP, ProjectDependency.using("spring-ldap", Dependencies.SPRING_LDAP));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("h2.version", Dependencies.H2));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("hsqldb.version", Dependencies.HSQLDB));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("db2.version", Dependencies.DB2_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("mariadb-java-client.version", Dependencies.MARIADB_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("mssql.version", Dependencies.MS_SQLSERVER_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("mysql-connector-java.version", Dependencies.MYSQL_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("postgresql.version", Dependencies.POSTGRES_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("oracle.version", Dependencies.ORACLE_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("awaitility.version", Dependencies.AWAITILITY));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("h2.version", Dependencies.H2));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("hsqldb.version", Dependencies.HSQLDB));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("db2.version", Dependencies.DB2_JDBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("mariadb-java-client.version", Dependencies.MARIADB_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("mssql.version", Dependencies.MS_SQLSERVER_JDBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("mysql-connector-java.version", Dependencies.MYSQL_JDBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("mysql-connector-java.version", Dependencies.LEGACY_MYSQL_JDBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("postgresql.version", Dependencies.POSTGRES_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("oracle.version", Dependencies.ORACLE_JDBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("r2dbc-postgresql.version", Dependencies.POSTGRES_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("r2dbc-h2.version", Dependencies.H2_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("r2dbc-mariadb.version", Dependencies.MARIADB_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("r2dbc-mssql.version", Dependencies.MS_SQLSERVER_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("r2dbc-mysql.version", Dependencies.MYSQL_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.ofProperty("oracle-r2dbc.version", Dependencies.ORACLE_R2DBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("r2dbc-postgresql.version", Dependencies.POSTGRES_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("r2dbc-h2.version", Dependencies.H2_R2DBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("r2dbc-mariadb.version", Dependencies.MARIADB_R2DBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("r2dbc-mssql.version", Dependencies.MS_SQLSERVER_R2DBC));
config.add(Projects.RELATIONAL, ProjectDependency.managedProperty("r2dbc-mysql.version", Dependencies.MYSQL_R2DBC));
config.add(Projects.RELATIONAL,
ProjectDependency.managedProperty("oracle-r2dbc.version", Dependencies.ORACLE_R2DBC));
}
private final List<ProjectDependency> dependencies;
@@ -172,10 +185,16 @@ public class ProjectDependencies implements Streamable<ProjectDependencies.Proje
String property;
boolean verifyUsage;
Dependency dependency;
public static ProjectDependency ofProperty(String pomProperty, Dependency dependency) {
return new ProjectDependency(pomProperty, dependency);
public static ProjectDependency managedProperty(String pomProperty, Dependency dependency) {
return new ProjectDependency(pomProperty, false, dependency);
}
public static ProjectDependency using(String pomProperty, Dependency dependency) {
return new ProjectDependency(pomProperty, true, dependency);
}
}
}