Skip to content

Commit

Permalink
A build step must be a non-static method
Browse files Browse the repository at this point in the history
- previously all static methods annotated with BuildStep were silently
ignored
  • Loading branch information
mkouba committed Oct 1, 2021
1 parent 84fd435 commit 074ede9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,16 @@ private static Consumer<BuildChainBuilder> loadStepsFromClass(Class<?> clazz,
// now iterate the methods
final List<Method> methods = getMethods(clazz);
for (Method method : methods) {
final int mods = method.getModifiers();
if (Modifier.isStatic(mods)) {
final BuildStep buildStep = method.getAnnotation(BuildStep.class);
if (buildStep == null) {
continue;
}
if (!method.isAnnotationPresent(BuildStep.class))
continue;
if (!Modifier.isPublic(mods) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
if (Modifier.isStatic(method.getModifiers())) {
throw new RuntimeException("A build step must be a non-static method: " + method);
}
if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
method.setAccessible(true);
}
final BuildStep buildStep = method.getAnnotation(BuildStep.class);
final Class<? extends BooleanSupplier>[] onlyIf = buildStep.onlyIf();
final Class<? extends BooleanSupplier>[] onlyIfNot = buildStep.onlyIfNot();
final Parameter[] methodParameters = method.getParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.jboss.jandex.MethodInfo;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ConfigClassBuildItem;
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
Expand All @@ -38,7 +37,6 @@ public class ConfigMappingUtils {
private ConfigMappingUtils() {
}

@BuildStep
public static void generateConfigClasses(
CombinedIndexBuildItem combinedIndex,
BuildProducer<GeneratedClassBuildItem> generatedClasses,
Expand Down
5 changes: 2 additions & 3 deletions docs/src/main/asciidoc/writing-extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,8 @@ to produce the final build artifact(s).

==== Build steps

A _build step_ is a method which is annotated with the `@io.quarkus.deployment.annotations.BuildStep` annotation. Each
build step may <<consuming-values,consume>> items that are produced by earlier stages, and <<producing-values,produce>> items
that can be consumed by later stages. Build steps are normally only run when they produce a build item that is
A _build step_ is a non-static method which is annotated with the `@io.quarkus.deployment.annotations.BuildStep` annotation.
Each build step may <<consuming-values,consume>> items that are produced by earlier stages, and <<producing-values,produce>> items that can be consumed by later stages. Build steps are normally only run when they produce a build item that is
ultimately consumed by another step.

Build steps are normally placed on plain classes within an extension's deployment module. The classes are automatically
Expand Down

0 comments on commit 074ede9

Please sign in to comment.