Class AntlrTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask
org.gradle.api.plugins.antlr.AntlrTask
All Implemented Interfaces:
Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Named, ExtensionAware, Task, PatternFilterable, Configurable<Task>

@NullMarked @CacheableTask public abstract class AntlrTask extends SourceTask
Generates parsers from Antlr grammars.
  • Constructor Details

    • AntlrTask

      public AntlrTask()
  • Method Details

    • getTrace

      @Input public abstract Property<Boolean> getTrace()
      Specifies that all rules call traceIn/traceOut.
    • getIsTrace

      @Internal public Property<Boolean> getIsTrace()
    • getTraceLexer

      @Input public abstract Property<Boolean> getTraceLexer()
      Specifies that all lexer rules call traceIn/traceOut.
    • getIsTraceLexer

      @Internal public Property<Boolean> getIsTraceLexer()
    • getTraceParser

      @Input public abstract Property<Boolean> getTraceParser()
      Specifies that all parser rules call traceIn/traceOut.
    • getIsTraceParser

      @Internal public Property<Boolean> getIsTraceParser()
    • getTraceTreeWalker

      @Input public abstract Property<Boolean> getTraceTreeWalker()
      Specifies that all tree walker rules call traceIn/traceOut.
    • getIsTraceTreeWalker

      @Internal public Property<Boolean> getIsTraceTreeWalker()
    • getMaxHeapSize

      @Internal public abstract Property<String> getMaxHeapSize()
      The maximum heap size for the forked antlr process (ex: '1g').
    • getArguments

      @Input public abstract ListProperty<String> getArguments()
      List of command-line arguments passed to the antlr process
      Returns:
      The antlr command-line arguments
    • getOutputDirectory

      @OutputDirectory public abstract DirectoryProperty getOutputDirectory()
      Returns the directory to generate the parser source files into.
      Returns:
      The output directory.
    • getAntlrClasspath

      @Classpath public abstract ConfigurableFileCollection getAntlrClasspath()
      Returns the classpath containing the Ant ANTLR task implementation.
      Returns:
      The Ant task implementation classpath.
    • getWorkerProcessBuilderFactory

      @Inject protected abstract org.gradle.process.internal.worker.WorkerProcessFactory getWorkerProcessBuilderFactory()
    • getProjectLayout

      @Inject protected abstract ProjectLayout getProjectLayout()
    • execute

      public void execute(InputChanges inputChanges)
      Generate the parsers.
      Since:
      6.0
    • setSource

      public void setSource(FileTree source)
      Sets the source for this task. Delegates to setSource(Object). If the source is of type SourceDirectorySet, then the relative path of each source grammar files is used to determine the relative output path of the generated source If the source is not of type SourceDirectorySet, then the generated source files end up flattened in the specified output directory.
      Overrides:
      setSource in class SourceTask
      Parameters:
      source - The source.
      Since:
      4.0
    • setSource

      public void setSource(Object source)
      Sets the source for this task. Delegates to SourceTask.setSource(Object). If the source is of type SourceDirectorySet, then the relative path of each source grammar files is used to determine the relative output path of the generated source If the source is not of type SourceDirectorySet, then the generated source files end up flattened in the specified output directory.
      Overrides:
      setSource in class SourceTask
      Parameters:
      source - The source.
    • getSource

      @Internal("tracked via stableSources") public FileTree getSource()
      Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

      The PathSensitivity for the sources is configured to be PathSensitivity.ABSOLUTE. If your sources are less strict, please change it accordingly by overriding this method in your subclass.

      Overrides:
      getSource in class SourceTask
      Returns:
      The source.
    • getStableSources

      The sources for incremental change detection.
      Since:
      6.0
    • getDeleter

      @Inject protected abstract org.gradle.internal.file.Deleter getDeleter()
    • getPackageName

      @Input @Optional @Incubating public abstract Property<String> getPackageName()
      Sets the package to be used when generating the parser source files. Supported only when using Antlr 4. This will add a "-package" argument to the ANTLR command line as well as adjust the target directory to generate sources into a package-specific subdirectory of getOutputDirectory(). For example, if the package name is set to "com.foo.bar" and the output directory is set to "path/to/output", the sources will be generated into "path/to/output/com/foo/bar".
      Since:
      9.1.0