Alexander Kriegisch created MSHADE-398:
------------------------------------------
Summary: MSHADE-185 IT failing if JAVA_HOME != JDK version running
the test
Key: MSHADE-398
URL: https://issues.apache.org/jira/browse/MSHADE-398
Project: Maven Shade Plugin
Issue Type: Bug
Affects Versions: 3.2.4
Reporter: Alexander Kriegisch
Maven Invoker regression integration test (IT) {{MSHADE-185}} runs only on JDK
<= 8. The CI builds on GitHub are fine, because they run on JDK 8 and also set
{{JAVA_HOME}} accordingly. But on many systems, e.g. my developer workstation,
{{JAVA_HOME}} points to a more recent JDK like 9, 11, 16. Those JDKs do not
contain {{tools.jar}}, of course. So far, so good.
Now it is perfectly normal that a developer starts an IDE and from there loads
her project and runs the Maven Shade build, selecting a different JDK to run
Maven on, because for example they want to run all ITs. The same can happen in
a console, if the developer starts Maven on a different Java executable than
the one pointed to by {{JAVA_HOME}}. In both cases, the test fails, because the
POM contains a system dependency on {{tools.jar}}.
First the Maven build started by Invoker fails:
{code:java}
[ERROR] Failed to execute goal on project system-dep: Could not resolve
dependencies for project test.shade:system-dep:jar:1.0.0-SNAPSHOT: Could not
find artifact com.sun:tools:jar:1.6 at specified path c:\Program
Files\Java\jdk-16\..\lib\tools.jar -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
on project system-dep: Could not resolve dependencies for project
test.shade:system-dep:jar:1.0.0-SNAPSHOT: Could not find artifact
com.sun:tools:jar:1.6 at specified path c:\Program
Files\Java\jdk-16\..\lib\tools.jar
at
org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies
(LifecycleDependencyResolver.java:269)
at
org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies
(LifecycleDependencyResolver.java:147)
at
org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved
(MojoExecutor.java:248)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:202)
{code}
Then later of course also the post-run verify step fails, because no
dependency-reduced POM was created due to the fact that the build failed
quickly:
{code:java}
Running post-build script:
C:\Users\alexa\Documents\java-src\maven-shade-plugin\target\it\MSHADE-185\verify.groovy
Assertion failed:
assert pomFile.isFile()
| |
| false
C:\Users\alexa\Documents\java-src\maven-shade-plugin\target\it\MSHADE-185\dependency-reduced-pom.xml
{code}
The solution would be to make sure that Invoker sets JAVA_HOME according to the
JDK actually used for running the test. I have not investigated how to do that,
but it should be possible somehow.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)