Skip to content

Commit

Permalink
Add ability to export dataTables (#310)
Browse files Browse the repository at this point in the history
* Add ability to export dataTables

* Minor polish to move methods and change log statement

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
ryanwalker and timtebeek authored Jul 22, 2024
1 parent e92c05d commit 5632d16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class RewriteExtension {
private File checkstyleConfigFile;
private String metricsUri = magicalMetricsLogString;
private boolean enableExperimentalGradleBuildScriptParsing = true;
private boolean exportDatatables;
private final List<String> exclusions = new ArrayList<>();
private final List<String> plainTextMasks = new ArrayList<>();

Expand Down Expand Up @@ -278,6 +279,14 @@ public void setEnableExperimentalGradleBuildScriptParsing(boolean enableExperime
this.enableExperimentalGradleBuildScriptParsing = enableExperimentalGradleBuildScriptParsing;
}

public boolean isExportDatatables() {
return exportDatatables;
}

public void setExportDatatables(boolean exportDatatables) {
this.exportDatatables = exportDatatables;
}

public List<String> getExclusions() {
return exclusions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
Expand Down Expand Up @@ -1255,6 +1257,14 @@ protected ResultsContainer listResults(ExecutionContext ctx) {

logger.lifecycle("All sources parsed, running active recipes: {}", String.join(", ", getActiveRecipes()));
RecipeRun recipeRun = recipe.run(new InMemoryLargeSourceSet(sourceFiles), ctx);

if (extension.isExportDatatables()) {
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss-SSS"));
Path datatableDirectoryPath = Paths.get(baseDir.toString(), "build", "rewrite", "datatables", timestamp);
logger.info(String.format("Printing available datatables to: %s", datatableDirectoryPath));
recipeRun.exportDatatablesToCsv(datatableDirectoryPath, ctx);
}

return new ResultsContainer(baseDir, recipeRun);
}

Expand Down

0 comments on commit 5632d16

Please sign in to comment.