Skip to content

Commit

Permalink
[MCOMPILER-333] Cleanup generated source files
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Solórzano <jorsol@gmail.com>
  • Loading branch information
jorsol committed Dec 7, 2023
1 parent d721f0f commit 9c7a411
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 9c7a411

Please sign in to comment.