Re: build maven project without setting compiler source and target
Hi Matt, > So I guess it's an issue with NetBeans then a) using such an old version > of maven b) not handle compiler version and minium required > source/target correctly. > Guess I just set it to 8, as that's the oldest jdk/vm I still have lay > around, and don't bother anymore about it. > Thanks for your replies and time anyway. Normally an IDE should respect what you have configured in your pom.xml when you execute a Maven build. Therefore I still assume that you don’t have specified what exact version of m-compiler-p you’d like to use. And that you don’t have configured source and target in m-compiler-p, i.e. you use the default parameters which - according to your mail - are an older version of Maven‘s compiler plugin and/or no source/target version set. Can you show us a minimal sample? Regards Thorsten - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: build maven project without setting compiler source and target
So I guess it's an issue with NetBeans then a) using such an old version of maven b) not handle compiler version and minium required source/target correctly. Guess I just set it to 8, as that's the oldest jdk/vm I still have lay around, and don't bother anymore about it. Thanks for your replies and time anyway. Matt Am 2020-02-17 13:03, schrieb Thorsten Heit: Hi, Scanning for projects... (...) - COMPILATION ERROR : - Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later. 2 errors - You obviously use an older version of maven-compiler-plugin that still defaults to Java 5. In that case this error is expectable as Java 11 doesn't support compiling for Java 5 anymore. The actual version 3.8.1 of m-compiler-p (see [1]) defaults to Java 6 as source and target for the compiler. I suggest you upgrade your pom.xml to that version. Anyway, I recommend you pin the version of each used plugin in your pom.xml. Otherwise you may get different results if you upgrade Maven, the JVM, use another OS and so on. [1] https://maven.apache.org/plugins/maven-compiler-plugin/ Regards Thorsten Am 2020-02-17 13:01, schrieb Thomas Broyer: You seem to mistake the version of the JDK you're using with the version of the Java language that your source files are written in and the JRE they depend on (in terms of available API). You can very well compile Java 8 sources with a JDK 11 or 13. If you share your project between machines where you don't control the JDK, then you'll want to make sure you never use something in your code that won't be available in another machine, so you'll actually *want* to set a source value (for example, you work on a machine with JDK 11 and start using Optional#isEmpty; then switch to a machine with JDK 8, your code won't compile) So: - set a source/target value to the minimum version of the JDK you want to support (if you have machines with JDK 8, then use source=8) - optional but recommended: use 'release' rather than 'source' (if you'll only ever have JDK 9+, then just use 'release'; if you'll have JDK 8, then you'll need to setup a profile to only use 'release' on JDK 9+, and use 'source' otherwise); this will make sure that not only you won't ever use language constructs from newer Java versions (e.g. private methods in interfaces) but will also validate that you won't attempt to use an API that's not available in that version (as in the Optional#isEmpty example above) On Mon, Feb 17, 2020 at 12:46 PM wrote: Sorry for the late reply, but I did some testing to make sure it wasn't me made a stupid mistake. So, when I clone my current repo and execute an "mvn compile" or "mvn package" on it without messing around with the pom either all works fine or I get a failure because the set version is higher than what'S available on the current system. If I manual change the version to match what the system has installed all works fine again (terminal and Netbeans). But when I remove the source and target from the pom I get this error (same when using a terminal as when using Netbeans): cd C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat; "JAVA_HOME=C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.4.11-hotspot" cmd /c "\"\"C:\\Program Files\\NetBeans-11.2\\netbeans\\java\\maven\\bin\\mvn.cmd\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans-11.2\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 install\"" Scanning for projects... Building YouTubeLiveChat 1.0 --- maven-resources-plugin:2.6:resources (default-resources) @ YouTubeLiveChat --- Using 'UTF-8' encoding to copy filtered resources. skip non existing resourceDirectory C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\src\main\resources --- maven-compiler-plugin:3.1:compile (default-compile) @ YouTubeLiveChat --- Changes detected - recompiling the module! Compiling 4 source files to C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\target\classes - COMPILATION ERROR : - Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later. 2 errors - BUILD FAILURE Total time: 1.995 s Finished at: 2020-02-17T12:28:58+01:00 Final Memory: 10M/40M --
Re: Re: build maven project without setting compiler source and target
Hi, > Scanning for projects... (...) > - > COMPILATION ERROR : > - > Source option 5 is no longer supported. Use 6 or later. > Target option 1.5 is no longer supported. Use 1.6 or later. > 2 errors > - You obviously use an older version of maven-compiler-plugin that still defaults to Java 5. In that case this error is expectable as Java 11 doesn't support compiling for Java 5 anymore. The actual version 3.8.1 of m-compiler-p (see [1]) defaults to Java 6 as source and target for the compiler. I suggest you upgrade your pom.xml to that version. Anyway, I recommend you pin the version of each used plugin in your pom.xml. Otherwise you may get different results if you upgrade Maven, the JVM, use another OS and so on. [1] https://maven.apache.org/plugins/maven-compiler-plugin/ Regards Thorsten
Re: build maven project without setting compiler source and target
You seem to mistake the version of the JDK you're using with the version of the Java language that your source files are written in and the JRE they depend on (in terms of available API). You can very well compile Java 8 sources with a JDK 11 or 13. If you share your project between machines where you don't control the JDK, then you'll want to make sure you never use something in your code that won't be available in another machine, so you'll actually *want* to set a source value (for example, you work on a machine with JDK 11 and start using Optional#isEmpty; then switch to a machine with JDK 8, your code won't compile) So: - set a source/target value to the minimum version of the JDK you want to support (if you have machines with JDK 8, then use source=8) - optional but recommended: use 'release' rather than 'source' (if you'll only ever have JDK 9+, then just use 'release'; if you'll have JDK 8, then you'll need to setup a profile to only use 'release' on JDK 9+, and use 'source' otherwise); this will make sure that not only you won't ever use language constructs from newer Java versions (e.g. private methods in interfaces) but will also validate that you won't attempt to use an API that's not available in that version (as in the Optional#isEmpty example above) On Mon, Feb 17, 2020 at 12:46 PM wrote: > Sorry for the late reply, but I did some testing to make sure it wasn't > me made a stupid mistake. > So, when I clone my current repo and execute an "mvn compile" or "mvn > package" on it without messing around with the pom either all works fine > or I get a failure because the set version is higher than what'S > available on the current system. If I manual change the version to match > what the system has installed all works fine again (terminal and > Netbeans). > But when I remove the source and target from the pom I get this error > (same when using a terminal as when using Netbeans): > > cd C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat; > "JAVA_HOME=C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.4.11-hotspot" cmd > /c "\"\"C:\\Program > Files\\NetBeans-11.2\\netbeans\\java\\maven\\bin\\mvn.cmd\" > -Dmaven.ext.class.path=\"C:\\Program > Files\\NetBeans-11.2\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" > -Dfile.encoding=UTF-8 install\"" > Scanning for projects... > > > Building YouTubeLiveChat 1.0 > > > --- maven-resources-plugin:2.6:resources (default-resources) @ > YouTubeLiveChat --- > Using 'UTF-8' encoding to copy filtered resources. > skip non existing resourceDirectory > > C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\src\main\resources > > --- maven-compiler-plugin:3.1:compile (default-compile) @ > YouTubeLiveChat --- > Changes detected - recompiling the module! > Compiling 4 source files to > > C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\target\classes > - > COMPILATION ERROR : > - > Source option 5 is no longer supported. Use 6 or later. > Target option 1.5 is no longer supported. Use 1.6 or later. > 2 errors > - > > BUILD FAILURE > > Total time: 1.995 s > Finished at: 2020-02-17T12:28:58+01:00 > Final Memory: 10M/40M > > Failed to execute goal > org.apache.maven.plugins:maven-compiler-plugin:3.1:compile > (default-compile) on project YouTubeLiveChat: Compilation failure: > Compilation failure: > Source option 5 is no longer supported. Use 6 or later. > Target option 1.5 is no longer supported. Use 1.6 or later. > -> [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/MojoFailureException > > From what I was able to find this is because the hardcoded default value > wich is used when no other setting is found in pom in the compiler > plugin is version 5. As the error message says, this is no longer > supported and 6 or higher should be used. I didn'T filed a bug report > cause it's possible that there're version mismatches wich may cause this > - I'm not sure about that. > So, as I don't want to set a fixed value (maybe would be 8 if I have to) > I would rather prefer to disable this settings at all and just let it > compile with what ever version the system has a JDK of. Or, if it's not > po
Re: build maven project without setting compiler source and target
Sorry for the late reply, but I did some testing to make sure it wasn't me made a stupid mistake. So, when I clone my current repo and execute an "mvn compile" or "mvn package" on it without messing around with the pom either all works fine or I get a failure because the set version is higher than what'S available on the current system. If I manual change the version to match what the system has installed all works fine again (terminal and Netbeans). But when I remove the source and target from the pom I get this error (same when using a terminal as when using Netbeans): cd C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat; "JAVA_HOME=C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.4.11-hotspot" cmd /c "\"\"C:\\Program Files\\NetBeans-11.2\\netbeans\\java\\maven\\bin\\mvn.cmd\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans-11.2\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 install\"" Scanning for projects... Building YouTubeLiveChat 1.0 --- maven-resources-plugin:2.6:resources (default-resources) @ YouTubeLiveChat --- Using 'UTF-8' encoding to copy filtered resources. skip non existing resourceDirectory C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\src\main\resources --- maven-compiler-plugin:3.1:compile (default-compile) @ YouTubeLiveChat --- Changes detected - recompiling the module! Compiling 4 source files to C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\target\classes - COMPILATION ERROR : - Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later. 2 errors - BUILD FAILURE Total time: 1.995 s Finished at: 2020-02-17T12:28:58+01:00 Final Memory: 10M/40M Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project YouTubeLiveChat: Compilation failure: Compilation failure: Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later. -> [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/MojoFailureException From what I was able to find this is because the hardcoded default value wich is used when no other setting is found in pom in the compiler plugin is version 5. As the error message says, this is no longer supported and 6 or higher should be used. I didn'T filed a bug report cause it's possible that there're version mismatches wich may cause this - I'm not sure about that. So, as I don't want to set a fixed value (maybe would be 8 if I have to) I would rather prefer to disable this settings at all and just let it compile with what ever version the system has a JDK of. Or, if it's not possible to complete throw it out is there at least a way to not just set a specific version but rather only a minimum? So, that a system wich has only J8 can use this, but other system with 9, 11, 13 won'T be enforced to compile v8 but with their own version? As I also mentioned else where: I thought IDEs and all their build stuff is supposed to make developing easier - but I had so many issues I encountered since I started to use it a few days ago I really though of go back to basic editor and terminal - wich seems easier (side-note about dependency management: yes, sure, it's nice to have a build system handle it for you, but as I'm used to gather libs and dependencies myself, and many often come in bundles, and manage different and matching versions by myself, I got a rather big lib collection used by just point my system wide classpath to the lib directory). So, any thoughts about how to solve that issue? I'm honestly kind of lost, not just using Netbeans as a gui wrapper (as one of its devs called it on their list) but also get my head around maven as the build environment). Thanks for any help in advance, Matt Am 2020-02-17 05:24, schrieb Bernd Eckenfels: Can you show the actual error message and give a concrete project? Normally Maven works with not specifying target/source as long as your JDK is recent enough. (But it's not ways a good idea, it's better to specify the properties (IDEs normally read them) -- http://b