1

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?

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

3 Answers3

1

It's in the new release tag, not the source or compile -

You can reference it using the maven user property

NB Release overrides source and target values - e.g. having source = 1.8, and target = 1.8, with release = 14, compiles and releases in JDK 14

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <release>${maven.compiler.source}</release>
    

Marc Magon
  • 713
  • 7
  • 11
0

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

antonyh
  • 2,131
  • 2
  • 21
  • 42
-1

The version that is used by maven can be found in POM file like:

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

or alternatively

<plugins>
    <plugin>    
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>
asbrodova
  • 36
  • 9