Search in sources :

Example 1 with ArtifactResult

use of io.quarkus.bootstrap.app.ArtifactResult in project quarkus by quarkusio.

the class AugmentActionImpl method createProductionApplication.

@Override
public AugmentResult createProductionApplication() {
    if (launchMode != LaunchMode.NORMAL) {
        throw new IllegalStateException("Can only create a production application when using NORMAL launch mode");
    }
    ClassLoader classLoader = curatedApplication.createDeploymentClassLoader();
    BuildResult result = runAugment(true, Collections.emptySet(), null, classLoader, ArtifactResultBuildItem.class, DeploymentResultBuildItem.class);
    writeDebugSourceFile(result);
    JarBuildItem jarBuildItem = result.consumeOptional(JarBuildItem.class);
    NativeImageBuildItem nativeImageBuildItem = result.consumeOptional(NativeImageBuildItem.class);
    List<ArtifactResultBuildItem> artifactResultBuildItems = result.consumeMulti(ArtifactResultBuildItem.class);
    BuildSystemTargetBuildItem buildSystemTargetBuildItem = result.consume(BuildSystemTargetBuildItem.class);
    // this depends on the fact that the order in which we can obtain MultiBuildItems is the same as they are produced
    // we want to write result of the final artifact created
    ArtifactResultBuildItem lastResult = artifactResultBuildItems.get(artifactResultBuildItems.size() - 1);
    writeArtifactResultMetadataFile(buildSystemTargetBuildItem, lastResult);
    return new AugmentResult(artifactResultBuildItems.stream().map(a -> new ArtifactResult(a.getPath(), a.getType(), a.getMetadata())).collect(Collectors.toList()), jarBuildItem != null ? jarBuildItem.toJarResult() : null, nativeImageBuildItem != null ? nativeImageBuildItem.getPath() : null);
}
Also used : BuildResult(io.quarkus.builder.BuildResult) JarBuildItem(io.quarkus.deployment.pkg.builditem.JarBuildItem) QuarkusClassLoader(io.quarkus.bootstrap.classloading.QuarkusClassLoader) ArtifactResultBuildItem(io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem) BuildSystemTargetBuildItem(io.quarkus.deployment.pkg.builditem.BuildSystemTargetBuildItem) AugmentResult(io.quarkus.bootstrap.app.AugmentResult) NativeImageBuildItem(io.quarkus.deployment.pkg.builditem.NativeImageBuildItem) ArtifactResult(io.quarkus.bootstrap.app.ArtifactResult)

Example 2 with ArtifactResult

use of io.quarkus.bootstrap.app.ArtifactResult in project quarkus by quarkusio.

the class RebuildHandler method handlePostAsync.

@Override
protected void handlePostAsync(RoutingContext event, MultiMap form) throws Exception {
    QuarkusBootstrap existing = (QuarkusBootstrap) DevConsoleManager.getQuarkusBootstrap();
    try (TempSystemProperties properties = new TempSystemProperties()) {
        for (Map.Entry<String, String> i : config.entrySet()) {
            properties.set(i.getKey(), i.getValue());
        }
        for (Map.Entry<String, String> i : form.entries()) {
            if (!i.getValue().isEmpty()) {
                properties.set(i.getKey(), i.getValue());
            }
        }
        QuarkusBootstrap quarkusBootstrap = existing.clonedBuilder().setMode(QuarkusBootstrap.Mode.PROD).setIsolateDeployment(true).build();
        try (CuratedApplication bootstrap = quarkusBootstrap.bootstrap()) {
            AugmentResult augmentResult = bootstrap.createAugmentor().createProductionApplication();
            List<ArtifactResult> containerArtifactResults = augmentResult.resultsMatchingType((s) -> s.contains("container"));
            if (containerArtifactResults.size() >= 1) {
                flashMessage(event, "Container-image: " + containerArtifactResults.get(0).getMetadata().get("container-image") + " created.", Duration.ofSeconds(10));
            }
        }
    }
    ;
}
Also used : TempSystemProperties(io.quarkus.dev.console.TempSystemProperties) CuratedApplication(io.quarkus.bootstrap.app.CuratedApplication) QuarkusBootstrap(io.quarkus.bootstrap.app.QuarkusBootstrap) AugmentResult(io.quarkus.bootstrap.app.AugmentResult) Map(java.util.Map) MultiMap(io.vertx.core.MultiMap) ArtifactResult(io.quarkus.bootstrap.app.ArtifactResult)

Aggregations

ArtifactResult (io.quarkus.bootstrap.app.ArtifactResult)2 AugmentResult (io.quarkus.bootstrap.app.AugmentResult)2 CuratedApplication (io.quarkus.bootstrap.app.CuratedApplication)1 QuarkusBootstrap (io.quarkus.bootstrap.app.QuarkusBootstrap)1 QuarkusClassLoader (io.quarkus.bootstrap.classloading.QuarkusClassLoader)1 BuildResult (io.quarkus.builder.BuildResult)1 ArtifactResultBuildItem (io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem)1 BuildSystemTargetBuildItem (io.quarkus.deployment.pkg.builditem.BuildSystemTargetBuildItem)1 JarBuildItem (io.quarkus.deployment.pkg.builditem.JarBuildItem)1 NativeImageBuildItem (io.quarkus.deployment.pkg.builditem.NativeImageBuildItem)1 TempSystemProperties (io.quarkus.dev.console.TempSystemProperties)1 MultiMap (io.vertx.core.MultiMap)1 Map (java.util.Map)1