-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly integrate bootstrap config into build system
This round makes bootstrap config work properly with the build system without the arbitrary restrictions of the first iteration. This is accomplished mostly by moving config generation and setup into their own build steps
- Loading branch information
Showing
13 changed files
with
295 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../src/main/java/io/quarkus/deployment/builditem/BootstrapConfigSetupCompleteBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import io.quarkus.builder.item.EmptyBuildItem; | ||
|
||
/** | ||
* Marker used by Build Steps that consume bootstrap configuration to ensure that they run after the bootstrap config has been | ||
* setup | ||
*/ | ||
public final class BootstrapConfigSetupCompleteBuildItem extends EmptyBuildItem { | ||
} |
24 changes: 0 additions & 24 deletions
24
...in/java/io/quarkus/deployment/builditem/MainBootstrapConfigBytecodeRecorderBuildItem.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...nt/src/main/java/io/quarkus/deployment/builditem/RuntimeConfigSetupCompleteBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import io.quarkus.builder.item.EmptyBuildItem; | ||
|
||
/** | ||
* Marker used by Build Steps that consume runtime configuration to ensure that they run after the runtime config has been setup | ||
*/ | ||
public final class RuntimeConfigSetupCompleteBuildItem extends EmptyBuildItem { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/deployment/src/main/java/io/quarkus/deployment/steps/BootstrapConfigSetupBuildStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.deployment.steps; | ||
|
||
import static io.quarkus.deployment.configuration.RunTimeConfigurationGenerator.C_CREATE_BOOTSTRAP_CONFIG; | ||
|
||
import io.quarkus.deployment.GeneratedClassGizmoAdaptor; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Produce; | ||
import io.quarkus.deployment.builditem.BootstrapConfigSetupCompleteBuildItem; | ||
import io.quarkus.deployment.builditem.GeneratedClassBuildItem; | ||
import io.quarkus.deployment.builditem.MainBytecodeRecorderBuildItem; | ||
import io.quarkus.gizmo.ClassCreator; | ||
import io.quarkus.gizmo.ClassOutput; | ||
import io.quarkus.gizmo.MethodCreator; | ||
import io.quarkus.runtime.StartupContext; | ||
import io.quarkus.runtime.StartupTask; | ||
|
||
public class BootstrapConfigSetupBuildStep { | ||
|
||
private static final String BOOTSTRAP_CONFIG_STARTUP_TASK_CLASS_NAME = "io.quarkus.deployment.steps.BootstrapConfigSetup"; | ||
|
||
/** | ||
* Generates a StartupTask that creates a instance of the generated Config class | ||
* It runs before any StartupTask that uses configuration | ||
*/ | ||
@BuildStep | ||
@Produce(BootstrapConfigSetupCompleteBuildItem.class) | ||
void setupBootstrapConfig(BuildProducer<GeneratedClassBuildItem> generatedClass, | ||
BuildProducer<MainBytecodeRecorderBuildItem> mainBytecodeRecorder) { | ||
ClassOutput classOutput = new GeneratedClassGizmoAdaptor(generatedClass, true); | ||
|
||
try (ClassCreator clazz = ClassCreator.builder().classOutput(classOutput) | ||
.className(BOOTSTRAP_CONFIG_STARTUP_TASK_CLASS_NAME) | ||
.interfaces(StartupTask.class).build()) { | ||
|
||
try (MethodCreator deploy = clazz.getMethodCreator("deploy", void.class, StartupContext.class)) { | ||
deploy.invokeStaticMethod(C_CREATE_BOOTSTRAP_CONFIG); | ||
deploy.returnValue(null); | ||
} | ||
} | ||
|
||
mainBytecodeRecorder.produce(new MainBytecodeRecorderBuildItem(BOOTSTRAP_CONFIG_STARTUP_TASK_CLASS_NAME)); | ||
} | ||
} |
Oops, something went wrong.