Since Java SE 7 is EOL, upgrading to Java 8 is necessary. However there are business reasons to not allow the developers to use any of the new language features. The feature that is especially forbidden is lambdas.
How can the use of Java 7 features be enforced? The build system is based on Jenkins and there is also SonarQube available.
Other answers are partially right. Compiler must indeed be configured with -source 1.7 to check that no Java 8 lang features are used. But it does not prevent from using the new Java 8 APIs. A solution is to use the animal sniffer project to verify that only Java 7 APIs are used.
Here is a a sample of configuration for maven projects:
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>animal-sniffer-maven-plugin</artifactId> <executions> <execution> <id>enforce-java-api-compatibility</id> <phase>verify</phase> <goals> <goal>check</goal> </goals> <configuration> <signature> <groupId>org.codehaus.mojo.signature </groupId> <artifactId>java17</artifactId> <version>1.0</version> </signature> </configuration> </execution> </executions> </plugin> </plugins>