Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add io.asyncer:r2dbc-mysql when spring boot 3.1 is selected #1285

Closed
wants to merge 1 commit into from
Closed
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 @@ -38,6 +38,7 @@
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Brian Clozel
* @author Eddú Meléndez
*/
public class R2dbcBuildCustomizer implements BuildCustomizer<Build> {

Expand All @@ -47,16 +48,21 @@ public class R2dbcBuildCustomizer implements BuildCustomizer<Build> {

private static final VersionRange SPRING_BOOT_3_0_0_OR_LATER = VersionParser.DEFAULT.parseRange("3.0.0-M1");

private static final VersionRange SPRING_BOOT_3_1_0_OR_LATER = VersionParser.DEFAULT.parseRange("3.1.0");

private final boolean borcaOrLater;

private final boolean mariaDbIsUnmanaged;

private final boolean sqlServerIsUnmanaged;

private final boolean mysqlR2dbcNewDependency;

public R2dbcBuildCustomizer(Version platformVersion) {
this.borcaOrLater = SPRING_BOOT_2_7_0_OR_LATER.match(platformVersion);
this.mariaDbIsUnmanaged = SPRING_BOOT_3_0_0_OR_LATER.match(platformVersion);
this.sqlServerIsUnmanaged = SPRING_BOOT_3_0_0_OR_LATER.match(platformVersion);
this.mysqlR2dbcNewDependency = SPRING_BOOT_3_1_0_OR_LATER.match(platformVersion);
}

@Override
Expand All @@ -71,6 +77,9 @@ public void customize(Build build) {
if (build.dependencies().has("mysql") && !this.borcaOrLater) {
addManagedDriver(build.dependencies(), "dev.miku", "r2dbc-mysql");
}
if (build.dependencies().has("mysql") && this.mysqlR2dbcNewDependency) {
addManagedDriver(build.dependencies(), "io.asyncer", "r2dbc-mysql");
}
if (build.dependencies().has("postgresql")) {
String groupId = this.borcaOrLater ? "org.postgresql" : "io.r2dbc";
addManagedDriver(build.dependencies(), groupId, "r2dbc-postgresql");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Tests for {@link R2dbcBuildCustomizer}.
*
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
class R2dbcBuildCustomizerTests extends AbstractExtensionTests {

Expand Down Expand Up @@ -72,6 +73,7 @@ void r2dbcWithMysql() {
build.dependencies().add("mysql");
customize(build, Version.parse("2.6.8"));
assertThat(build.dependencies().ids()).containsOnly("data-r2dbc", "mysql", "r2dbc-mysql");
assertThat(build.dependencies().get("r2dbc-mysql").getGroupId()).isEqualTo("dev.miku");
}

@Test
Expand All @@ -83,6 +85,16 @@ void r2dbcWithMysqlAndBorca() {
assertThat(build.dependencies().ids()).containsOnly("data-r2dbc", "mysql");
}

@Test
void r2dbcWithMysqlAndSpringBoot31() {
Build build = createBuild();
build.dependencies().add("data-r2dbc");
build.dependencies().add("mysql");
customize(build, Version.parse("3.1.0"));
assertThat(build.dependencies().ids()).containsOnly("data-r2dbc", "mysql", "r2dbc-mysql");
assertThat(build.dependencies().get("r2dbc-mysql").getGroupId()).isEqualTo("io.asyncer");
}

@Test
void r2dbcWithPostgresql() {
Build build = createBuild();
Expand Down