diff --git a/README.md b/README.md
index abc1f2ecbc6fc188dffc79235bfaea792f52d6e9..0b8e60ac3fabb14885a3ac9b8fe83006cb0cdb28 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,10 @@ tasks.named("generateSableCCSource").configure {
 
 ## Changelog
 
+## Version 1.2.0 (not released yet)
+
+* Fix deprecation warnings on Gradle 8.12 about accessing `Project` at execution time.
+
 ## Version 1.1.0
 
 * Fix `sourcesJar` task not always depending on `generateSableCCSource` as intended. This caused deprecation warnings from Gradle about undeclared dependencies.
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 8dfdef21c4c59046d8c23c615295e54c68c41243..897963917a3c4e5e82aece8a0ff9cef61690982b 100644
--- a/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
+++ b/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
@@ -1,14 +1,21 @@
 package de.hhu.stups.sablecc.gradle;
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.inject.Inject;
+
 import org.gradle.api.NonNullApi;
+import org.gradle.api.file.ConfigurableFileTree;
 import org.gradle.api.file.Directory;
 import org.gradle.api.file.DirectoryProperty;
 import org.gradle.api.file.FileCollection;
+import org.gradle.api.file.FileSystemOperations;
 import org.gradle.api.file.FileTree;
+import org.gradle.api.model.ObjectFactory;
 import org.gradle.api.tasks.Classpath;
 import org.gradle.api.tasks.IgnoreEmptyDirectories;
 import org.gradle.api.tasks.Input;
@@ -18,24 +25,37 @@ import org.gradle.api.tasks.PathSensitive;
 import org.gradle.api.tasks.PathSensitivity;
 import org.gradle.api.tasks.SourceTask;
 import org.gradle.api.tasks.TaskAction;
+import org.gradle.process.ExecOperations;
 import org.gradle.work.NormalizeLineEndings;
 
 @NonNullApi
-public class SableCCTask extends SourceTask {
+public abstract class SableCCTask extends SourceTask {
+	private final ObjectFactory objectFactory;
+	
 	private FileCollection sableCCClasspath;
 	private String maxHeapSize;
 	private final DirectoryProperty destinationJavaDir;
 	private final DirectoryProperty destinationResourcesDir;
 	
-	public SableCCTask() {
+	@Inject
+	@SuppressWarnings("ConstructorNotProtectedInAbstractClass") // Must be public so that Gradle can find the constructor for dependency injection
+	public SableCCTask(ObjectFactory objectFactory) {
 		super();
 		
+		this.objectFactory = objectFactory;
+		
 		this.sableCCClasspath = null;
 		this.maxHeapSize = null;
-		this.destinationJavaDir = this.getProject().getObjects().directoryProperty();
-		this.destinationResourcesDir = this.getProject().getObjects().directoryProperty();
+		this.destinationJavaDir = objectFactory.directoryProperty();
+		this.destinationResourcesDir = objectFactory.directoryProperty();
 	}
 	
+	@Inject
+	protected abstract ExecOperations getExecOperations();
+	
+	@Inject
+	protected abstract FileSystemOperations getFs();
+	
 	@IgnoreEmptyDirectories
 	@NormalizeLineEndings
 	@PathSensitive(PathSensitivity.NONE)
@@ -82,14 +102,14 @@ public class SableCCTask extends SourceTask {
 	}
 	
 	@TaskAction
-	void execute() {
+	void execute() throws IOException {
 		// Delete any previously generated source files, so that no longer existing token and node classes aren't kept around.
-		this.getProject().delete(this.getDestinationJavaDir(), this.getDestinationResourcesDir());
-		this.getProject().mkdir(this.getDestinationJavaDir());
-		this.getProject().mkdir(this.getDestinationResourcesDir());
+		this.getFs().delete(spec -> spec.delete(this.getDestinationJavaDir(), this.getDestinationResourcesDir()));
+		Files.createDirectories(this.getDestinationJavaDir().getAsFile().toPath());
+		Files.createDirectories(this.getDestinationResourcesDir().getAsFile().toPath());
 		
 		// Call SableCC to generate the source files.
-		this.getProject().javaexec(spec -> {
+		this.getExecOperations().javaexec(spec -> {
 			spec.setClasspath(this.getSableCCClasspath());
 			spec.setMaxHeapSize(this.getMaxHeapSize());
 			spec.getMainClass().set("org.sablecc.sablecc.SableCC");
@@ -103,11 +123,16 @@ public class SableCCTask extends SourceTask {
 		});
 		
 		// Move generated dat files from Java source directory to resources directory.
-		this.getProject().copy(spec -> {
+		this.getFs().copy(spec -> {
 			spec.from(this.getDestinationJavaDir());
 			spec.into(this.getDestinationResourcesDir());
 			spec.include("**/*.dat");
 		});
-		this.getProject().delete(this.getProject().fileTree(this.getDestinationJavaDir(), files -> files.include("**/*.dat")));
+		this.getFs().delete(spec -> {
+			ConfigurableFileTree fileTree = this.objectFactory.fileTree();
+			fileTree.from(this.getDestinationJavaDir());
+			fileTree.include("**/*.dat");
+			spec.delete(fileTree);
+		});
 	}
 }