diff --git a/README.md b/README.md index 0b8e60ac3fabb14885a3ac9b8fe83006cb0cdb28..cbae578f9b8f1d0e15acd104df87b509fbb4f47d 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ You normally don't need to do this - all of these options have reasonable defaul tasks.named("generateSableCCSource").configure { sableCCClasspath = sourceSets.something.runtimeClasspath maxHeapSize = "512M" + arguments = ["--no-inline"] // WARNING: The destination dirs will be DELETED every time the SableCC task runs! destinationJavaDir = "my/custom/out/java" destinationResourcesDir = "my/custom/out/resources" @@ -62,6 +63,7 @@ tasks.named("generateSableCCSource").configure { ## Version 1.2.0 (not released yet) +* Add ability to pass extra arguments to SableCC using the new `arguments` property of `SableCCTask`. * Fix deprecation warnings on Gradle 8.12 about accessing `Project` at execution time. ## Version 1.1.0 diff --git a/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java b/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java index 27466f90c5e3572913184de5c296d119e6762c90..8afe9d3ed9c9056042ba51cb5b4a229176fc0efe 100644 --- a/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java +++ b/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java @@ -6,6 +6,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.inject.Inject; @@ -35,6 +36,7 @@ public abstract class SableCCTask extends SourceTask { private FileCollection sableCCClasspath; private String maxHeapSize; + private List<String> arguments; private final DirectoryProperty destinationJavaDir; private final DirectoryProperty destinationResourcesDir; @@ -47,6 +49,7 @@ public abstract class SableCCTask extends SourceTask { this.sableCCClasspath = null; this.maxHeapSize = null; + this.arguments = new ArrayList<>(); this.destinationJavaDir = objectFactory.directoryProperty(); this.destinationResourcesDir = objectFactory.directoryProperty(); } @@ -84,6 +87,15 @@ public abstract class SableCCTask extends SourceTask { this.maxHeapSize = maxHeapSize; } + @Input + public List<String> getArguments() { + return this.arguments; + } + + public void setArguments(List<String> arguments) { + this.arguments = Objects.requireNonNull(arguments, "arguments"); + } + @OutputDirectory public Directory getDestinationJavaDir() { return this.destinationJavaDir.get(); @@ -120,6 +132,7 @@ public abstract class SableCCTask extends SourceTask { List<String> args = new ArrayList<>(); args.add("-d"); args.add(destinationJavaPath.toString()); + args.addAll(this.getArguments()); for (File file : this.getSource().getFiles()) { args.add(file.getPath()); }