From fbd61acf9c22627710551118d71fa0475d87868d Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 20 Sep 2024 15:41:23 -0400 Subject: [PATCH 01/21] add PowerShell scripts for Windows --- install-jdks-windows.ps1 | 50 +++++++++++++++ setup.ps1 | 130 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 install-jdks-windows.ps1 create mode 100644 setup.ps1 diff --git a/install-jdks-windows.ps1 b/install-jdks-windows.ps1 new file mode 100644 index 00000000000..0a3a3b829d7 --- /dev/null +++ b/install-jdks-windows.ps1 @@ -0,0 +1,50 @@ +# Enable error handling +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' + +# winget may not be available for a few minutes if you just signed into Windows for the first time +if (-not (Get-Command 'winget.exe' -ErrorAction SilentlyContinue)) { + # this command will ensure it is available. + Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe -ErrorAction SilentlyContinue +} + +# if winget is still not available, it may not be pre-installed in your Windows version +if (-not (Get-Command 'winget.exe' -ErrorAction SilentlyContinue)) { + Write-Host 'Installing WinGet PowerShell module from PSGallery...' + Install-PackageProvider -Name NuGet -Force | Out-Null + Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null + Write-Host 'Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet...' + Repair-WinGetPackageManager + Write-Host 'WinGet.' +} + +# install the required JDKs +$jdkVersions = @('8', '11', '17', '21') + +foreach ($jdkVersion in $jdkVersions) { + Write-Host "ℹ️ Installing EclipseAdoptium.Temurin.${jdkVersion}.JDK" + winget install --silent --disable-interactivity --accept-package-agreements --source winget --exact --id "EclipseAdoptium.Temurin.${jdkVersion}.JDK" +} + +# find the JDK installation paths +if (Test-Path 'C:\Program Files\Eclipse Adoptium') { + $jdkDirs = Get-ChildItem -Path 'C:\Program Files\Eclipse Adoptium' -Directory +} else { + Write-Host '❌ Directory "C:\Program Files\Eclipse Adoptium" does not exist. Cannot set environment variables.' + exit 1 +} + +# set the required JDK environment variables +foreach ($jdkDir in $jdkDirs) { + if ($jdkDir.Name -match 'jdk-(\d+)\..*-hotspot') { + $jdkDirFullName = $jdkDir.FullName + $version = $matches[1] + $envVarName = "JAVA_${version}_HOME" + Write-Host "ℹ️ Setting $envVarName=$jdkDirFullName" + [System.Environment]::SetEnvironmentVariable($envVarName, $jdkDirFullName, [System.EnvironmentVariableTarget]::User) + } +} + +Write-Host 'ℹ️ Setting JAVA_HOME=%JAVA_8_HOME%' +[System.Environment]::SetEnvironmentVariable('JAVA_HOME', '%JAVA_8_HOME%', [System.EnvironmentVariableTarget]::User) diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 00000000000..1f7b04e5cf1 --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,130 @@ +# Enable error handling +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +function TestJvm { + param ($JavaHomeName, $ExpectedJavaVersion) + + if (-not (Test-Path "env:$JavaHomeName")) { + Write-Host "❌ $JavaHomeName is not set. Please set $JavaHomeName to refer to a JDK $ExpectedJavaVersion installation." -ForegroundColor Red + exit 1 + } + else { + $javaHome = Get-Item "env:$JavaHomeName" | Select-Object -ExpandProperty Value + + try { + # try to handle differences between PowerShell 7 and Windows PowerShell 5 + $ErrorActionPreference = 'Continue' + $javaVersionOutput = & "$javaHome\bin\java.exe" -version 2>&1 + } + catch { + Write-Host "❌ Error running `"$javaHome\bin\java.exe -version`". Please check that $JavaHomeName is set to a JDK $ExpectedJavaVersion installation." + exit 1 + } + finally { + $ErrorActionPreference = 'Stop' + } + + if ($javaVersionOutput[0] -notmatch "version `"$ExpectedJavaVersion") { + Write-Host "❌ $JavaHomeName is set to $javaHome, but it does not refer to a JDK $ExpectedJavaVersion installation." -ForegroundColor Red + exit 1 + } + else { + Write-Host "✅ $JavaHomeName is set to $javaHome." + } + } +} + +Write-Host 'ℹ️ Checking required JVM:' +if (Test-Path 'env:JAVA_HOME') { + TestJvm 'JAVA_HOME' '1.8' +} + +TestJvm 'JAVA_8_HOME' '1.8' +TestJvm 'JAVA_11_HOME' '11' +TestJvm 'JAVA_17_HOME' '17' +TestJvm 'JAVA_21_HOME' '21' +TestJvm 'JAVA_GRAALVM17_HOME' '17' + +# Check for required commands (e.g., git, docker) +function TestCommand { + param ($command) + + if (Get-Command $command -ErrorAction SilentlyContinue) { + Write-Host "✅ The $command command line is installed." + } + else { + Write-Host "❌ The $command command line is missing. Please install $command." -ForegroundColor Red + exit 1 + } +} + +function Get-FileHashMD5 { + param ($file) + return (Get-FileHash -Path $file -Algorithm MD5).Hash +} + +function TestHook { + param ($hookName) + + $hookChecksum = Get-FileHashMD5 ".githooks/$hookName" + $hooksPath = (git config core.hooksPath) -or '.git/hooks' + + if ((Test-Path ".git/hooks/$hookName") -and (Get-FileHashMD5 ".git/hooks/$hookName" -eq $hookChecksum)) { + Write-Host "✅ $hookName hook is installed in repository." + } + elseif ((Test-Path "$hooksPath/$hookName") -and (Get-FileHashMD5 "$hooksPath/$hookName" -eq $hookChecksum)) { + Write-Host "✅ $hookName hook is installed in git hooks path." + } + else { + Write-Host "🟨 $hookName hook was not found (optional but recommended)." + } +} + +function TestGitConfig { + param ($configName, $expectedValue) + + $actualValue = git config $configName + + if ($actualValue -eq $expectedValue) { + Write-Host "✅ git config $configName is set to $expectedValue." + } + elseif (-not $actualValue) { + Write-Host "❌ git config $configName is not set. Please set it to $expectedValue." -ForegroundColor Red + } + else { + Write-Host "🟨 git config $configName is set to $actualValue (expected: $expectedValue)." + } +} + +Write-Host 'ℹ️ Checking git configuration:' +TestCommand 'git' +TestHook 'pre-commit' +TestGitConfig 'submodule.recurse' 'true' + +# Check Docker environment +function TestDockerServer { + try { + # try to handle differences between PowerShell 7 and Windows PowerShell 5 + $ErrorActionPreference = 'Continue' + docker info *> $null + + if ($LASTEXITCODE -eq 0) { + Write-Host "✅ The Docker server is running." + } + else { + Write-Host "🟨 The Docker server is not running. Please start it to run all tests." + } + } + catch { + Write-Host "❌ Error running `"docker info *> $null`"." + exit 1 + } + finally { + $ErrorActionPreference = 'Stop' + } +} + +Write-Host 'ℹ️ Checking Docker environment:' +TestCommand 'docker' +TestDockerServer From 74f22b1f9fadf51a7bb064a7e461472425298cff Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 20 Sep 2024 15:42:54 -0400 Subject: [PATCH 02/21] fix typo and remove trailing whitespace in BUILDING.md --- BUILDING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index b07e1b2b201..054554e0a90 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -56,7 +56,7 @@ Requirements to build the full project: `sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-` * Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `.bashrc` or other. ```shell -export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home +export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home export JAVA_21_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home @@ -65,8 +65,8 @@ export JAVA_HOME=$JAVA_8_HOME ``` * Restart your shell after applying the changes if you appended the commands to your shell configuration file. -> [!NOTE] -> ARM users: there is no Oracle JDK v8 for ARM. +> [!NOTE] +> ARM users: there is no Oracle JDK v8 for ARM. > It's recommended to use [Azul's Zulu](https://www.azul.com/downloads/?version=java-8-lts&architecture=arm-64-bit&package=jdk#zulu) builds of Java 8. > [Amazon Corretto](https://aws.amazon.com/corretto/) builds have also been proven to work. @@ -77,7 +77,7 @@ export JAVA_HOME=$JAVA_8_HOME * Download and extract JDK 8, 11, 17 and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites). -* Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other. +* Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other. ```shell export JAVA_8_HOME=//jdk8u export JAVA_11_HOME=//jdk-11. @@ -101,7 +101,7 @@ export JAVA_HOME=$JAVA_8_HOME ### Install git -**On MacOS:** +**On MacOS:** You can trigger the installation by running any `git` command from the terminal, e.g. `git --version`. If not installed, the terminal will prompt you to install it. @@ -110,7 +110,7 @@ If not installed, the terminal will prompt you to install it. Run `apt-get install git`. -**On Windows:** +**On Windows:** Download and install [the installer](https://git-scm.com/download/win) from the official website. @@ -138,7 +138,7 @@ cp .githooks/pre-commit .git/hooks/ # On Windows cd dd-trace-java -copy .githooks/pre-comit .git/hooks/ +copy .githooks/pre-commit .git/hooks/ ``` > [!TIP] @@ -168,7 +168,7 @@ git config --local submodule.recurse true You can confirm that your development environment is properly set up using the [quick check](#development-environment-quick-check) `setup.sh` script. -> [!NOTE] +> [!NOTE] > The `setup.sh` script is only available for MacOS and Linux. ### Build the project From b48ff09eb2a8ec22810da147ec11394cfe586a45 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 10 Jan 2025 12:05:16 -0500 Subject: [PATCH 03/21] add more Windows instructions, misc tweaks in BUILDING.md --- BUILDING.md | 138 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 54 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 054554e0a90..a1a8344b329 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,4 +1,3 @@ - # Building This documentation provides information for developers to set up their environment and build their project from sources. @@ -10,10 +9,9 @@ This documentation provides information for developers to set up their environme ## Development environment quick check -To check that your development environment is properly set up to build the project, run `./setup.sh` from the project root. Your output should look something like the following. +To check that your development environment is properly set up to build the project, run `./setup.sh` on macOS or Linux (or `.\setup.ps1` on Windows) from the project root. Your output should look something like the following: -```bash -$ ./setup.sh +``` ℹ️ Checking required JVM: ✅ JAVA_HOME is set to /Users/datadog/.sdkman/candidates/java/8.0.402-zulu. ✅ JAVA_8_HOME is set to /Users/datadog/.sdkman/candidates/java/8.0.402-zulu. @@ -48,7 +46,10 @@ Requirements to build the full project: ### Install the required JDKs -**On MacOS:** +Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. + +
+macOS * Install the required JDKs using `brew`. `brew install --cask zulu@8 zulu@11 zulu@17 zulu@21 graalvm/tap/graalvm-ce-java17` @@ -73,9 +74,12 @@ export JAVA_HOME=$JAVA_8_HOME > [!NOTE] > MacOS users: remember that `/usr/libexec/java_home` may control which JDK is in your path. -**On Linux:** +
-* Download and extract JDK 8, 11, 17 and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). +
+Linux + +* Download and extract JDK 8, 11, 17, and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites). * Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other. ```shell @@ -88,20 +92,43 @@ export JAVA_HOME=$JAVA_8_HOME ``` * Restart your shell after applying the changes if you appended the commands to your shell configuration file. -**On Windows:** +
+ +
+Windows + +Use the `install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. + +To install the JDKs manually using `winget`, use the following commands. After the JDKs are installed, you can still use `install-jdks-windows.ps1` to add the environment variables. -* Download and install JDK 8, 11, 17 and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). +``` +winget install --id EclipseAdoptium.Temurin.8.JDK +winget install --id EclipseAdoptium.Temurin.11.JDK +winget install --id EclipseAdoptium.Temurin.17.JDK +winget install --id EclipseAdoptium.Temurin.21.JDK +``` + +To install the JDKs manually: +* Download SDKs manually from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows). -* Add the required environment variables. - * Open the *Start Menu*, type `environment variable`, and use the *Edit environment variable for your account* entry to open the *System Properties*. - * Add new entries to the table. - * `JAVA_8_HOME` to the JDK 8 installation folder, usually `C:\Program Files\Eclipse Adoptium\jdk--hotspot\bin` - * `JAVA_11_HOME`, `JAVA_21_HOME`, and `JAVA_21_HOME` similarly to their respective installation `bin` folders - * `JAVA_GRAALVM17_HOME` to the GraalVM installation folder, usually `C:\Program Files\Java\\bin` -### Install git +To add the required environment variables manually from PowerShell, run this command for each SDK version: +```pwsh +[Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk--hotspot", [EnvironmentVariableTarget]::User) +``` + +To add the required environment variables manually using the UI: +* Open the *Start Menu*, type `environment variable`, and use the *Edit environment variable for your account* entry to open the *System Properties*. +* Add new entries to the table: + * `JAVA_8_HOME` to the JDK 8 installation folder, usually `C:\Program Files\Eclipse Adoptium\jdk--hotspot\bin` + * `JAVA_11_HOME`, `JAVA_17_HOME`, and `JAVA_21_HOME` similarly to their respective installation `bin` folders + * `JAVA_GRAALVM17_HOME` to the GraalVM installation folder, usually `C:\Program Files\Java\\bin` -**On MacOS:** +
+ +### Install `git` + +**On macOS:** You can trigger the installation by running any `git` command from the terminal, e.g. `git --version`. If not installed, the terminal will prompt you to install it. @@ -112,64 +139,67 @@ Run `apt-get install git`. **On Windows:** -Download and install [the installer](https://git-scm.com/download/win) from the official website. +Run `winget install --id git.git`. Alternatively, download and install the installer from [the official website](https://git-scm.com/download/win). ### Install Docker Desktop -Download and install Docker Desktop from the offical website for [MacOS](https://docs.docker.com/desktop/install/mac-install/), [Linux](https://docs.docker.com/desktop/install/linux-install/) or [Windows](https://docs.docker.com/desktop/install/windows-install/). - > [!NOTE] > Docker Desktop is the recommended container runtime environment, but you can use any other environment to run testcontainers tests. > Check [the testcontainers container runtime requirements](https://java.testcontainers.org/supported_docker_environment/) for more details. -### Clone the repository and set up git +**On macOS:** -* Get a copy of the project. - * In your workspace, clone the repository using git. -```bash -git clone --recurse-submodules git@github.com:DataDog/dd-trace-java.git -``` -* Install the project git hooks. - * There is a pre-commit hook setup to verify formatting before committing. It can be activated with the following command. -```bash -# On MacOS and Linux -cd dd-trace-java -cp .githooks/pre-commit .git/hooks/ +Download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/mac-install/ -# On Windows -cd dd-trace-java -copy .githooks/pre-commit .git/hooks/ -``` +**On Linux:** -> [!TIP] -> You can alternatively use the `core.hooksPath` configuration to point to the `.githooks` folder using `git config --local core.hooksPath .githooks` if you don't already have a hooks path defined system-wide. +Download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/linux/ -> [!NOTE] -> The git hooks will check that your code is properly formatted before commiting. -> This is done both to avoid future merge conflict and ensure uniformity inside the code base. +**On Windows:** + +Run `winget install --id Docker.DockerDesktop`. + +Alternatively, download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/windows-install/ + +### Clone the repository and set up git + +* Get a copy of the project by cloning the repository using git in your workspace: + ```bash + git clone --recurse-submodules git@github.com:DataDog/dd-trace-java.git + ``` +* There is a pre-commit hook setup to verify formatting before committing. It can be activated with the following command: + ```bash + # On bash-like shells shells or PowerShell + cd dd-trace-java + cp .githooks/pre-commit .git/hooks/ + ``` + + > [!TIP] + > You can alternatively use the `core.hooksPath` configuration to point to the `.githooks` folder using `git config --local core.hooksPath .githooks` if you don't already have a hooks path defined system-wide. + + > [!NOTE] + > The git hooks will check that your code is properly formatted before commiting. + > This is done both to avoid future merge conflict and ensure uniformity inside the code base. * Configure git to automatically update submodules. -```bash -git config --local submodule.recurse true -``` + ```bash + git config --local submodule.recurse true + ``` -> [!NOTE] -> Git does not automatically update submodules when switching branches. -> Without this configuration, you will need to remember to add `--recurse-submodules` to `git checkout` when switching to old branches. + > [!NOTE] + > Git does not automatically update submodules when switching branches. + > Without this configuration, you will need to remember to add `--recurse-submodules` to `git checkout` when switching to old branches. -> [!TIP] -> This will keep the submodule in `dd-java-agent/agent-jmxfetch/integrations-core` up-to-date. -> There is also an automated check when opening a pull request if you are trying to submit a module version change (usually an outdated version). + > [!TIP] + > This will keep the submodule in `dd-java-agent/agent-jmxfetch/integrations-core` up-to-date. + > There is also an automated check when opening a pull request if you are trying to submit a module version change (usually an outdated version). > [!NOTE] > Both git configurations (hooks and submodule) will only be applied to this project and won't apply globally in your setup. ### Check your development environment -You can confirm that your development environment is properly set up using the [quick check](#development-environment-quick-check) `setup.sh` script. - -> [!NOTE] -> The `setup.sh` script is only available for MacOS and Linux. +You can confirm that your development environment is properly set up using the [quick check](#development-environment-quick-check) `setup.sh` script on macOS or Linux or `setup.ps1` on Windows. ### Build the project From 328979f52202c12c9ebbe6846a7692ce3acc61fc Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 10 Jan 2025 18:46:35 -0500 Subject: [PATCH 04/21] more changes in BUILDING.md --- BUILDING.md | 204 ++++++++++++++++++++++++++++------------------------ 1 file changed, 112 insertions(+), 92 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index a1a8344b329..29acfafa21d 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,15 +1,42 @@ -# Building +# Building This documentation provides information for developers to set up their environment and build their project from sources. -* [Development environment quick check](#development-environment-quick-check) -* [Environment requirements quick check](#environment-requirements-quick-check) -* [Development environment set up](#development-environment-set-up) -* [Project build](#project-build) +* [Development environment](#development-environment) + * [Requirements](#requirements) + * [Quick check](#quick-check) + * [Install the required JDKs](#install-the-required-jdks) + * [Install git](#install-git) + * [Install Docker Desktop](#install-docker-desktop) +* [Clone the repository and set up git](#clone-the-repository-and-set-up-git) +* [Building the project](#building-the-project) -## Development environment quick check +## Development environment -To check that your development environment is properly set up to build the project, run `./setup.sh` on macOS or Linux (or `.\setup.ps1` on Windows) from the project root. Your output should look something like the following: +### Requirements + +Requirements to build the full project: + +* The JDK versions 8, 11, 17 and 21 must be installed. +* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME` and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. +* The JDK-8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). +* The `JAVA_HOME` environment variable may be unset. If set, it must point to the JDK 8 location (same as `JAVA_8_HOME`). +* The `git` command line must be installed. +* A container runtime environment must be available to run all tests (e.g. Docker Desktop). + +### Quick check + +To check that your development environment is properly set up to build the project, from the project root run on macOS or Linux: +```shell +./setup.sh +``` + +or on Windows: +```pwsh +.\setup.ps1 +``` + +Your output should look something like the following: ``` ℹ️ Checking required JVM: @@ -29,41 +56,32 @@ To check that your development environment is properly set up to build the proje ✅ The Docker server is running. ``` -If there is any issue with your output, you can check the requirements and/or follow the guide below to install and configure the required tools. +If there is any issue with your output, check the requirements above and use the following guide to install and configure the required tools. -## Environment requirements quick check - -Requirements to build the full project: - -* The JDK versions 8, 11, 17 and 21 must be installed. -* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME` and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. -* The JDK-8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). -* The `JAVA_HOME` environment variable may be unset. If set, it must point to the JDK 8 location (same as `JAVA_8_HOME`). -* The `git` command line must be installed. -* A container runtime environment must be available to run all tests (e.g. Docker Desktop). - -## Development environment set up ### Install the required JDKs Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. -
-macOS +#### macOS -* Install the required JDKs using `brew`. -`brew install --cask zulu@8 zulu@11 zulu@17 zulu@21 graalvm/tap/graalvm-ce-java17` -* Fix the GraalVM installation by [removing the quarantine flag](https://www.graalvm.org/latest/docs/getting-started/macos/). -`sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-` +* Install the required JDKs using `brew`: + ```shell + brew install --cask zulu@8 zulu@11 zulu@17 zulu@21 graalvm/tap/graalvm-ce-java17 + ``` +* Fix the GraalVM installation by [removing the quarantine flag](https://www.graalvm.org/latest/docs/getting-started/macos/): + ``` + sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm- + ``` * Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `.bashrc` or other. -```shell -export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home -export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home -export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home -export JAVA_21_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home -export JAVA_GRAALVM17_HOME=/Library/Java/JavaVirtualMachines/graalvm-/Contents/Home -export JAVA_HOME=$JAVA_8_HOME -``` + ```shell + export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home + export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home + export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home + export JAVA_21_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home + export JAVA_GRAALVM17_HOME=/Library/Java/JavaVirtualMachines/graalvm-/Contents/Home + export JAVA_HOME=$JAVA_8_HOME + ``` * Restart your shell after applying the changes if you appended the commands to your shell configuration file. > [!NOTE] @@ -72,34 +90,34 @@ export JAVA_HOME=$JAVA_8_HOME > [Amazon Corretto](https://aws.amazon.com/corretto/) builds have also been proven to work. > [!NOTE] -> MacOS users: remember that `/usr/libexec/java_home` may control which JDK is in your path. - -
+> macOS users: remember that `/usr/libexec/java_home` may control which JDK is in your path. -
-Linux +#### Linux * Download and extract JDK 8, 11, 17, and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites). * Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other. -```shell -export JAVA_8_HOME=//jdk8u -export JAVA_11_HOME=//jdk-11. -export JAVA_17_HOME=//jdk-17. -export JAVA_21_HOME=//jdk-21. -export JAVA_GRAALVM17_HOME=//graalvm-jdk-17./Contents/Home -export JAVA_HOME=$JAVA_8_HOME -``` + ```shell + export JAVA_8_HOME=//jdk8u + export JAVA_11_HOME=//jdk-11. + export JAVA_17_HOME=//jdk-17. + export JAVA_21_HOME=//jdk-21. + export JAVA_GRAALVM17_HOME=//graalvm-jdk-17./Contents/Home + export JAVA_HOME=$JAVA_8_HOME + ``` * Restart your shell after applying the changes if you appended the commands to your shell configuration file. -
- -
-Windows +#### Windows Use the `install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. -To install the JDKs manually using `winget`, use the following commands. After the JDKs are installed, you can still use `install-jdks-windows.ps1` to add the environment variables. +> [!NOTE] +> This scripts currently does _not_ install GraalVM. + +
+Manual installation + +* To install the JDKs manually, download the installers from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/), or use `winget`: ``` winget install --id EclipseAdoptium.Temurin.8.JDK @@ -108,38 +126,40 @@ winget install --id EclipseAdoptium.Temurin.17.JDK winget install --id EclipseAdoptium.Temurin.21.JDK ``` -To install the JDKs manually: -* Download SDKs manually from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows). -To add the required environment variables manually from PowerShell, run this command for each SDK version: -```pwsh -[Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk--hotspot", [EnvironmentVariableTarget]::User) -``` +* To add the required environment variables, run this PowerShell command for each SDK version: + ```pwsh + [Environment]::SetEnvironmentVariable("JAVA__HOME", "C:\Program Files\Eclipse Adoptium\", [EnvironmentVariableTarget]::User) + ``` -To add the required environment variables manually using the UI: -* Open the *Start Menu*, type `environment variable`, and use the *Edit environment variable for your account* entry to open the *System Properties*. -* Add new entries to the table: - * `JAVA_8_HOME` to the JDK 8 installation folder, usually `C:\Program Files\Eclipse Adoptium\jdk--hotspot\bin` - * `JAVA_11_HOME`, `JAVA_17_HOME`, and `JAVA_21_HOME` similarly to their respective installation `bin` folders - * `JAVA_GRAALVM17_HOME` to the GraalVM installation folder, usually `C:\Program Files\Java\\bin` + For example: + ```pwsh + [Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) + ```
-### Install `git` +### Install git -**On macOS:** +#### macOS You can trigger the installation by running any `git` command from the terminal, e.g. `git --version`. If not installed, the terminal will prompt you to install it. -**On Linux:** +#### Linux + +```shell +apt-get install git +``` -Run `apt-get install git`. +#### Windows -**On Windows:** +```pwsh +winget install --id git.git +``` -Run `winget install --id git.git`. Alternatively, download and install the installer from [the official website](https://git-scm.com/download/win). +Alternatively, download and install the installer from [the official website](https://git-scm.com/download/win). ### Install Docker Desktop @@ -147,29 +167,35 @@ Run `winget install --id git.git`. Alternatively, download and install the insta > Docker Desktop is the recommended container runtime environment, but you can use any other environment to run testcontainers tests. > Check [the testcontainers container runtime requirements](https://java.testcontainers.org/supported_docker_environment/) for more details. -**On macOS:** +#### macOS + +Download and install Docker Desktop from the offical website:
+https://docs.docker.com/desktop/setup/install/mac-install/ -Download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/mac-install/ +#### Linux -**On Linux:** +Download and install Docker Desktop from the offical website:
+https://docs.docker.com/desktop/setup/install/linux/ -Download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/linux/ +#### Windows -**On Windows:** +Use `winget` to install Docker Desktop: -Run `winget install --id Docker.DockerDesktop`. +```pwsh +winget install --id Docker.DockerDesktop +``` -Alternatively, download and install Docker Desktop from the offical website: https://docs.docker.com/desktop/setup/install/windows-install/ +Alternatively, download and install Docker Desktop from the offical website:
+https://docs.docker.com/desktop/setup/install/windows-install/ -### Clone the repository and set up git +## Clone the repository and set up git * Get a copy of the project by cloning the repository using git in your workspace: - ```bash + ```shell git clone --recurse-submodules git@github.com:DataDog/dd-trace-java.git ``` * There is a pre-commit hook setup to verify formatting before committing. It can be activated with the following command: - ```bash - # On bash-like shells shells or PowerShell + ```shell cd dd-trace-java cp .githooks/pre-commit .git/hooks/ ``` @@ -182,7 +208,7 @@ Alternatively, download and install Docker Desktop from the offical website: htt > This is done both to avoid future merge conflict and ensure uniformity inside the code base. * Configure git to automatically update submodules. - ```bash + ```shell git config --local submodule.recurse true ``` @@ -197,23 +223,17 @@ Alternatively, download and install Docker Desktop from the offical website: htt > [!NOTE] > Both git configurations (hooks and submodule) will only be applied to this project and won't apply globally in your setup. -### Check your development environment - -You can confirm that your development environment is properly set up using the [quick check](#development-environment-quick-check) `setup.sh` script on macOS or Linux or `setup.ps1` on Windows. - -### Build the project +## Building the project After everything is properly set up, you can move on to the next section to start a build or check [the contribution guidelines](CONTRIBUTING.md). -## Project build - To build the project without running tests, run: -```bash +```shell ./gradlew clean assemble ``` To build the entire project with tests (this can take a very long time), run: -```bash +```shell ./gradlew clean build ``` @@ -223,7 +243,7 @@ To build the entire project with tests (this can take a very long time), run: > It is recommended to only run the tests related to your changes locally and leave running the whole test suite to the continuous integration platform. To build the JVM agent artifact only, run: -```bash +```shell ./gradlew :dd-java-agent:shadowJar ``` From 0b4160ff1146353dc9bc9cb36235e5d2f1cc6724 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Tue, 14 Jan 2025 17:14:37 -0500 Subject: [PATCH 05/21] use explicit value for JAVA_HOME instead of "%JAVA_8_HOME%" --- install-jdks-windows.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install-jdks-windows.ps1 b/install-jdks-windows.ps1 index 0a3a3b829d7..e07ac1c4043 100644 --- a/install-jdks-windows.ps1 +++ b/install-jdks-windows.ps1 @@ -43,8 +43,10 @@ foreach ($jdkDir in $jdkDirs) { $envVarName = "JAVA_${version}_HOME" Write-Host "ℹ️ Setting $envVarName=$jdkDirFullName" [System.Environment]::SetEnvironmentVariable($envVarName, $jdkDirFullName, [System.EnvironmentVariableTarget]::User) + + if ($version -eq '8') { + Write-Host "ℹ️ Setting JAVA_HOME=$jdkDirFullName" + [System.Environment]::SetEnvironmentVariable('JAVA_HOME', $jdkDirFullName, [System.EnvironmentVariableTarget]::User) + } } } - -Write-Host 'ℹ️ Setting JAVA_HOME=%JAVA_8_HOME%' -[System.Environment]::SetEnvironmentVariable('JAVA_HOME', '%JAVA_8_HOME%', [System.EnvironmentVariableTarget]::User) From 02655311795f9736108ee48a01a86e2d56414487 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Tue, 14 Jan 2025 17:57:21 -0500 Subject: [PATCH 06/21] Update install-jdks-windows.ps1 --- install-jdks-windows.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/install-jdks-windows.ps1 b/install-jdks-windows.ps1 index e07ac1c4043..90a45af7dcc 100644 --- a/install-jdks-windows.ps1 +++ b/install-jdks-windows.ps1 @@ -6,6 +6,7 @@ $ProgressPreference = 'SilentlyContinue' # winget may not be available for a few minutes if you just signed into Windows for the first time if (-not (Get-Command 'winget.exe' -ErrorAction SilentlyContinue)) { # this command will ensure it is available. + Write-Host 'WinGet not availalbe. Trying to enable WinGet...' Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe -ErrorAction SilentlyContinue } From 72d18689b550087804a2307601f3859ae12e4005 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 17 Jan 2025 13:45:06 -0500 Subject: [PATCH 07/21] move JDK install powershell script --- install-jdks-windows.ps1 => tooling/install-jdks-windows.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename install-jdks-windows.ps1 => tooling/install-jdks-windows.ps1 (100%) diff --git a/install-jdks-windows.ps1 b/tooling/install-jdks-windows.ps1 similarity index 100% rename from install-jdks-windows.ps1 rename to tooling/install-jdks-windows.ps1 From dd63642d9362c7f1b1a78b842b084c9d85684b86 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 17 Jan 2025 13:45:24 -0500 Subject: [PATCH 08/21] update BUILDING.md --- BUILDING.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 29acfafa21d..4555350ca9f 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -18,8 +18,8 @@ This documentation provides information for developers to set up their environme Requirements to build the full project: * The JDK versions 8, 11, 17 and 21 must be installed. -* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME` and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. -* The JDK-8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). +* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME`, and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. +* The JDK 8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). * The `JAVA_HOME` environment variable may be unset. If set, it must point to the JDK 8 location (same as `JAVA_8_HOME`). * The `git` command line must be installed. * A container runtime environment must be available to run all tests (e.g. Docker Desktop). @@ -109,15 +109,15 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. #### Windows -Use the `install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. +Use the `tooling/install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. > [!NOTE] -> This scripts currently does _not_ install GraalVM. +> This scripts currently does _not_ install GraalVM due to license changes in October 2024.
Manual installation -* To install the JDKs manually, download the installers from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/), or use `winget`: +* To install the JDKs manually, download the installers from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and or use `winget`: ``` winget install --id EclipseAdoptium.Temurin.8.JDK @@ -125,17 +125,16 @@ winget install --id EclipseAdoptium.Temurin.11.JDK winget install --id EclipseAdoptium.Temurin.17.JDK winget install --id EclipseAdoptium.Temurin.21.JDK ``` +* Install GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). Note that GraalVM for JDK 17.0.13 and later are released under a different license and may be unavailable. + * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows). -* Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows). - -* To add the required environment variables, run this PowerShell command for each SDK version: - ```pwsh - [Environment]::SetEnvironmentVariable("JAVA__HOME", "C:\Program Files\Eclipse Adoptium\", [EnvironmentVariableTarget]::User) - ``` - - For example: +* To add the required environment variables, run the following PowerShell commands for each SDK version, replacing `` with the full version number. For example, `C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot`. ```pwsh - [Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("JAVA_11_HOME", "C:\Program Files\Eclipse Adoptium\jdk-11.0.25.9-hotspot", [EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("JAVA_17_HOME", "C:\Program Files\Eclipse Adoptium\jdk-17.0.12.7-hotspot", [EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("JAVA_21_HOME", "C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot", [EnvironmentVariableTarget]::User) ```
From 80671d60ffc1d3261dc78f2bde05020f32e9c5b8 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 17 Jan 2025 13:54:45 -0500 Subject: [PATCH 09/21] add comments about GraalVM license --- BUILDING.md | 2 +- setup.ps1 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 4555350ca9f..f03e9d5159f 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -112,7 +112,7 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. Use the `tooling/install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. > [!NOTE] -> This scripts currently does _not_ install GraalVM due to license changes in October 2024. +> This scripts currently does _not_ install GraalVM due to license changes in October 2024 for GraalVM 17.0.13 and later.
Manual installation diff --git a/setup.ps1 b/setup.ps1 index 1f7b04e5cf1..c89f539f47e 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -44,7 +44,8 @@ TestJvm 'JAVA_8_HOME' '1.8' TestJvm 'JAVA_11_HOME' '11' TestJvm 'JAVA_17_HOME' '17' TestJvm 'JAVA_21_HOME' '21' -TestJvm 'JAVA_GRAALVM17_HOME' '17' +# GraalVM cannot currently be installed due to license change in October 2024 for GraalVM 17.0.13 and later. +# TestJvm 'JAVA_GRAALVM17_HOME' '17' # Check for required commands (e.g., git, docker) function TestCommand { From ac6aeaa9691799df8d403a760c9f7be26c2923fa Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Fri, 17 Jan 2025 13:54:54 -0500 Subject: [PATCH 10/21] add script descriptions --- setup.ps1 | 8 +++++++- tooling/install-jdks-windows.ps1 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/setup.ps1 b/setup.ps1 index c89f539f47e..2e0b0d06ab8 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -1,7 +1,13 @@ -# Enable error handling +<# + .DESCRIPTION + This script checks the development environment for required tools and configurations. +#> + +# Enable error handling Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' +# Check for required JDKs function TestJvm { param ($JavaHomeName, $ExpectedJavaVersion) diff --git a/tooling/install-jdks-windows.ps1 b/tooling/install-jdks-windows.ps1 index 90a45af7dcc..5794413f4ac 100644 --- a/tooling/install-jdks-windows.ps1 +++ b/tooling/install-jdks-windows.ps1 @@ -1,4 +1,9 @@ -# Enable error handling +<# + .DESCRIPTION + This script installs the required JDKs and sets the environment variables for them. +#> + +# Enable error handling Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' From 8bc08dd2e3d87d4d0d86980611ec5be61f076e3a Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Tue, 28 Jan 2025 13:46:38 -0500 Subject: [PATCH 11/21] add comment to explain "omit from toc" --- BUILDING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILDING.md b/BUILDING.md index f03e9d5159f..ea9de22917b 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,4 +1,5 @@ # Building + This documentation provides information for developers to set up their environment and build their project from sources. From b95f372f268b28ba4550037f01a27743a33234d2 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Tue, 28 Jan 2025 13:46:57 -0500 Subject: [PATCH 12/21] move "Quick check" up --- BUILDING.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index ea9de22917b..e6ccf91dae5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -4,8 +4,8 @@ This documentation provides information for developers to set up their environment and build their project from sources. * [Development environment](#development-environment) - * [Requirements](#requirements) * [Quick check](#quick-check) + * [Requirements](#requirements) * [Install the required JDKs](#install-the-required-jdks) * [Install git](#install-git) * [Install Docker Desktop](#install-docker-desktop) @@ -14,17 +14,6 @@ This documentation provides information for developers to set up their environme ## Development environment -### Requirements - -Requirements to build the full project: - -* The JDK versions 8, 11, 17 and 21 must be installed. -* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME`, and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. -* The JDK 8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). -* The `JAVA_HOME` environment variable may be unset. If set, it must point to the JDK 8 location (same as `JAVA_8_HOME`). -* The `git` command line must be installed. -* A container runtime environment must be available to run all tests (e.g. Docker Desktop). - ### Quick check To check that your development environment is properly set up to build the project, from the project root run on macOS or Linux: @@ -59,6 +48,16 @@ Your output should look something like the following: If there is any issue with your output, check the requirements above and use the following guide to install and configure the required tools. +### Requirements + +Requirements to build the full project: + +* The JDK versions 8, 11, 17 and 21 must be installed. +* The `JAVA_8_HOME`, `JAVA_11_HOME`, `JAVA_17_HOME`, `JAVA_21_HOME`, and `JAVA_GRAALVM17_HOME` must point to their respective JDK location. +* The JDK 8 `bin` directory must be the only JDK on the PATH (e.g. `$JAVA_8_HOME/bin`). +* The `JAVA_HOME` environment variable may be unset. If set, it must point to the JDK 8 location (same as `JAVA_8_HOME`). +* The `git` command line must be installed. +* A container runtime environment must be available to run all tests (e.g. Docker Desktop). ### Install the required JDKs From 146b0bdfebda78fe48bbacd9530912227bc7ba72 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 09:15:59 -0500 Subject: [PATCH 13/21] remove Windows install script for now --- tooling/install-jdks-windows.ps1 | 58 -------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 tooling/install-jdks-windows.ps1 diff --git a/tooling/install-jdks-windows.ps1 b/tooling/install-jdks-windows.ps1 deleted file mode 100644 index 5794413f4ac..00000000000 --- a/tooling/install-jdks-windows.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -<# - .DESCRIPTION - This script installs the required JDKs and sets the environment variables for them. -#> - -# Enable error handling -Set-StrictMode -Version Latest -$ErrorActionPreference = 'Stop' -$ProgressPreference = 'SilentlyContinue' - -# winget may not be available for a few minutes if you just signed into Windows for the first time -if (-not (Get-Command 'winget.exe' -ErrorAction SilentlyContinue)) { - # this command will ensure it is available. - Write-Host 'WinGet not availalbe. Trying to enable WinGet...' - Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe -ErrorAction SilentlyContinue -} - -# if winget is still not available, it may not be pre-installed in your Windows version -if (-not (Get-Command 'winget.exe' -ErrorAction SilentlyContinue)) { - Write-Host 'Installing WinGet PowerShell module from PSGallery...' - Install-PackageProvider -Name NuGet -Force | Out-Null - Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null - Write-Host 'Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet...' - Repair-WinGetPackageManager - Write-Host 'WinGet.' -} - -# install the required JDKs -$jdkVersions = @('8', '11', '17', '21') - -foreach ($jdkVersion in $jdkVersions) { - Write-Host "ℹ️ Installing EclipseAdoptium.Temurin.${jdkVersion}.JDK" - winget install --silent --disable-interactivity --accept-package-agreements --source winget --exact --id "EclipseAdoptium.Temurin.${jdkVersion}.JDK" -} - -# find the JDK installation paths -if (Test-Path 'C:\Program Files\Eclipse Adoptium') { - $jdkDirs = Get-ChildItem -Path 'C:\Program Files\Eclipse Adoptium' -Directory -} else { - Write-Host '❌ Directory "C:\Program Files\Eclipse Adoptium" does not exist. Cannot set environment variables.' - exit 1 -} - -# set the required JDK environment variables -foreach ($jdkDir in $jdkDirs) { - if ($jdkDir.Name -match 'jdk-(\d+)\..*-hotspot') { - $jdkDirFullName = $jdkDir.FullName - $version = $matches[1] - $envVarName = "JAVA_${version}_HOME" - Write-Host "ℹ️ Setting $envVarName=$jdkDirFullName" - [System.Environment]::SetEnvironmentVariable($envVarName, $jdkDirFullName, [System.EnvironmentVariableTarget]::User) - - if ($version -eq '8') { - Write-Host "ℹ️ Setting JAVA_HOME=$jdkDirFullName" - [System.Environment]::SetEnvironmentVariable('JAVA_HOME', $jdkDirFullName, [System.EnvironmentVariableTarget]::User) - } - } -} From 5d19bff79c67cfb91941d87ccb54a0d9f39d397c Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 09:29:21 -0500 Subject: [PATCH 14/21] rewrite Windows sections to focus on manual installation --- BUILDING.md | 64 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index e6ccf91dae5..a135af2958d 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -109,35 +109,47 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. #### Windows -Use the `tooling/install-jdks-windows.ps1` script to download and install Eclipse Temurin JDK versions 8, 11, 17, and 21, and set the required environment variables. +* Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/). Alternatively, if available, you can use `winget` or `scoop`: -> [!NOTE] -> This scripts currently does _not_ install GraalVM due to license changes in October 2024 for GraalVM 17.0.13 and later. +
+ Install JDKs using `winget` -
-Manual installation + ```pwsh + winget install --id EclipseAdoptium.Temurin.8.JDK + winget install --id EclipseAdoptium.Temurin.11.JDK + winget install --id EclipseAdoptium.Temurin.17.JDK + winget install --id EclipseAdoptium.Temurin.21.JDK + ``` -* To install the JDKs manually, download the installers from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and or use `winget`: +
-``` -winget install --id EclipseAdoptium.Temurin.8.JDK -winget install --id EclipseAdoptium.Temurin.11.JDK -winget install --id EclipseAdoptium.Temurin.17.JDK -winget install --id EclipseAdoptium.Temurin.21.JDK -``` -* Install GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). Note that GraalVM for JDK 17.0.13 and later are released under a different license and may be unavailable. - * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows). +
+ Install JDKs using `scoop` -* To add the required environment variables, run the following PowerShell commands for each SDK version, replacing `` with the full version number. For example, `C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot`. ```pwsh - [Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) + scoop bucket add java + + scoop install temurin8-jdk + scoop install temurin11-jdk + scoop install temurin17-jdk + scoop install temurin21-jdk + ``` + +
+ +* To add the required environment variables, run the following PowerShell commands for each SDK version, replacing the path with the correct version installed: + ```pwsh [Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) [Environment]::SetEnvironmentVariable("JAVA_11_HOME", "C:\Program Files\Eclipse Adoptium\jdk-11.0.25.9-hotspot", [EnvironmentVariableTarget]::User) [Environment]::SetEnvironmentVariable("JAVA_17_HOME", "C:\Program Files\Eclipse Adoptium\jdk-17.0.12.7-hotspot", [EnvironmentVariableTarget]::User) [Environment]::SetEnvironmentVariable("JAVA_21_HOME", "C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot", [EnvironmentVariableTarget]::User) + + # JAVA_HOME = JAVA_8_HOME + [Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) ``` -
+> [!NOTE] +> This scripts currently does _not_ install GraalVM due to license changes in October 2024 for GraalVM 17.0.13 and later. ### Install git @@ -154,11 +166,27 @@ apt-get install git #### Windows +Download and install the installer from [the official website](https://git-scm.com/download/win). + +Alternatively, you can use `winget` or `scoop`: + +
+Install git using winget + ```pwsh winget install --id git.git ``` -Alternatively, download and install the installer from [the official website](https://git-scm.com/download/win). +
+ +
+Install git using scoop + +```pwsh +scoop install git +``` + +
### Install Docker Desktop From e0e97cd23bca881f4bb3c7d8875b66ca644443d9 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 09:38:19 -0500 Subject: [PATCH 15/21] remove toc comments --- BUILDING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index a135af2958d..7bf9d042a4b 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,5 +1,4 @@ -# Building - +# Building This documentation provides information for developers to set up their environment and build their project from sources. From 5b293fcbcc82d1d77b530741c27531bc9216c4e0 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 10:25:00 -0500 Subject: [PATCH 16/21] more updates to Windows instructions --- BUILDING.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 7bf9d042a4b..ada4f41da8e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -108,10 +108,10 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. #### Windows -* Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/). Alternatively, if available, you can use `winget` or `scoop`: +* Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/). Alternatively, you can use `winget` or `scoop`:
- Install JDKs using `winget` + Install JDKs using winget ```pwsh winget install --id EclipseAdoptium.Temurin.8.JDK @@ -123,11 +123,10 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM.
- Install JDKs using `scoop` + Install JDKs using scoop ```pwsh scoop bucket add java - scoop install temurin8-jdk scoop install temurin11-jdk scoop install temurin17-jdk @@ -136,7 +135,7 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM.
-* To add the required environment variables, run the following PowerShell commands for each SDK version, replacing the path with the correct version installed: +* To add the required environment variables, run the following PowerShell commands for each SDK version, replacing the paths with the correct version installed: ```pwsh [Environment]::SetEnvironmentVariable("JAVA_8_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) [Environment]::SetEnvironmentVariable("JAVA_11_HOME", "C:\Program Files\Eclipse Adoptium\jdk-11.0.25.9-hotspot", [EnvironmentVariableTarget]::User) @@ -147,9 +146,6 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. [Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-8.0.432.6-hotspot", [EnvironmentVariableTarget]::User) ``` -> [!NOTE] -> This scripts currently does _not_ install GraalVM due to license changes in October 2024 for GraalVM 17.0.13 and later. - ### Install git #### macOS @@ -165,9 +161,7 @@ apt-get install git #### Windows -Download and install the installer from [the official website](https://git-scm.com/download/win). - -Alternatively, you can use `winget` or `scoop`: +Download and install the installer from [the official website](https://git-scm.com/download/win). Alternatively, you can use `winget` or `scoop`:
Install git using winget @@ -205,14 +199,19 @@ https://docs.docker.com/desktop/setup/install/linux/ #### Windows -Use `winget` to install Docker Desktop: +Download and install Docker Desktop from the offical website:
+https://docs.docker.com/desktop/setup/install/windows-install/ + +Alternatively, you can use `winget`: + +
+Install Docker Desktop using winget ```pwsh winget install --id Docker.DockerDesktop ``` -Alternatively, download and install Docker Desktop from the offical website:
-https://docs.docker.com/desktop/setup/install/windows-install/ +
## Clone the repository and set up git From 5d757dfd80ceb46b30f73a9d1999a96767192bee Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 10:27:14 -0500 Subject: [PATCH 17/21] fix formatting --- BUILDING.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index ada4f41da8e..e3ea4980402 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -225,25 +225,25 @@ winget install --id Docker.DockerDesktop cp .githooks/pre-commit .git/hooks/ ``` - > [!TIP] - > You can alternatively use the `core.hooksPath` configuration to point to the `.githooks` folder using `git config --local core.hooksPath .githooks` if you don't already have a hooks path defined system-wide. +> [!TIP] +> You can alternatively use the `core.hooksPath` configuration to point to the `.githooks` folder using `git config --local core.hooksPath .githooks` if you don't already have a hooks path defined system-wide. - > [!NOTE] - > The git hooks will check that your code is properly formatted before commiting. - > This is done both to avoid future merge conflict and ensure uniformity inside the code base. +> [!NOTE] +> The git hooks will check that your code is properly formatted before commiting. +> This is done both to avoid future merge conflict and ensure uniformity inside the code base. * Configure git to automatically update submodules. ```shell git config --local submodule.recurse true ``` - > [!NOTE] - > Git does not automatically update submodules when switching branches. - > Without this configuration, you will need to remember to add `--recurse-submodules` to `git checkout` when switching to old branches. +> [!NOTE] +> Git does not automatically update submodules when switching branches. +> Without this configuration, you will need to remember to add `--recurse-submodules` to `git checkout` when switching to old branches. - > [!TIP] - > This will keep the submodule in `dd-java-agent/agent-jmxfetch/integrations-core` up-to-date. - > There is also an automated check when opening a pull request if you are trying to submit a module version change (usually an outdated version). +> [!TIP] +> This will keep the submodule in `dd-java-agent/agent-jmxfetch/integrations-core` up-to-date. +> There is also an automated check when opening a pull request if you are trying to submit a module version change (usually an outdated version). > [!NOTE] > Both git configurations (hooks and submodule) will only be applied to this project and won't apply globally in your setup. From 076f4aa88c10dae6788dfa7f2e6fad6bed37eb2e Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 11:40:11 -0500 Subject: [PATCH 18/21] simplify collapsible sections --- BUILDING.md | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index e3ea4980402..8f0177b3138 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -108,10 +108,10 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. #### Windows -* Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/). Alternatively, you can use `winget` or `scoop`: +* Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/).
- Install JDKs using winget + Alternatively, click here to install JDKs using `winget` or `scoop`. ```pwsh winget install --id EclipseAdoptium.Temurin.8.JDK @@ -120,11 +120,6 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. winget install --id EclipseAdoptium.Temurin.21.JDK ``` -
- -
- Install JDKs using scoop - ```pwsh scoop bucket add java scoop install temurin8-jdk @@ -161,20 +156,15 @@ apt-get install git #### Windows -Download and install the installer from [the official website](https://git-scm.com/download/win). Alternatively, you can use `winget` or `scoop`: +Download and install the installer from [the official website](https://git-scm.com/download/win).
-Install git using winget +Alternatively, click here to install git using `winget` or `scoop`. ```pwsh winget install --id git.git ``` -
- -
-Install git using scoop - ```pwsh scoop install git ``` @@ -202,10 +192,8 @@ https://docs.docker.com/desktop/setup/install/linux/ Download and install Docker Desktop from the offical website:
https://docs.docker.com/desktop/setup/install/windows-install/ -Alternatively, you can use `winget`: -
-Install Docker Desktop using winget +Alternatively, click here to install Docker Desktop using winget. ```pwsh winget install --id Docker.DockerDesktop From edd3667fb474052db603eb8f5c67e0dd7bc3b861 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Thu, 30 Jan 2025 11:55:29 -0500 Subject: [PATCH 19/21] tweak the "click here" text --- BUILDING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 8f0177b3138..6a9c4acf8c4 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -111,7 +111,7 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. * Download and install JDK 8, 11, 17, and 21 [Eclipse Temurin releases](https://adoptium.net/temurin/releases/).
- Alternatively, click here to install JDKs using `winget` or `scoop`. + Alternatively, install JDKs using winget or scoop. (click here to expand) ```pwsh winget install --id EclipseAdoptium.Temurin.8.JDK @@ -159,7 +159,7 @@ apt-get install git Download and install the installer from [the official website](https://git-scm.com/download/win).
-Alternatively, click here to install git using `winget` or `scoop`. +Alternatively, install git using winget or scoop. (click here to expand) ```pwsh winget install --id git.git @@ -193,7 +193,7 @@ Download and install Docker Desktop from the offical website:
https://docs.docker.com/desktop/setup/install/windows-install/
-Alternatively, click here to install Docker Desktop using winget. +Alternatively, install Docker Desktop using winget. (click here to expand) ```pwsh winget install --id Docker.DockerDesktop From 183c6a1a63ef5414bdefeab8e4ddca2cbaabe304 Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Wed, 5 Feb 2025 09:53:45 -0500 Subject: [PATCH 20/21] add GraalVM version Co-authored-by: Bruce Bujon --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 6a9c4acf8c4..3409f617220 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -60,7 +60,7 @@ Requirements to build the full project: ### Install the required JDKs -Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM. +Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM 17. #### macOS From 05774cd616ad45d0c937d14e4db20b63b7f0501d Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Wed, 5 Feb 2025 09:53:59 -0500 Subject: [PATCH 21/21] add GraalVM version Co-authored-by: Bruce Bujon --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 3409f617220..4332ec13b5e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -93,7 +93,7 @@ Download and install Eclipse Temurin JDK versions 8, 11, 17 and 21, and GraalVM #### Linux -* Download and extract JDK 8, 11, 17, and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/). +* Download and extract JDK 8, 11, 17, and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM 17 from [Oracle downloads](https://www.graalvm.org/downloads/). * Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites). * Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other. ```shell