Code review comment: Can't. It takes an Action, which is not compatible with Consumer.

Code before review:
private void registerTasks(Project project) {
TaskContainer tasks = project.getTasks();
tasks.create(LIST_EXTENSIONS_TASK_NAME, QuarkusListExtensions.class);
tasks.create(ADD_EXTENSION_TASK_NAME, QuarkusAddExtension.class);
tasks.create(GENERATE_CONFIG_TASK_NAME, QuarkusGenerateConfig.class);
Task quarkusBuild = tasks.create(QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class);
Task quarkusDev = tasks.create(QUARKUS_DEV_TASK_NAME, QuarkusDev.class);
Task buildNative = tasks.create(BUILD_NATIVE_TASK_NAME, QuarkusNative.class);
Task quarkusTestConfig = tasks.create(QUARKUS_TEST_CONFIG_TASK_NAME, QuarkusTestConfig.class);
project.getPlugins().withType(
BasePlugin.class,
basePlugin -> tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(quarkusBuild));
project.getPlugins().withType(
JavaPlugin.class,
javaPlugin -> {
Task classesTask = tasks.getByName(JavaPlugin.CLASSES_TASK_NAME);
quarkusDev.dependsOn(classesTask);
quarkusBuild.dependsOn(classesTask, tasks.getByName(JavaPlugin.JAR_TASK_NAME));
quarkusTestConfig.dependsOn(classesTask);
buildNative.dependsOn(tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME));
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
.getSourceSets();
SourceSet nativeTestSourceSet = sourceSets.create(NATIVE_TEST_SOURCE_SET_NAME);
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
nativeTestSourceSet.setCompileClasspath(
nativeTestSourceSet.getCompileClasspath()
.plus(mainSourceSet.getOutput())
.plus(testSourceSet.getOutput()));
nativeTestSourceSet.setRuntimeClasspath(
nativeTestSourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getOutput())
.plus(testSourceSet.getOutput()));
ConfigurationContainer configurations = project.getConfigurations();
configurations.maybeCreate(NATIVE_TEST_IMPLEMENTATION_CONFIGURATION_NAME)
.extendsFrom(configurations.findByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME));
configurations.maybeCreate(NATIVE_TEST_RUNTIME_ONLY_CONFIGURATION_NAME)
.extendsFrom(configurations.findByName(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME));
Task testNative = tasks.create(TEST_NATIVE_TASK_NAME, QuarkusTestNative.class);
testNative.dependsOn(buildNative);
testNative.setShouldRunAfter(Collections.singletonList(tasks.findByName(JavaPlugin.TEST_TASK_NAME)));
Consumer<Test> configureTestTask = t -> {
t.dependsOn(quarkusTestConfig);
t.useJUnitPlatform();
};
tasks.withType(Test.class).forEach(configureTestTask);
tasks.withType(Test.class).whenTaskAdded(t -> configureTestTask.accept(t));
});
}

Line under review: tasks.withType(Test.class).whenTaskAdded(t -> configureTestTask.accept(t));

Code after addressing the review:
private void registerTasks(Project project) {
TaskContainer tasks = project.getTasks();
tasks.create(LIST_EXTENSIONS_TASK_NAME, QuarkusListExtensions.class);
tasks.create(ADD_EXTENSION_TASK_NAME, QuarkusAddExtension.class);
tasks.create(GENERATE_CONFIG_TASK_NAME, QuarkusGenerateConfig.class);
Task quarkusBuild = tasks.create(QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class);
Task quarkusDev = tasks.create(QUARKUS_DEV_TASK_NAME, QuarkusDev.class);
Task buildNative = tasks.create(BUILD_NATIVE_TASK_NAME, QuarkusNative.class);
Task quarkusTestConfig = tasks.create(QUARKUS_TEST_CONFIG_TASK_NAME, QuarkusTestConfig.class);
project.getPlugins().withType(
BasePlugin.class,
basePlugin -> tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(quarkusBuild));
project.getPlugins().withType(
JavaPlugin.class,
javaPlugin -> {
Task classesTask = tasks.getByName(JavaPlugin.CLASSES_TASK_NAME);
quarkusDev.dependsOn(classesTask);
quarkusBuild.dependsOn(classesTask, tasks.getByName(JavaPlugin.JAR_TASK_NAME));
quarkusTestConfig.dependsOn(classesTask);
buildNative.dependsOn(tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME));
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
.getSourceSets();
SourceSet nativeTestSourceSet = sourceSets.create(NATIVE_TEST_SOURCE_SET_NAME);
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
nativeTestSourceSet.setCompileClasspath(
nativeTestSourceSet.getCompileClasspath()
.plus(mainSourceSet.getOutput())
.plus(testSourceSet.getOutput()));
nativeTestSourceSet.setRuntimeClasspath(
nativeTestSourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getOutput())
.plus(testSourceSet.getOutput()));
ConfigurationContainer configurations = project.getConfigurations();
configurations.maybeCreate(NATIVE_TEST_IMPLEMENTATION_CONFIGURATION_NAME)
.extendsFrom(configurations.findByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME));
configurations.maybeCreate(NATIVE_TEST_RUNTIME_ONLY_CONFIGURATION_NAME)
.extendsFrom(configurations.findByName(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME));
Task testNative = tasks.create(TEST_NATIVE_TASK_NAME, QuarkusTestNative.class);
testNative.dependsOn(buildNative);
testNative.setShouldRunAfter(Collections.singletonList(tasks.findByName(JavaPlugin.TEST_TASK_NAME)));
Consumer<Test> configureTestTask = t -> {
t.dependsOn(quarkusTestConfig);
t.useJUnitPlatform();
};
tasks.withType(Test.class).forEach(configureTestTask);
tasks.withType(Test.class).whenTaskAdded(t -> configureTestTask.accept(t));
});
}