Setting Java version for maven build

后端 未结 1 1980
面向向阳花
面向向阳花 2021-01-24 13:41

I am trying to set the java version for a maven build when I execute it from a shell script. Fot some reason it is not picking up the intended java version. Any advise welcome.<

1条回答
  •  甜味超标
    2021-01-24 14:10

    I found a solution:

    If I set, this it works. Maven compiles the code.

        /usr/lib/jvm/jdk-14.0.2/bin/javac
    

    However, this is not ideal because the path to the install is hard-coded, so on other servers with a different JAVA_HOME location, it won't work. Is it possible to reference $JAVA_HOME from within the POM file? and do something like this?

        <$JAVA_HOME>/bin/javac
    

    e.g.

            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    ${java.version}
                    ${java.version}
                    true
                    /usr/lib/jvm/jdk-14.0.2/bin/javac
                
            
    

    0 讨论(0)
提交回复
热议问题