How to fail/stop task immediately if dependency jar file classes compile with old java version

Hi
How to fail/stop task immediately if dependency jar file classes compile with old java version?

if Gradle has not this feature , is it good way do this with jenking?
e.g: after build completed jenking extract ear file after that jar files, then find all versions that classes complied with.

Any recommendation?
Thanks,

In a class file, bytes at offset 5&6 specify major version and 4&5 specify minor version.

See https://en.m.wikipedia.org/wiki/Java_class_file#General_layout

is it possible to define failed condition with Gradle or Jenkings to monitor this version and stop it?

Yes, you can add a task to the task graph which

  • loops through the jars in all the configurations
  • take a sample class file from each jar
  • take bytes 4-7 from the class file
  • compare against the accepted minimum (ByteBuffer.getInt() can help here)
  • fail if below accepted minimum version