Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the plugin toolchains aware #58

Open
martin-g opened this issue Nov 14, 2018 · 4 comments
Open

Make the plugin toolchains aware #58

martin-g opened this issue Nov 14, 2018 · 4 comments

Comments

@martin-g
Copy link

Could this plugin be made aware of Maven toolchains so that it use the configured JDK in the project ?

My project defines that it should be build (via maven-toolchains-plugin) with JDK 11 but I run mvn on the command line where JAVA_HOME points to JDK 8 installation and this leads to an error like:

...
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ wicketstuff-scala ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/home/martin/devel/jdk-11/]
[INFO] No sources to compile
[INFO] 
[INFO] --- scala-maven-plugin:3.4.4:testCompile (test-compile) @ wicketstuff-scala ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ wicketstuff-scala ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- scalatest-maven-plugin:2.0.0:test (test) @ wicketstuff-scala ---
Discovery starting.
*** RUN ABORTED ***
  java.lang.UnsupportedClassVersionError: org/apache/wicket/ajax/markup/html/AjaxFallbackLink has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  ...
[INFO] ------------------------------------------------------------------------

Information how a Maven plugin could be made toolchains-aware could be found at: https://cwiki.apache.org//confluence/display/MAVENOLD/Toolchains
Here is how scala-maven-plugin does it: https://github.com/davidB/scala-maven-plugin/search?q=ToolchainManager&unscoped_q=ToolchainManager

@axiopisty
Copy link

We're running into this same issue in our CI/CD pipeline. We use Jenkins to build, test, and deploy our application. The jenkins servers have one version of Java installed on the machine, but the build is allowed to specify which version of the build tools should be used (ie: Java, Maven, etc.).

Currently the Jenkins servers have Java 8 installed, but when we specify to build with Java 11 (probably using docker containers) Maven and all the other plugins we use in our project appropriately use Java 11. The scalatest-maven-plugin does not use Java 11 when it forks. The command it uses is simply java. In this case, I think the problem is that java on the path is pointing to Java 8, but $JAVA_HOME within the build environment specifies Java 11.

I could have some details wrong here because I don't work on our CI/CD team that manages the pipeline, but this is probably a fair analysis of what is happening. We're getting the exact same error as reported here.

@blast-hardcheese
Copy link

Related, scalatest/scalatest#297, just discovered this as well

@kasabov
Copy link

kasabov commented Jun 21, 2021

I was faced with the same issue until I upgraded to latest scalatest-maven-plugin:2.0.2.

@demaziej
Copy link

Workaround to force the java version by using the undocumented jvm property :

<configuration>
  <jvm>${env.JAVA_HOME_11}/bin/java</jvm>
</configuration>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants