From 6ea7057dd091873d68af3e0f0a22a2be14c261ba Mon Sep 17 00:00:00 2001 From: George Cao Date: Fri, 17 May 2024 09:52:37 +0800 Subject: [PATCH] Skip grammar file change detect and just compile them --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index 3fb37a8e0e..038b8af00a 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -105,6 +105,12 @@ public class Antlr4Mojo extends AbstractMojo { @Parameter(property = "antlr4.forceATN", defaultValue = "false") protected boolean forceATN; + /** + * Skip grammar file change detect and just compile them. + */ + @Parameter(property = "antlr4.forceCompile", defaultValue = "false") + protected boolean forceCompile; + /** * A list of grammar options to explicitly specify to the tool. These * options are passed to the tool using the @@ -394,7 +400,7 @@ private List> processGrammarFiles( for (File grammarFile : grammarFiles) { String tokensFileName = grammarFile.getName().split("\\.")[0] + ".tokens"; File outputFile = new File(outputDirectory, tokensFileName); - if ( (! outputFile.exists()) || + if (forceCompile || (! outputFile.exists()) || outputFile.lastModified() <= grammarFile.lastModified() || dependencies.isDependencyChanged(grammarFile)) { grammarFilesToProcess.add(grammarFile);