jira-importer opened a new issue, #41: URL: https://github.com/apache/maven-jdeps-plugin/issues/41
**[Andrii Radistao](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=radistao)** opened **[MJDEPS-30](https://issues.apache.org/jira/browse/MJDEPS-30?redirect=false)** and commented When running command ```java mvn jdeps:jdkinternals ``` (or any other maven workflow, which uses `{}jdeps{`}) on _any_ project without specified system environment variable `JAVA_HOME` - the build fails with the error: > [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jdeps-plugin:3.1.2:jdkinternals (default-cli) on project cloud-backend-internal-client: Unable to find jdeps command: The environment variable JAVA_HOME is not correctly set. all other maven tools (`{}javac{`}, `{}jar{`}, tests) and most of other plugins work fine without `JAVA_HOME` specified Note, that we use default java-11 installation on Debian (Ubuntu): ```java openjdk-11-jdk:amd64 11.0.18+10-0ubuntu1~22.04 amd64 ``` which doesn't set JAVA_HOME by default, but still has `jdeps` installed and provided in the PATH (same as `javac` or `jar`): ```java $ command -v jdeps /usr/bin/jdeps $ jdeps --version 11.0.18 The issue happens because `maven-jdeps-plugin:3.1.2` resolves executable path only by toolchain or JAVA_HOME, but ignores default `PATH` (like `javac` or `jar` do) or JDK installation configuration: https://github.com/apache/maven-jdeps-plugin/blob/edcbab0c81a93338dab6fad479108e1102f86ca1/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java#L455-L465 ```java // ---------------------------------------------------------------------- // Try to find jdepsExe from JAVA_HOME environment variable // ---------------------------------------------------------------------- if ( !jdepsExe.exists() || !jdepsExe.isFile() ) { Properties env = CommandLineUtils.getSystemEnvVars(); String javaHome = env.getProperty( "JAVA_HOME" ); if ( StringUtils.isEmpty( javaHome ) ) { throw new IOException( "The environment variable JAVA_HOME is not correctly set." ); } ``` **Proposition:** consider resolving `jdeps` executable location either by default `PATH` or by `SystemUtils#getJavaHome`, like in [this line](https://github.com/apache/maven-jdeps-plugin/blob/edcbab0c81a93338dab6fad479108e1102f86ca1/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java#L453-L453): ```java jdepsExe = new File( SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "sh", jdepsCommand ); ``` **but** without `".." + File.separator + "sh"` i tried and it proved to work: ```java new File( SystemUtils.getJavaHome() + File.separator + "bin", jdepsCommand ); ``` I can supply a PR if this helps. --- **Affects:** 3.1.2 **Issue Links:** - [MJDEPRSCAN-9](https://issues.apache.org/jira/browse/MJDEPRSCAN-9) jdeprscan plugin does not work when JAVA_HOME is not set -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
