io.quarkus.deployment.pkg.steps.NativeBuild Java Examples

The following examples show how to use io.quarkus.deployment.pkg.steps.NativeBuild. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudFunctionsDeploymentBuildStep.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a target/deployment dir and copy the uber jar in it.
 * This facilitates the usage of the 'glcoud' command.
 */
@BuildStep(onlyIf = IsNormal.class, onlyIfNot = NativeBuild.class)
public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target, JarBuildItem jar)
        throws BuildException, IOException {
    if (!jar.isUberJar()) {
        throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
                "please set 'quarkus.package.uber-jar=true' inside your application.properties",
                Collections.EMPTY_LIST);
    }

    Path deployment = target.getOutputDirectory().resolve("deployment");
    if (Files.notExists(deployment)) {
        Files.createDirectory(deployment);
    }

    Path jarPath = jar.getPath();
    Path targetJarPath = deployment.resolve(jarPath.getFileName());
    Files.deleteIfExists(targetJarPath);
    Files.copy(jarPath, targetJarPath);

    return new ArtifactResultBuildItem(targetJarPath, "function", Collections.EMPTY_MAP);
}
 
Example #2
Source File: CloudFunctionDeploymentBuildStep.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a target/deployment dir and copy the uber jar in it.
 * This facilitates the usage of the 'glcoud' command.
 */
@BuildStep(onlyIf = IsNormal.class, onlyIfNot = NativeBuild.class)
public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target, JarBuildItem jar)
        throws BuildException, IOException {
    if (!jar.isUberJar()) {
        throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
                "please set 'quarkus.package.uber-jar=true' inside your application.properties",
                Collections.EMPTY_LIST);
    }

    Path deployment = target.getOutputDirectory().resolve("deployment");
    if (Files.notExists(deployment)) {
        Files.createDirectory(deployment);
    }

    Path jarPath = jar.getPath();
    Path targetJarPath = deployment.resolve(jarPath.getFileName());
    Files.deleteIfExists(targetJarPath);
    Files.copy(jarPath, targetJarPath);

    return new ArtifactResultBuildItem(targetJarPath, "function", Collections.EMPTY_MAP);
}
 
Example #3
Source File: SentinelNativeImageProcessor.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@BuildStep(onlyIf = NativeBuild.class)
List<RuntimeInitializedClassBuildItem> runtimeInitializedClasses() {
    return Arrays.asList(
            new RuntimeInitializedClassBuildItem("com.alibaba.fastjson.serializer.JodaCodec"),
            new RuntimeInitializedClassBuildItem("com.alibaba.fastjson.serializer.GuavaCodec"),
            new RuntimeInitializedClassBuildItem("com.alibaba.fastjson.support.moneta.MonetaCodec"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.Env"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.init.InitExecutor"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.cluster.ClusterStateManager"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.node.metric.MetricTimerListener"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.node.metric.MetricWriter"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.util.TimeUtil"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.eagleeye.StatLogController"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.slots.logger.EagleEyeLogUtil"),
            new RuntimeInitializedClassBuildItem("com.alibaba.csp.sentinel.eagleeye.EagleEye"));
}
 
Example #4
Source File: HibernateOrmProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = NativeBuild.class)
public void test(CombinedIndexBuildItem index,
        BuildProducer<ReflectiveClassBuildItem> reflective) {
    Collection<AnnotationInstance> annotationInstances = index.getIndex().getAnnotations(STATIC_METAMODEL);
    if (!annotationInstances.isEmpty()) {

        String[] metamodel = annotationInstances.stream()
                .map(a -> a.target().asClass().name().toString())
                .toArray(String[]::new);

        reflective.produce(new ReflectiveClassBuildItem(false, false, true, metamodel));
    }
}
 
