[ 
https://issues.apache.org/jira/browse/MSHADE-398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17374099#comment-17374099
 ] 

Alexander Kriegisch edited comment on MSHADE-398 at 7/3/21, 5:26 PM:
---------------------------------------------------------------------

Attention, {{9-}} is not the same as {{9+}}. This is cryptic and undocumented, 
I also had to find out by experimenting. The documentation shows examples, but 
never explains their meanings, obviously assuming they would speak for 
themselves, which obviously they don't, if even a Maven guru like you does not 
know. Same goes for tests: no explanation.

Of course {{java.home}} is not the same as {{JAVA_HOME}} and can be overridden, 
but defaults to it. I recommend to simply give it a try, simply running the 
test, trying to reproduce what I described? I should not have to convince 
anyone, the facts speak for themselves. 


was (Author: kriegaex):
Attention, {{9-}} is not the same as {{9+}}. This is cryptic and undocumented, 
I also had to find out by experimenting. The documentation shows examples, but 
never explains their meanings, obviously assuming they would speak for 
themselves, which obviously they don't, if even a Maven guru like you does not 
know. Same goes for tests: no explanation. 

> 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
>            Priority: Major
>
> 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)

Reply via email to