Maven - 如何验证依赖项是使用特定 Java 级别(例如 1.7)编译的?

Maven - how to verify that dependencies compiled with specific Java level (1.7 for example)?

例如,Java Maven 项目已使用 maven-compiler-plugin 编译,目标级别为 1.7 具有多个依赖项

如何验证这些依赖项是否也使用某些特定的 Java 目标级别(例如 1.7)编译?

正如评论中所建议的,我使用了提供额外规则的 Extra Enforcer Rules as additional dependency to Maven enforcer plugin 作为解决方案。

此功能的用法描述 here,具体来说,在我的代码中它看起来像这样:

   <properties>
        <extra-enforcer-rules>1.0-beta-4</extra-enforcer-rules>
   </properties>

   <dependencies>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>${extra-enforcer-rules}</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.4</version>
                    <executions>   
                        <execution>
                            <id>enforce-bytecode-version</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <enforceBytecodeVersion>
                                        <maxJdkVersion>1.7</maxJdkVersion>   
                                    </enforceBytecodeVersion>
                                </rules>
                                <fail>true</fail>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>extra-enforcer-rules</artifactId>
                            <version>${extra-enforcer-rules}</version>
                        </dependency>
                    </dependencies>
                </plugin>        
            </plugins>
        </pluginManagement>
    </build>