From 60fd16f8b3698182b52a3e22fe8cf1d03bff5c89 Mon Sep 17 00:00:00 2001 From: Guillaume Le Floch Date: Wed, 1 Apr 2020 08:56:48 +0200 Subject: [PATCH] deprecate buildNative gradle task --- .../gradle/QuarkusPluginFunctionalTest.java | 4 + .../java/io/quarkus/gradle/QuarkusPlugin.java | 28 +- .../quarkus/gradle/tasks/QuarkusNative.java | 511 ------------------ .../resources/templates/README.gradle.ftl | 4 +- docs/src/main/asciidoc/gradle-tooling.adoc | 48 +- 5 files changed, 32 insertions(+), 563 deletions(-) delete mode 100644 devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusNative.java diff --git a/devtools/gradle/src/functionalTest/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java b/devtools/gradle/src/functionalTest/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java index f2746b1cb495b..62b06e729a44c 100644 --- a/devtools/gradle/src/functionalTest/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java +++ b/devtools/gradle/src/functionalTest/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -81,6 +82,9 @@ public void canBuild(SourceType sourceType) throws IOException, InterruptedExcep assertThat(build.task(":build").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); // gradle build should not build the native image assertThat(build.task(":buildNative")).isNull(); + Path buildDir = projectRoot.toPath().resolve("build"); + assertThat(buildDir).exists(); + assertThat(buildDir.resolve("foo-1.0.0-SNAPSHOT-runner")).doesNotExist(); } private void createProject(SourceType sourceType) throws IOException { diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index e85e8d7f4bab0..8e22bf68ef481 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.function.Consumer; +import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -25,13 +26,13 @@ import io.quarkus.gradle.tasks.QuarkusDev; import io.quarkus.gradle.tasks.QuarkusGenerateConfig; import io.quarkus.gradle.tasks.QuarkusListExtensions; -import io.quarkus.gradle.tasks.QuarkusNative; import io.quarkus.gradle.tasks.QuarkusTestConfig; import io.quarkus.gradle.tasks.QuarkusTestNative; public class QuarkusPlugin implements Plugin { public static final String ID = "io.quarkus"; + public static final String QUARKUS_PACKAGE_TYPE = "quarkus.package.type"; public static final String EXTENSION_NAME = "quarkus"; public static final String LIST_EXTENSIONS_TASK_NAME = "listExtensions"; @@ -39,6 +40,8 @@ public class QuarkusPlugin implements Plugin { public static final String QUARKUS_BUILD_TASK_NAME = "quarkusBuild"; public static final String GENERATE_CONFIG_TASK_NAME = "generateConfig"; public static final String QUARKUS_DEV_TASK_NAME = "quarkusDev"; + + @Deprecated public static final String BUILD_NATIVE_TASK_NAME = "buildNative"; public static final String TEST_NATIVE_TASK_NAME = "testNative"; public static final String QUARKUS_TEST_CONFIG_TASK_NAME = "quarkusTestConfig"; @@ -69,9 +72,15 @@ private void registerTasks(Project project) { 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); + Task buildNative = tasks.create(BUILD_NATIVE_TASK_NAME, DefaultTask.class); + buildNative.finalizedBy(quarkusBuild); + buildNative.doFirst(t -> project.getLogger() + .warn("The 'buildNative' task has been deprecated in favor of 'build -Dquarkus.package.type=native'")); + + configureBuildNativeTask(project); + project.getPlugins().withType( BasePlugin.class, basePlugin -> tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(quarkusBuild)); @@ -85,8 +94,6 @@ private void registerTasks(Project project) { 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); @@ -111,9 +118,8 @@ private void registerTasks(Project project) { .extendsFrom(configurations.findByName(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME)); Task testNative = tasks.create(TEST_NATIVE_TASK_NAME, QuarkusTestNative.class); - testNative.dependsOn(buildNative); + testNative.dependsOn(quarkusBuild); testNative.setShouldRunAfter(Collections.singletonList(tasks.findByName(JavaPlugin.TEST_TASK_NAME))); - Consumer configureTestTask = t -> { // Quarkus test configuration task which should be executed before any Quarkus test t.dependsOn(quarkusTestConfig); @@ -132,6 +138,16 @@ private void verifyGradleVersion() { } } + private void configureBuildNativeTask(Project project) { + project.getGradle().getTaskGraph().whenReady(taskGraph -> { + if (taskGraph.hasTask(project.getPath() + BUILD_NATIVE_TASK_NAME) + || taskGraph.hasTask(project.getPath() + TEST_NATIVE_TASK_NAME)) { + project.getExtensions().getExtraProperties() + .set(QUARKUS_PACKAGE_TYPE, "native"); + } + }); + } + private void afterEvaluate(Project project) { project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME) .getIncoming().getDependencies() diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusNative.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusNative.java deleted file mode 100644 index 58bbd3c6c28f5..0000000000000 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusNative.java +++ /dev/null @@ -1,511 +0,0 @@ -package io.quarkus.gradle.tasks; - -import static java.util.stream.Collectors.joining; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.eclipse.microprofile.config.spi.ConfigSource; -import org.gradle.api.GradleException; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.options.Option; - -import io.quarkus.bootstrap.BootstrapException; -import io.quarkus.bootstrap.app.CuratedApplication; -import io.quarkus.bootstrap.app.QuarkusBootstrap; -import io.quarkus.bootstrap.model.AppArtifact; -import io.quarkus.bootstrap.resolver.AppModelResolver; -import io.quarkus.bootstrap.resolver.AppModelResolverException; - -public class QuarkusNative extends QuarkusTask { - - private boolean reportErrorsAtRuntime = false; - - private boolean debugSymbols = false; - - private boolean debugBuildProcess; - - private boolean cleanupServer; - - private boolean enableHttpUrlHandler; - - private boolean enableHttpsUrlHandler; - - private boolean enableAllSecurityServices; - - private boolean enableIsolates; - - private String graalvmHome = System.getenv("GRAALVM_HOME"); - - private boolean enableServer = false; - - /** - * @deprecated JNI is always enabled starting from GraalVM 19.3.1. - */ - @Deprecated - private boolean enableJni = true; - - private boolean autoServiceLoaderRegistration = false; - - private boolean dumpProxies = false; - - private String nativeImageXmx; - - private String containerRuntime; - - private String containerRuntimeOptions; - - private String dockerBuild; - - private String nativeBuilderImage; - - private boolean enableVMInspection = false; - - private boolean enableFallbackImages = false; - - private boolean fullStackTraces = true; - - private boolean enableReports; - - private List additionalBuildArgs; - - private boolean addAllCharsets = false; - - private boolean reportExceptionStackTraces = true; - - public QuarkusNative() { - super("Building a native image"); - } - - @Input - public boolean isAddAllCharsets() { - return addAllCharsets; - } - - @Option(description = "Should all Charsets supported by the host environment be included in the native image", option = "add-all-charsets") - public void setAddAllCharsets(final boolean addAllCharsets) { - this.addAllCharsets = addAllCharsets; - } - - @Input - public boolean isReportErrorsAtRuntime() { - return reportErrorsAtRuntime; - } - - @Option(description = "Report errors at runtime", option = "report-errors-runtime") - public void setReportErrorsAtRuntime(boolean reportErrorsAtRuntime) { - this.reportErrorsAtRuntime = reportErrorsAtRuntime; - } - - @Input - public boolean isDebugSymbols() { - return debugSymbols; - } - - @Option(description = "Specify if debug symbols should be set", option = "debug-symbols") - public void setDebugSymbols(boolean debugSymbols) { - this.debugSymbols = debugSymbols; - } - - @Input - public boolean isDebugBuildProcess() { - return debugBuildProcess; - } - - @Option(description = "Specify if debug is set during build process", option = "debug-build-process") - public void setDebugBuildProcess(boolean debugBuildProcess) { - this.debugBuildProcess = debugBuildProcess; - } - - @Input - public boolean isCleanupServer() { - return cleanupServer; - } - - @Option(description = "Cleanup server", option = "cleanup-server") - public void setCleanupServer(boolean cleanupServer) { - this.cleanupServer = cleanupServer; - } - - @Input - public boolean isEnableHttpUrlHandler() { - return enableHttpUrlHandler; - } - - @Input - public boolean isEnableFallbackImages() { - return enableFallbackImages; - } - - @Option(description = "Enable the GraalVM native image compiler to generate Fallback Images in case of compilation error. " - + - "Careful: these are not as efficient as normal native images.", option = "enable-fallback-images") - public void setEnableFallbackImages(boolean enableFallbackImages) { - this.enableFallbackImages = enableFallbackImages; - } - - @Option(description = "Specify if http url handler is enabled", option = "enable-http-url-handler") - public void setEnableHttpUrlHandler(boolean enableHttpUrlHandler) { - this.enableHttpUrlHandler = enableHttpUrlHandler; - } - - @Input - public boolean isEnableHttpsUrlHandler() { - return enableHttpsUrlHandler; - } - - @Option(description = "Specify if https url handler is enabled", option = "enable-https-url-handler") - public void setEnableHttpsUrlHandler(boolean enableHttpsUrlHandler) { - this.enableHttpsUrlHandler = enableHttpsUrlHandler; - } - - @Input - public boolean isEnableAllSecurityServices() { - return enableAllSecurityServices; - } - - @Option(description = "Enable all security services", option = "enable-all-security-services") - public void setEnableAllSecurityServices(boolean enableAllSecurityServices) { - this.enableAllSecurityServices = enableAllSecurityServices; - } - - @Input - public boolean isEnableIsolates() { - return enableIsolates; - } - - @Option(description = "Report errors at runtime", option = "enable-isolates") - public void setEnableIsolates(boolean enableIsolates) { - this.enableIsolates = enableIsolates; - } - - @Optional - @Input - public String getGraalvmHome() { - return graalvmHome; - } - - @Option(description = "Specify the GraalVM directory (default to $GRAALVM_HOME)", option = "graalvm") - public void setGraalvmHome(String graalvmHome) { - this.graalvmHome = graalvmHome; - } - - @Input - public boolean isEnableServer() { - return enableServer; - } - - @Option(description = "Enable server", option = "enable-server") - public void setEnableServer(boolean enableServer) { - this.enableServer = enableServer; - } - - @Input - @Deprecated - public boolean isEnableJni() { - return enableJni; - } - - /** - * @param enableJni true to enable JNI - * @deprecated JNI is always enabled starting from GraalVM 19.3.1. - */ - @Option(description = "Enable jni (deprecated)", option = "enable-jni") - @Deprecated - public void setEnableJni(boolean enableJni) { - this.enableJni = enableJni; - } - - @Input - public boolean isAutoServiceLoaderRegistration() { - return autoServiceLoaderRegistration; - } - - @Option(description = "Auto ServiceLoader registration", option = "auto-service-loader-registration") - public void setAutoServiceLoaderRegistration(boolean autoServiceLoaderRegistration) { - this.autoServiceLoaderRegistration = autoServiceLoaderRegistration; - } - - @Input - public boolean isDumpProxies() { - return dumpProxies; - } - - @Option(description = "Dump proxies", option = "dump-proxies") - public void setDumpProxies(boolean dumpProxies) { - this.dumpProxies = dumpProxies; - } - - @Optional - @Input - public String getNativeImageXmx() { - return nativeImageXmx; - } - - @Option(description = "Specify the native image maximum heap size", option = "native-image-xmx") - public void setNativeImageXmx(String nativeImageXmx) { - this.nativeImageXmx = nativeImageXmx; - } - - @Optional - @Input - public String getContainerRuntime() { - return containerRuntime; - } - - @Optional - @Input - public String getContainerRuntimeOptions() { - return containerRuntimeOptions; - } - - @Optional - @Input - public String getDockerBuild() { - return dockerBuild; - } - - @Option(description = "Container runtime", option = "container-runtime") - public void setContainerRuntime(String containerRuntime) { - this.containerRuntime = containerRuntime; - } - - @Option(description = "Container runtime options", option = "container-runtime-options") - public void setContainerRuntimeOptions(String containerRuntimeOptions) { - this.containerRuntimeOptions = containerRuntimeOptions; - } - - @Option(description = "Docker build", option = "docker-build") - public void setDockerBuild(String dockerBuild) { - this.dockerBuild = dockerBuild; - } - - @Option(description = "Docker image", option = "native-builder-image") - public void setNativeBuilderImage(String nativeBuilderImage) { - this.nativeBuilderImage = nativeBuilderImage; - } - - @Optional - @Input - public String getNativeBuilderImage() { - return nativeBuilderImage; - } - - @Input - public boolean isEnableVMInspection() { - return enableVMInspection; - } - - @Option(description = "Enable VM inspection", option = "enable-vm-inspection") - public void setEnableVMInspection(boolean enableVMInspection) { - this.enableVMInspection = enableVMInspection; - } - - @Input - public boolean isFullStackTraces() { - return fullStackTraces; - } - - @Option(description = "Specify full stacktraces", option = "full-stacktraces") - public void setFullStackTraces(boolean fullStackTraces) { - this.fullStackTraces = fullStackTraces; - } - - @Input - public boolean isEnableReports() { - return enableReports; - } - - @Deprecated - @Option(description = "Disable reports", option = "disable-reports") - public void setDisableReports(boolean disableReports) { - this.enableReports = !disableReports; - } - - @Option(description = "Enable reports", option = "enable-reports") - public void setEnableReports(boolean enableReports) { - this.enableReports = enableReports; - } - - @Optional - @Input - public List getAdditionalBuildArgs() { - return additionalBuildArgs; - } - - @Option(description = "Additional build arguments", option = "additional-build-args") - public void setAdditionalBuildArgs(List additionalBuildArgs) { - this.additionalBuildArgs = additionalBuildArgs; - } - - @Input - public boolean isReportExceptionStackTraces() { - return reportExceptionStackTraces; - } - - @Option(description = "Show exception stack traces for exceptions during image building", option = "report-exception-stack-traces") - public void setReportExceptionStackTraces(boolean reportExceptionStackTraces) { - this.reportExceptionStackTraces = reportExceptionStackTraces; - } - - @TaskAction - public void buildNative() { - getLogger().lifecycle("building native image"); - - final AppArtifact appArtifact = extension().getAppArtifact(); - final AppModelResolver modelResolver = extension().getAppModelResolver(); - try { - modelResolver.resolveModel(appArtifact); - } catch (AppModelResolverException e) { - throw new GradleException("Failed to resolve application model " + appArtifact + " dependencies", e); - } - final Properties realProperties = getBuildSystemProperties(appArtifact); - - Map config = createCustomConfig(); - Map old = new HashMap<>(); - for (Map.Entry e : config.entrySet()) { - old.put(e.getKey(), System.getProperty(e.getKey())); - System.setProperty(e.getKey(), e.getValue()); - } - try (CuratedApplication appCreationContext = QuarkusBootstrap.builder(appArtifact.getPath()) - .setAppModelResolver(modelResolver) - .setBaseClassLoader(getClass().getClassLoader()) - .setTargetDirectory(getProject().getBuildDir().toPath()) - .setBaseName(extension().finalName()) - .setLocalProjectDiscovery(false) - .setBuildSystemProperties(realProperties) - .setIsolateDeployment(true) - .setAppArtifact(appArtifact) - .build().bootstrap()) { - appCreationContext.createAugmentor().createProductionApplication(); - - } catch (BootstrapException e) { - throw new GradleException("Failed to build a runnable JAR", e); - } finally { - for (Map.Entry e : old.entrySet()) { - if (e.getValue() == null) { - System.clearProperty(e.getKey()); - } else { - System.setProperty(e.getKey(), e.getValue()); - } - } - } - } - - private Map createCustomConfig() { - Map configs = new HashMap<>(); - configs.put("quarkus.package.type", "native"); - - configs.put("quarkus.native.add-all-charsets", Boolean.toString(addAllCharsets)); - - if (additionalBuildArgs != null && !additionalBuildArgs.isEmpty()) { - configs.put("quarkus.native.additional-build-args", - additionalBuildArgs.stream() - .map(val -> val.replace("\\", "\\\\")) - .map(val -> val.replace(",", "\\,")) - .collect(joining(","))); - } - configs.put("quarkus.native.auto-service-loader-registration", Boolean.toString(autoServiceLoaderRegistration)); - - configs.put("quarkus.native.cleanup-server", Boolean.toString(cleanupServer)); - configs.put("quarkus.native.debug-build-process", Boolean.toString(debugBuildProcess)); - - configs.put("quarkus.native.debug-symbols", Boolean.toString(debugSymbols)); - configs.put("quarkus.native.enable-reports", Boolean.toString(enableReports)); - if (containerRuntime != null && !containerRuntime.trim().isEmpty()) { - configs.put("quarkus.native.container-runtime", containerRuntime); - } else if (dockerBuild != null && !dockerBuild.trim().isEmpty()) { - if (!dockerBuild.isEmpty() && !dockerBuild.toLowerCase().equals("false")) { - if (dockerBuild.toLowerCase().equals("true")) { - configs.put("quarkus.native.container-runtime", "docker"); - } else { - configs.put("quarkus.native.container-runtime", dockerBuild); - } - } - } - if (containerRuntimeOptions != null && !containerRuntimeOptions.trim().isEmpty()) { - configs.put("quarkus.native.container-runtime-options", containerRuntimeOptions); - } - if (nativeBuilderImage != null && !nativeBuilderImage.trim().isEmpty()) { - configs.put("quarkus.native.builder-image", nativeBuilderImage); - } - configs.put("quarkus.native.dump-proxies", Boolean.toString(dumpProxies)); - configs.put("quarkus.native.enable-all-security-services", Boolean.toString(enableAllSecurityServices)); - configs.put("quarkus.native.enable-fallback-images", Boolean.toString(enableFallbackImages)); - configs.put("quarkus.native.enable-https-url-handler", Boolean.toString(enableHttpsUrlHandler)); - - configs.put("quarkus.native.enable-http-url-handler", Boolean.toString(enableHttpUrlHandler)); - configs.put("quarkus.native.enable-isolates", Boolean.toString(enableIsolates)); - - configs.put("quarkus.native.enable-server", Boolean.toString(enableServer)); - - configs.put("quarkus.native.enable-vm-inspection", Boolean.toString(enableVMInspection)); - - configs.put("quarkus.native.full-stack-traces", Boolean.toString(fullStackTraces)); - - if (graalvmHome != null && !graalvmHome.trim().isEmpty()) { - configs.put("quarkus.native.graalvm-home", graalvmHome); - } - if (nativeImageXmx != null && !nativeImageXmx.trim().isEmpty()) { - configs.put("quarkus.native.native-image-xmx", nativeImageXmx); - } - configs.put("quarkus.native.report-errors-at-runtime", Boolean.toString(reportErrorsAtRuntime)); - - configs.put("quarkus.native.report-exception-stack-traces", Boolean.toString(reportExceptionStackTraces)); - - return configs; - - } - - private static final class InMemoryConfigSource implements ConfigSource { - - private final Map values = new HashMap<>(); - private final int ordinal; - private final String name; - - private InMemoryConfigSource(int ordinal, String name) { - this.ordinal = ordinal; - this.name = name; - } - - public InMemoryConfigSource add(String key, String value) { - values.put(key, value); - return this; - } - - public InMemoryConfigSource add(String key, Object value) { - values.put(key, value.toString()); - return this; - } - - @Override - public Map getProperties() { - return values; - } - - @Override - public Set getPropertyNames() { - return values.keySet(); - } - - @Override - public int getOrdinal() { - return ordinal; - } - - @Override - public String getValue(String propertyName) { - return values.get(propertyName); - } - - @Override - public String getName() { - return name; - } - } -} diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/README.gradle.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/README.gradle.ftl index a91dd8a13175d..7c9ddaef5f165 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/README.gradle.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/README.gradle.ftl @@ -26,9 +26,9 @@ If you want to build an _über-jar_, just add the `--uber-jar` option to the com ## Creating a native executable -You can create a native executable using: `./gradlew buildNative`. +You can create a native executable using: `./gradlew build -Dquarkus.package.type=native`. -Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./gradlew buildNative --docker-build=true`. +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true`. You can then execute your native executable with: `./build/${project_artifactId}-${project_version}-runner` diff --git a/docs/src/main/asciidoc/gradle-tooling.adoc b/docs/src/main/asciidoc/gradle-tooling.adoc index 3f543ae6a06c8..e92c5fb07b000 100644 --- a/docs/src/main/asciidoc/gradle-tooling.adoc +++ b/docs/src/main/asciidoc/gradle-tooling.adoc @@ -261,7 +261,7 @@ Native executables make Quarkus applications ideal for containers and serverless Make sure to have `GRAALVM_HOME` configured and pointing to GraalVM version {graalvm-version}. -Create a native executable using: `./gradlew buildNative`. +Create a native executable using: `./gradlew build -Dquarkus.package.type=native`. A native executable will be present in `build/`. === Build a container friendly executable @@ -271,18 +271,7 @@ To create an executable that will run in a container, use the following: [source,shell] ---- -./gradlew buildNative ----- - -==== Customize the build native task - -There are situations where it may be required to alter the default values of the `buildNative` task (whose implementation can be found link:https://github.com/quarkusio/quarkus/blob/master/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusNative.java[here]). - -The easiest way to supply custom configuration is via the command line. For example to use docker to build the native image, simply add the `--docker-build=true` flag like so: - -[source,shell] ----- -./gradlew buildNative --docker-build=true +./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true ---- The produced executable will be a 64 bit Linux executable, so depending on your operating system it may no longer be runnable. @@ -300,35 +289,6 @@ The list of the available Docker images can be found on https://quay.io/reposito Be aware that a given Quarkus version might not be compatible with all the images available. ==== -Another way of customizing the native build image build process is to configure the task inside the Gradle build script. If for example it is required to set the `enableHttpUrlHandler`, it can be done like so: - -[source,groovy] ----- -buildNative { - enableHttpUrlHandler = true -} ----- - -or, if you use the Gradle Kotlin DSL: - -[source,kotlin,subs=attributes+] ----- -tasks { - named("buildNative") { - setEnableHttpUrlHandler(true) - } -} ----- - - -The native executable would then be produced by executing: - -[source,shell] ----- -./gradlew buildNative ----- - - == Running native tests Run the native tests using: @@ -338,7 +298,7 @@ Run the native tests using: ./gradlew testNative ---- -This task depends on `buildNative`, so it will generate the native image before running the tests. +This task depends on `quarkusBuild`, so it will generate the native image before running the tests. == Building Uber-Jars @@ -360,4 +320,4 @@ The entries are relative to the root of the generated Uber-Jar. You can specify == Building with `./gradlew build` -Starting from 1.1.0.Final, `./gradlew build` will no longer build the native image. Use the `buildNative` task explicitly as explained above if needed. +Starting from 1.1.0.Final, `./gradlew build` will no longer build the native image. Add `-Dquarkus.package.type=native` build argument explicitly as explained above if needed.