Search code examples
javamavenjacksonpom.xml

Determine the actual java version used in maven build


Complementary to this question, how to determine actual java version used in mvn compile?

I am compiling FasterXML/jackson-databind as follows, but can't be sure of the java version:

$ git clone https://github.com/FasterXML/jackson-databind.git
$ cd jackson-databind
$ mvn compile
$ javap -verbose ./target/classes/com/fasterxml/jackson/databind/PropertyNamingStrategy.class | grep "major"
  major version: 52

So according to this post, the java version is 1.8. But when I grep the pom.xml I don't see that:

$ grep -wn "source" pom.xml
245:                <id>add-test-source</id>
248:                  <goal>add-test-source</goal>
252:                    <source>src/test-jdk14/java</source>
265:              <source>14</source>

I only see java 14 (?) What am I missing?


Solution

  • The parent POM is jackson-base which does set the java version : https://github.com/FasterXML/jackson-bom/blob/e60567a0e778f749d9e39e2c245486a44fbc52f9/base/pom.xml

        <javac.src.version>1.8</javac.src.version>
        <javac.target.version>1.8</javac.target.version>
    
        <maven.compiler.source>${javac.src.version}</maven.compiler.source>
        <maven.compiler.target>${javac.target.version}</maven.compiler.target>
    
    

    You can inspect the fully evaluated POM with all the parents/dependencies/plugins/properties/etc using mvn help:effective-pom