Code Analyzer prerequisites
The PMD and CPD engines require a Java runtime and the Code Analyzer engine libraries. This page covers what to download and where to put it.
The pmd and cpd engines run on the JVM. The eslint engine does not and needs neither of these.
| Requirement | Version |
|---|---|
| Java | 11.0.0 or later, on PATH |
| Code Analyzer engine libraries | 0.40.0 for sfp v51 |
To pin a specific JDK instead of the one on PATH, set java_command in the Code Analyzer configuration file:
# config/code-analyzer.yml
engines:
pmd:
java_command: /usr/lib/jvm/java-21-openjdk/bin/javaStep 1: Download the engine libraries
curl -sL https://registry.npmjs.org/@salesforce/code-analyzer-pmd-engine/-/code-analyzer-pmd-engine-0.40.0.tgz \
| tar -xz -C /tmpThe tarball has SHA-1 3fba2fb397f31861691862fa8a692f99c145b684. Where npm is available, npm install @salesforce/code-analyzer-pmd-engine@0.40.0 fetches the same package into node_modules/@salesforce/code-analyzer-pmd-engine/.
Step 2: Copy them into place
| Platform | Copy dist/java-lib to | Create package.json in |
|---|---|---|
| Linux | /opt/flxbl-io/dist/java-lib | /opt/flxbl-io/ |
| macOS | /Applications/sfp-pro.app/Contents/dist/java-lib | /Applications/sfp-pro.app/Contents/ |
| Windows | C:\Program Files\flxbl-io\dist\java-lib | C:\Program Files\flxbl-io\ |
The package.json holds {"name":"sfp","version":"0.0.0"}.
Linux
sudo mkdir -p /opt/flxbl-io/dist/java-lib
sudo cp -r /tmp/package/dist/java-lib/* /opt/flxbl-io/dist/java-lib/
sudo sh -c 'printf "{\"name\":\"sfp\",\"version\":\"0.0.0\"}" > /opt/flxbl-io/package.json'macOS
APP=/Applications/sfp-pro.app/Contents
sudo mkdir -p "$APP/dist/java-lib"
sudo cp -r /tmp/package/dist/java-lib/* "$APP/dist/java-lib/"
sudo sh -c "printf '{\"name\":\"sfp\",\"version\":\"0.0.0\"}' > $APP/package.json"Adding files to a signed application bundle invalidates its code signature. If macOS then declines to launch the binary, reinstall the application and run sfp from a Node.js package tree instead.
Windows
Run in PowerShell as Administrator:
$url = 'https://registry.npmjs.org/@salesforce/code-analyzer-pmd-engine/-/code-analyzer-pmd-engine-0.40.0.tgz'
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\pmd-engine.tgz"
tar -xzf "$env:TEMP\pmd-engine.tgz" -C $env:TEMP
$target = 'C:\Program Files\flxbl-io'
New-Item -ItemType Directory -Force -Path "$target\dist\java-lib" | Out-Null
Copy-Item "$env:TEMP\package\dist\java-lib\*" "$target\dist\java-lib\" -Recurse -Force
'{"name":"sfp","version":"0.0.0"}' | Set-Content "$target\package.json" -NoNewlineStep 3: Verify
sfp analyze --code-analyzer-engines pmd,cpdSelected 99 rules for analysis
Running code analysis...The count varies with the project. Rules Checked in the results summary reports the same number, and is greater than zero.
If the libraries are missing
| Error: Could not find or load main class com.salesforce.sfca.pmdwrapper.PmdWrapper
Selected 0 rules for analysis
Rules Checked: 0The command exits 0 in this state, including with --fail-on code-analyzer. Where the analyzer gates a pipeline, assert on Rules Checked rather than the exit status alone. ENOENT: no such file or directory, open '/opt/flxbl-io/package.json' means the JAR files are in place but the package.json from Step 2 is not.
Upgrading sfp
Upgrading sfp does not update these libraries. Repeat Step 1 and Step 2 when the required engine version changes.