Skip to content

Commit

Permalink
Added Documentation building an executable with graalvm (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
KGoroll1 authored Mar 19, 2024
1 parent 9c29a10 commit 810c616
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions documentation/graalvm-build-guide.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
= Graalvm Build Guide

*1. Setup Graalvm*

* Update the file under e.g. C\Projects\IDEasy\settings and add
[width="100%",cols="100%",options="header",]
|===
a|
GRAALVM_EDITION=community
|===

This is necessary as the community edition of graalvm is delivered with a pre-installed native image.

* Open a command-line interface inside a devon installation e.g. C\Projects\IDEasy\workspaces\main
* Install Graalvm using the devonfw-ide with
[width="100%",cols="100%",options="header",]
|===
a|
devon graalvm setup
|===

When the installation is complete, the GRAALVM_HOME environment variable is automatically set to the graalvm installation path e.g. C/Projects/IDEasy/software/extra/graalvm

* Restart your cli
* Add *$GRAALVM_HOME/bin* to your *PATH* environment variable
Bash:

[width="100%",cols="100%",options="header",]
|===
a|
export PATH=$GRAALVM_HOME\bin:$PATH
|===

Powershell (run as Admin):

[width="100%",cols="100%",options="header",]
|===
a|
$path = [System.Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine) +
$newPath = "$env:GRAALVM_HOME\bin;" + $path +
[System.Environment]::SetEnvironmentVariable("Path", $newPath,
[System.EnvironmentVariableTarget]::Machine)
|===

*2. Install Dependencies*

*2.1 Windows: Install Visual Studio*

* Download Visual Studio from https://visualstudio.microsoft.com/downloads/
* During the installation, make sure to include the "Desktop development with CPP" workload, as this includes the necessary C/C++ compiler
image:images/cppInstall.png[image]
* If you already have Visual Studio installed, open the Visual Studio installer and click “modifyˮ on your existing installation.
Then select the C++ workload and click on install.

*2.2 Linux*

Install the zlib development package on your system:

[width="100%",cols="100%",options="header",]
|===
a|
sudo apt-get update +
sudo apt-get install zlib1g-dev
|===

*3. Build Your Application*

Run the following Maven command inside Intellij to compile your application and create an executable:

[width="100%",cols="100%",options="header",]
|===
a|
-B -ntp -Pnative -DskipTests=true package
|===

image:images/graalvmMvnArgs.png[image]

*Alternatively you can build the project using a cli:*

* Open *PowerShell* and check the java version with
[width="100%",cols="100%",options="header",]
|===
a|
java --version
|===

If the java version is below 17, you need to specify a JDK with version >=17.
e.g.

[width="100%",cols="100%",options="header",]
|===
a|
$env:JAVA_HOME = "C:\Projects\IDEasy\software\java\"
|===

This command sets the *JAVA_HOME* variable temporarily for the session and will be re-set after you close the shell.

* Run the following Maven command in your project directory where the pom.xml is located to compile your application and create an executable:
[width="100%",cols="100%",options="header",]
|===
a|
PATH/TO/MVN/mvn -B -ntp -Pnative -DskipTests=true package
|===

Example:

[width="100%",cols="100%",options="header",]
|===
a|
C:\Projects\IDEasy\workspaces\main\IDEasy> C:\Projects\IDEasy\software\mvn\bin\mvn -B -ntp -Pnative -DskipTests=true package
|===

Building the application might take up to 10 minutes depending on your machine.

*4. Run your Application* +
An ideasy executable (e.g. ideasy.exe under windows) should be created under *../workspace/main/IDEasy/cli/target*.

To run the application open a cli and pass your arguments.

Example:

[width="100%",cols="100%",options="header",]
|===
a|
C:\Projects\IDEasy\workspaces\main\IDEasy\cli\target> .\ideasy.exe mvn --version
|===

Binary file added documentation/images/cppInstall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/graalvmMvnArgs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 810c616

Please sign in to comment.