Example #5
Source File: JibProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, JibBuild.class, NativeBuild.class })
public void buildFromNative(ContainerImageConfig containerImageConfig, JibConfig jibConfig,
        ContainerImageInfoBuildItem containerImage,
        NativeImageBuildItem nativeImage,
        ApplicationInfoBuildItem applicationInfo,
        OutputTargetBuildItem outputTarget,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        List<ContainerImageLabelBuildItem> containerImageLabels,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {
        throw new RuntimeException(
                "The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding \"quarkus.native.container-build=true\" to your configuration");
    }

    JibContainerBuilder jibContainerBuilder = createContainerBuilderFromNative(containerImageConfig, jibConfig,
            nativeImage, containerImageLabels);
    handleExtraFiles(outputTarget, jibContainerBuilder);
    containerize(applicationInfo, containerImageConfig, containerImage, jibContainerBuilder,
            pushRequest.isPresent());

    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap()));
}
 
Example #6
Source File: JibProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, JibBuild.class }, onlyIfNot = NativeBuild.class)
public void buildFromJar(ContainerImageConfig containerImageConfig, JibConfig jibConfig,
        PackageConfig packageConfig,
        ContainerImageInfoBuildItem containerImage,
        JarBuildItem sourceJar,
        MainClassBuildItem mainClass,
        OutputTargetBuildItem outputTarget, ApplicationInfoBuildItem applicationInfo,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        List<ContainerImageLabelBuildItem> containerImageLabels,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    JibContainerBuilder jibContainerBuilder;
    String packageType = packageConfig.type;
    if (packageConfig.isLegacyJar() || packageType.equalsIgnoreCase(PackageConfig.UBER_JAR)) {
        jibContainerBuilder = createContainerBuilderFromLegacyJar(jibConfig,
                sourceJar, outputTarget, mainClass, containerImageLabels);
    } else if (packageConfig.isFastJar()) {
        jibContainerBuilder = createContainerBuilderFromFastJar(jibConfig, sourceJar, containerImageLabels);
    } else {
        throw new IllegalArgumentException(
                "Package type '" + packageType + "' is not supported by the container-image-jib extension");
    }
    handleExtraFiles(outputTarget, jibContainerBuilder);
    containerize(applicationInfo, containerImageConfig, containerImage, jibContainerBuilder,
            pushRequest.isPresent());

    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap()));
}
 
Example #7
Source File: S2iProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, S2iBuild.class, NativeBuild.class })
public void s2iBuildFromNative(S2iConfig s2iConfig, ContainerImageConfig containerImageConfig,
        KubernetesClientBuildItem kubernetesClient,
        ContainerImageInfoBuildItem containerImage,
        ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig,
        List<GeneratedFileSystemResourceBuildItem> generatedResources,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
        NativeImageBuildItem nativeImage) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default");
    LOG.info("Performing s2i binary build with native image on server: " + kubernetesClient.getClient().getMasterUrl()
            + " in namespace:" + namespace + ".");

    Optional<GeneratedFileSystemResourceBuildItem> openshiftYml = generatedResources
            .stream()
            .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
            .findFirst();

    if (!openshiftYml.isPresent()) {
        LOG.warn(
                "No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no s2i process will be taking place");
        return;
    }

    createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), nativeImage.getPath());
    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap()));
}
 
Example #8
Source File: S2iProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, S2iBuild.class }, onlyIfNot = NativeBuild.class)
public void s2iBuildFromJar(S2iConfig s2iConfig, ContainerImageConfig containerImageConfig,
        KubernetesClientBuildItem kubernetesClient,
        ContainerImageInfoBuildItem containerImage,
        ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig,
        List<GeneratedFileSystemResourceBuildItem> generatedResources,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
        // used to ensure that the jar has been built
        JarBuildItem jar) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    Optional<GeneratedFileSystemResourceBuildItem> openshiftYml = generatedResources
            .stream()
            .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
            .findFirst();

    if (!openshiftYml.isPresent()) {
        LOG.warn(
                "No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no s2i process will be taking place");
        return;
    }

    String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default");
    LOG.info("Performing s2i binary build with jar on server: " + kubernetesClient.getClient().getMasterUrl()
            + " in namespace:" + namespace + ".");

    createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), jar.getPath(),
            out.getOutputDirectory().resolve("lib"));
    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap()));
}
 
