slawekjaranowski commented on code in PR #219: URL: https://github.com/apache/maven-compiler-plugin/pull/219#discussion_r1433140742
########## src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java: ########## @@ -1842,6 +1851,48 @@ private boolean hasInputFileTreeChanged(IncrementalBuildHelper ibh, Set<File> in return inputTreeChanges.hasChanged(); } + private static final int MAX_FILE_WALK_LIMIT = 20; + + /** + * Performs a check on compiled class files to ensure that the bytecode version + * hasn't changed between runs. + * + * <p>This is limited to check a maximum of {@link #MAX_FILE_WALK_LIMIT}. + * + * @return true if a bytecode version differs from the actual release version. + */ + private boolean hasBytecodeChanged() { + String currentVersion = getVersionRelease(); + JavaVersion javaVersion = JavaVersion.parse(currentVersion).asMajor(); + + try (Stream<Path> walk = Files.walk(getOutputDirectory().toPath())) { + Map<Path, JavaClassfileVersion> pathVersionMap = walk.filter(file -> "class" + .equals(FileUtils.extension(file.getFileName().toString()))) + .limit(MAX_FILE_WALK_LIMIT) + .collect(Collectors.toMap(Function.identity(), JavaClassfileVersion::of)); Review Comment: Maybe instead of checking bytecode of classes we can store current JDK version used to compile and next time verify if is the same. We also should add an IT for multi-releases compilation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org