Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I detect target>1.6 dependencies in a <=1.6 project?

Tags:

java

maven

In a specific project I am (at the moment) only allowed to use JRE6 for execution of a Java application. Therefore, I configured maven-compiler-plugin with 1.6 for both source and target.

In my Maven dependencies, I included a dependency that itself targets 1.7 and also uses 1.7 features like try-with-resources -- which I assumed would lead to some compile-time error or warning in my own project (I'm using Eclipse). But it doesn't, so my question is: Is it possible to detect such problems before running the application (or tests) on the specific target JRE which in my case is JRE6?

like image 643
letmaik Avatar asked Nov 12 '22 13:11

letmaik


1 Answers

Although just a partial answer, I found a solution for Mihai's mentioned issue with different library signatures. There is the Animal Sniffer Maven Plugin which lets you specify a certain Java runtime that it checks against in some phase (e.g. test).

But this doesn't solve the class file version problem, as Maven simply swallows (-nowarn) those warnings from javac, as explained in a comment to this question.

like image 71
letmaik Avatar answered Nov 15 '22 07:11

letmaik