Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCOMPILER-333] Cleanup generated source files #214

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
Expand All @@ -41,6 +42,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.handler.ArtifactHandler;
Expand Down Expand Up @@ -1173,6 +1175,17 @@ public void execute() throws MojoExecutionException, CompilationFailureException
if (useIncrementalCompilation) {
incrementalBuildHelperRequest.outputDirectory(getOutputDirectory());

// Cleanup the generated source files created by annotation processing
// they are regenerated by the java compiler.
if (getGeneratedSourcesDirectory() != null) {
try (Stream<Path> walk =
Files.walk(getGeneratedSourcesDirectory().toPath())) {
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
} catch (IOException ex) {
getLog().warn("I/O error deleting the annotation processing generated files: " + ex.getMessage());
}
}

incrementalBuildHelper.beforeRebuildExecution(incrementalBuildHelperRequest);

getLog().debug("incrementalBuildHelper#beforeRebuildExecution");
Expand Down