micronaut-projects / micronaut-guides

Guides and Tutorials on how to use Micronaut including sample code
https://guides.micronaut.io
Creative Commons Attribution 4.0 International
36 stars 32 forks source link

Add exclude logic to core #1538

Closed AndreaLaGrotteria closed 1 month ago

AndreaLaGrotteria commented 1 month ago

It should remove the block inside the exclude macro if the exclude criterias are met. For example

:exclude-for-languages:groovy

== Generate Micronaut Application Native Executables with GraalVM

We will use https://www.graalvm.org/[GraalVM], the polyglot embeddable virtual machine, to generate Native executables of our Micronaut applications.

Compiling native executables ahead-of-time with GraalVM improves startup time and reduces the memory footprint of JVM-based applications.

NOTE: Only Java and Kotlin projects support using GraalVM's `native-image` tool. Groovy relies heavily on reflection, which is only partially supported by GraalVM.

=== Native Executable generation

common:install-graalvm-sdkman.adoc[]

:exclude-for-build:maven

To generate native executables for each application using Gradle, run:

[source, bash]
----
./gradlew nativeCompile
----

The native executables are created in `build/native/nativeCompile` directory and can be run with `build/native/nativeCompile/micronautguide`.

It is possible to customize the name of a native executable or pass additional parameters to GraalVM:

.build.gradle
[source,groovy]
----
graalvmNative {
    binaries {
        main {
            imageName.set('mn-graalvm-application') // <1>
            buildArgs.add('--verbose') // <2>
        }
    }
}
----
<1> The native executable name will now be `mn-graalvm-application`
<2> It is possible to pass extra arguments to build the native executable

:exclude-for-build:

:exclude-for-build:gradle

To generate native executables for each application using Maven run:

[source, bash]
----
./mvnw package -Dpackaging=native-image
----

The native executable is created in the `target` directory and can be run with `target/micronautguide`.

:exclude-for-build:

:exclude-for-languages:

For groovy should became

For maven should become

== Generate Micronaut Application Native Executables with GraalVM

We will use https://www.graalvm.org/[GraalVM], the polyglot embeddable virtual machine, to generate Native executables of our Micronaut applications.

Compiling native executables ahead-of-time with GraalVM improves startup time and reduces the memory footprint of JVM-based applications.

NOTE: Only Java and Kotlin projects support using GraalVM's `native-image` tool. Groovy relies heavily on reflection, which is only partially supported by GraalVM.

=== Native Executable generation

common:install-graalvm-sdkman.adoc[]

To generate native executables for each application using Maven run:

[source, bash]
----
./mvnw package -Dpackaging=native-image
----

The native executable is created in the `target` directory and can be run with `target/micronautguide`.

For gradle it should become

== Generate Micronaut Application Native Executables with GraalVM

We will use https://www.graalvm.org/[GraalVM], the polyglot embeddable virtual machine, to generate Native executables of our Micronaut applications.

Compiling native executables ahead-of-time with GraalVM improves startup time and reduces the memory footprint of JVM-based applications.

NOTE: Only Java and Kotlin projects support using GraalVM's `native-image` tool. Groovy relies heavily on reflection, which is only partially supported by GraalVM.

=== Native Executable generation

common:install-graalvm-sdkman.adoc[]

To generate native executables for each application using Gradle, run:

[source, bash]
----
./gradlew nativeCompile
----

The native executables are created in `build/native/nativeCompile` directory and can be run with `build/native/nativeCompile/micronautguide`.

It is possible to customize the name of a native executable or pass additional parameters to GraalVM:

.build.gradle
[source,groovy]
----
graalvmNative {
    binaries {
        main {
            imageName.set('mn-graalvm-application') // <1>
            buildArgs.add('--verbose') // <2>
        }
    }
}
----
<1> The native executable name will now be `mn-graalvm-application`
<2> It is possible to pass extra arguments to build the native executable