Skip to content

Maven project: Java Platform from Project Properties is ignored #3928

Closed

Description

@NicolaIsotta

Apache NetBeans version

Apache NetBeans 13

What happened

If Maven java platform is not the default JDK, and in project properties I set Java Platform to the default one, Maven does not use the JDK set in project properties.

How to reproduce

Netbean 13 clean install
Set JDK home to Adoptium 11 (if it's not picked up automatically)
In Tools -> Java Platforms add a different JDK (I used Adoptium 1.8)
In Tools -> Options -> Java -> Maven change Default JDK to the just added one
File -> New Project... -> Java with Maven -> Finish
Right click on project -> Properties -> Sources check that Sources/Binary format is set to "11"
Right click on project -> Properties -> Compile change Java Platform to "JDK 11 (Default)"
Build the project -> the build fails for invalid target release

Did this work correctly in an earlier version?

Apache NetBeans 12.3 or earlier

Operating System

Windows 10 - x64 - version 21H2 - build 19044.1586

JDK

openjdk version "11.0.14.1" 2022-02-08 OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1) OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

java platforms
maven options
projects properties

build output

cd C:\Users\Emmeduei-Nicola\Documents\NetBeansProjects\mavenproject1; "JAVA_HOME=C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot" cmd /c "\"C:\\Tools\\netbeans-13\\java\\maven\\bin\\mvn.cmd\" -Dmaven.ext.class.path=C:\\Tools\\netbeans-13\\java\\maven-nblib\\netbeans-eventspy.jar -Dfile.encoding=UTF-8 install"
Scanning for projects...

---------------------< it.emmeduei:mavenproject1 >----------------------
Building mavenproject1 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------

--- maven-resources-plugin:2.6:resources (default-resources) @ mavenproject1 ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\Emmeduei-Nicola\Documents\NetBeansProjects\mavenproject1\src\main\resources

--- maven-compiler-plugin:3.1:compile (default-compile) @ mavenproject1 ---
Changes detected - recompiling the module!
Compiling 1 source file to C:\Users\Emmeduei-Nicola\Documents\NetBeansProjects\mavenproject1\target\classes
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  0.960 s
Finished at: 2022-04-05T11:47:27+02:00
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mavenproject1: Fatal error compiling: invalid target release: 11 -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

Activity

  1. added
    kind:bug
    needs:triage
    on Apr 5, 2022
  2. NicolaIsotta commented on Apr 5, 2022

    @NicolaIsotta
    ContributorAuthor

    May be releated to #3853

  3. neilcsmith-net commented on Apr 12, 2022

    @neilcsmith-net
    Member

    I think this is working as designed, even if the UI is somewhat non-obvious. If the project JDK is set to default then it will use the global setting. Of course the JDK 11 label then for the default option is wrong. I would register both JDKs as explicit platforms and try with that.

  4. added
    Maven
    and removed
    needs:triage
    on Apr 12, 2022
  5. NicolaIsotta commented on Apr 12, 2022

    @NicolaIsotta
    ContributorAuthor

    Yeah, you're right. Adding another JDK 11 entry in the platforms and using it project properties works.
    Maybe the UI could be a little clearer with a new entry in the Java Platforms dropdown in the project properties:

    • Maven Default
    • all the other entries from Tools -> Java Platforms, including Netbeans default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Mavenkind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions