Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Documentation for building an executable with graalvm #248

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading