diff --git a/src/main/java/org/apache/maven/plugins/enforcer/EnforceBytecodeVersion.java b/src/main/java/org/apache/maven/plugins/enforcer/EnforceBytecodeVersion.java index 9fa2756d..e6af852c 100644 --- a/src/main/java/org/apache/maven/plugins/enforcer/EnforceBytecodeVersion.java +++ b/src/main/java/org/apache/maven/plugins/enforcer/EnforceBytecodeVersion.java @@ -299,6 +299,7 @@ private String isBadArtifact( Artifact a ) jarFile = new JarFile( f ); getLog().debug( f.getName() + " => " + f.getPath() ); byte[] magicAndClassFileVersion = new byte[8]; + String artifactInfo = "(" + a.getGroupId() + ":" + a.getArtifactId() + ") "; JAR: for ( Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry entry = e.nextElement(); @@ -349,7 +350,13 @@ private String isBadArtifact( Artifact a ) Matcher matcher = MULTIRELEASE.matcher( entry.getName() ); - if ( matcher.matches() ) + if ( MODULE_INFO_CLASS.equals( entry.getName() ) ) { + if ( major > maxJavaMajorVersionNumber ) { + getLog().warn( artifactInfo + "Invalid bytecodeVersion for " + MODULE_INFO_CLASS + ": expected " + + maxJavaMajorVersionNumber + ", but was " + major); + } + } + else if ( matcher.matches() ) { Integer expectedMajor = JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.get( matcher.group( 1 ) ); @@ -359,8 +366,8 @@ private String isBadArtifact( Artifact a ) } else if ( major != expectedMajor ) { - getLog().warn( "Invalid bytecodeVersion for " + a + " : " - + entry.getName() + ": expected " + expectedMajor + ", but was " + major ); + getLog().warn( artifactInfo + "Invalid bytecodeVersion for " + entry.getName() + ": expected " + + expectedMajor + ", but was " + major ); } } else