Example #9
Source File: DockerProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, NativeBuild.class })
public void dockerBuildFromNativeImage(DockerConfig dockerConfig,
        ContainerImageConfig containerImageConfig,
        ContainerImageInfoBuildItem containerImage,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        OutputTargetBuildItem out,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
        PackageConfig packageConfig,
        // used to ensure that the native binary has been built
        NativeImageBuildItem nativeImage) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    if (!dockerWorking.getAsBoolean()) {
        throw new RuntimeException("Unable to build docker image. Please check your docker installation");
    }

    if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {
        throw new RuntimeException(
                "The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding \"quarkus.native.container-build=true\" to your configuration");
    }

    log.info("Starting docker image build");

    String image = containerImage.getImage();
    List<String> additionalImageTags = containerImage.getAdditionalImageTags();

    ImageIdReader reader = new ImageIdReader();
    createContainerImage(containerImageConfig, dockerConfig, image, additionalImageTags, out, reader, true,
            pushRequest.isPresent(), packageConfig);
    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap()));
}
 
Example #10
Source File: DockerProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class }, onlyIfNot = NativeBuild.class)
public void dockerBuildFromJar(DockerConfig dockerConfig,
        ContainerImageConfig containerImageConfig, // TODO: use to check whether we need to also push to registry
        OutputTargetBuildItem out,
        ContainerImageInfoBuildItem containerImage,
        Optional<ContainerImageBuildRequestBuildItem> buildRequest,
        Optional<ContainerImagePushRequestBuildItem> pushRequest,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
        PackageConfig packageConfig,
        // used to ensure that the jar has been built
        JarBuildItem jar) {

    if (!containerImageConfig.build && !containerImageConfig.push && !buildRequest.isPresent()
            && !pushRequest.isPresent()) {
        return;
    }

    if (!dockerWorking.getAsBoolean()) {
        throw new RuntimeException("Unable to build docker image. Please check your docker installation");
    }

    log.info("Building docker image for jar.");

    String image = containerImage.getImage();
    List<String> additionalImageTags = containerImage.getAdditionalImageTags();

    ImageIdReader reader = new ImageIdReader();
    createContainerImage(containerImageConfig, dockerConfig, image, additionalImageTags, out, reader, false,
            pushRequest.isPresent(), packageConfig);

    artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap()));
}
 
Example #11
Source File: FunctionZipProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Native function.zip adds anything in src/main/zip.native. If src/main/zip.native/bootstrap
 * exists then the native executable is renamed to "runner".
 *
 * @param target
 * @param artifactResultProducer
 * @param nativeImage
 * @throws Exception
 */
@BuildStep(onlyIf = { IsNormal.class, NativeBuild.class })
public void nativeZip(OutputTargetBuildItem target,
        BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
        NativeImageBuildItem nativeImage) throws Exception {
    Path zipDir = findNativeZipDir(target.getOutputDirectory());

    Path zipPath = target.getOutputDirectory().resolve("function.zip");
    Files.deleteIfExists(zipPath);
    try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(zipPath.toFile())) {
        String executableName = "bootstrap";
        if (zipDir != null) {

            File bootstrap = zipDir.resolve("bootstrap").toFile();
            if (bootstrap.exists()) {
                executableName = "runner";
            }

            try (Stream<Path> paths = Files.walk(zipDir)) {
                paths.filter(Files::isRegularFile)
                        .forEach(path -> {
                            try {
                                if (bootstrap.equals(path.toFile())) {
                                    addZipEntry(zip, path, "bootstrap", 0755);
                                } else {
                                    int mode = Files.isExecutable(path) ? 0755 : 0644;
                                    addZipEntry(zip, path, zipDir.relativize(path).toString().replace('\\', '/'), mode);
                                }
                            } catch (Exception ex) {
                                throw new RuntimeException(ex);
                            }
                        });
            }
        }
        addZipEntry(zip, nativeImage.getPath(), executableName, 0755);
    }
    ;
}
 
Example #12
Source File: AmazonLambdaCommonProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = NativeBuild.class)
@Record(STATIC_INIT)
public void initContextReaders(AmazonLambdaMapperRecorder recorder,
        LambdaObjectMapperInitializedBuildItem dependency) {
    // only need context readers in native or dev or test mode
    recorder.initContextReaders();
}
 
