1

i upgraded my java version to 12.0.2 in my system, and i have few projects where i have used maven 3.6.2, and some i used maven + surefire plugin 3.0.0-M8. since i know that maven is working with java 1.6 and i need to update the compiler version to work with these, also i need to update the surefire plugin to work with the java 12 version, so i want to understand in what to use, and on what (Maven or surefire or both) and also if the syntax is the right one? also if these is not the right way, so what is the right one?

<plugin>
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId>          
        <version>3.8.1</version>            
        <configuration>         
          <verbose>true</verbose>               
          <fork>true</fork>             
          <executable> ${JAVA_HOME}/bin/javac </executable>         
        </configuration>                
      </plugin>

also

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

and also

    <properties>
        <maven.compiler.release>12</maven.compiler.release>
    </properties>

and also

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>12</release>
                </configuration>
            </plugin>
        </plugins>
    </build>
nuzo
  • 49
  • 1
  • 7
  • If you have defined the maven-compiler-plugin version somewhere else for example in a parent you can go with the property only variant. If not I recommend the last solution. Also I suggest to upgrade the version to the most recent version 3.8.1 and also upgrade Maven to most recent (3.6.3)...apart from that maven-surefire-plugin only exist in 3.0.0-M4 (is the most recent version)... – khmarbaise Jun 05 '20 at 10:32
  • @khmarbaise i updated the syntax ( and also the version as you said ) also the maven version to 3.6.2 , but still no answer about in what to use so that the project won't go back to the 1.5 version and which errors is it covers? – nuzo Jun 05 '20 at 10:53
  • Repeating my comment: "If you have defined the maven-compiler-plugin version somewhere else for example in a parent you can go with the property only variant. If not I recommend the last solution. " maybe I don't understand your question? – khmarbaise Jun 05 '20 at 11:17
  • no other place in these project, only these place and only these project. and after i made the last solution, when i made an update maven project, t revert back to 1.5 so no success with that – nuzo Jun 05 '20 at 11:18
  • so, no other perent it's all in that place. the last solution isn't work in case you are doing right click on the project and maven >update project, it revert the project to 1.5 java – nuzo Jun 05 '20 at 11:37
  • maybe to explain more, when i change the compiler and the build path throgh the properties of the project it marks it as warning, but when i update the project throguh maven, it get back to j2SE-1.5 these first of all need to be changed to 12, how to make it? – nuzo Jun 05 '20 at 13:27
  • So we don't have a Maven problem. We have an IDE (supposing Eclipse?) problem? You have to configure the maven-compiler-plugin with version and the version you want to use... – khmarbaise Jun 05 '20 at 14:16
  • @khmarbaise i don't know because i added the two snippites from up plugin and the `12` and yet it is s still same thing – nuzo Jun 05 '20 at 14:29
  • @khmarbaise theres two questions here, 1 - why new project of maven start with java 1.5? 2 - why every update makes it return back to 1.5? even in the newst eclipse – nuzo Jun 05 '20 at 15:37
  • Which version of eclipse do you use? I would try to use `..` and `..` and check if this works..but it sounds like a problem with your IDE – khmarbaise Jun 05 '20 at 16:08
  • yes looks like, so if you can please tell me in what and when to use from the above plugins / properties? – nuzo Jun 06 '20 at 21:45
  • @khmarbaise yes, i installed the latest version of eclipse and now it works, now the question is in what should i use and what are the difference between them (i updated the thread syntaxes) - also i want to mention that the thred one didn't work to me at all but according to [here](https://stackoverflow.com/questions/38882080/specifying-java-version-in-maven-differences-between-properties-and-compiler-p) maybe i'm worng. – nuzo Jun 06 '20 at 23:04

0 Answers0