Example #13
Source File: AmazonLambdaProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * This should only run when building a native image
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void startPoolLoop(AmazonLambdaRecorder recorder,
        ShutdownContextBuildItem shutdownContextBuildItem,
        List<ServiceStartBuildItem> orderServicesFirst // try to order this after service recorders
) {
    recorder.startPollLoop(shutdownContextBuildItem);
}
 
Example #14
Source File: FunqyLambdaBuildStep.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * This should only run when building a native image
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(RUNTIME_INIT)
public void startPoolLoop(FunqyLambdaBindingRecorder recorder,
        RuntimeComplete ignored,
        ShutdownContextBuildItem shutdownContextBuildItem,
        List<ServiceStartBuildItem> orderServicesFirst // try to order this after service recorders
) {
    recorder.startPollLoop(shutdownContextBuildItem);
}
 
Example #15
Source File: CassandraqlProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #16
Source File: GooglePubsubProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #17
Source File: OgnlProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #18
Source File: RabbitmqProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #19
Source File: GrpcProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #20
Source File: GroovyProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #21
Source File: OpenstackProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #22
Source File: AvroProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #23
Source File: ProtobufProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #24
Source File: CouchbaseProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #25
Source File: PubnubProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #26
Source File: GoogleBigqueryProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #27
Source File: NitriteProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #28
Source File: DebeziumMongodbProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example #29
Source File: AmazonLambdaCommonProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
/**
 * Lambda custom runtime does not like ipv6.
 */
@BuildStep(onlyIf = NativeBuild.class)
void ipv4Only(BuildProducer<SystemPropertyBuildItem> systemProperty) {
    // lambda custom runtime does not like IPv6
    systemProperty.produce(new SystemPropertyBuildItem("java.net.preferIPv4Stack", "true"));
}
 
Example #30
Source File: S2iProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BuildStep(onlyIf = { IsNormal.class, NativeBuild.class })
public void s2iRequirementsNative(S2iConfig s2iConfig,
        CurateOutcomeBuildItem curateOutcomeBuildItem,
        OutputTargetBuildItem out,
        PackageConfig packageConfig,
        NativeImageBuildItem nativeImage,
        BuildProducer<KubernetesEnvBuildItem> envProducer,
        BuildProducer<BaseImageInfoBuildItem> builderImageProducer,
        BuildProducer<KubernetesCommandBuildItem> commandProducer) {

    boolean usingDefaultBuilder = ImageUtil.getRepository(S2iConfig.DEFAULT_BASE_NATIVE_IMAGE)
            .equals(ImageUtil.getRepository(s2iConfig.baseNativeImage));
    String outputNativeBinaryFileName = nativeImage.getPath().getFileName().toString();

    String nativeBinaryFileName = null;

    //The default s2i builder for native builds, renames the native binary.
    //To make things easier for the user, we need to handle it.
    if (usingDefaultBuilder && !s2iConfig.nativeBinaryFileName.isPresent()) {
        nativeBinaryFileName = S2iConfig.DEFAULT_NATIVE_TARGET_FILENAME;
    } else {
        nativeBinaryFileName = s2iConfig.nativeBinaryFileName.orElse(outputNativeBinaryFileName);
    }

    String pathToNativeBinary = concatUnixPaths(s2iConfig.nativeBinaryDirectory, nativeBinaryFileName);

    builderImageProducer.produce(new BaseImageInfoBuildItem(s2iConfig.baseNativeImage));
    Optional<S2iBaseNativeImage> baseImage = S2iBaseNativeImage.findMatching(s2iConfig.baseNativeImage);
    baseImage.ifPresent(b -> {
        envProducer.produce(
                KubernetesEnvBuildItem.createSimpleVar(b.getHomeDirEnvVar(), s2iConfig.nativeBinaryDirectory, OPENSHIFT));
        envProducer.produce(
                KubernetesEnvBuildItem.createSimpleVar(b.getOptsEnvVar(), String.join(" ", s2iConfig.nativeArguments),
                        OPENSHIFT));
    });

    if (!baseImage.isPresent()) {
        commandProducer.produce(new KubernetesCommandBuildItem(pathToNativeBinary,
                s2iConfig.nativeArguments.toArray(new String[s2iConfig.nativeArguments.size()])));
    }
}