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 897963917a3c4e5e82aece8a0ff9cef61690982b..09f84e6347f061b3ee1917b77171e360cb9e1bda 100644
--- a/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
+++ b/src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
@@ -3,6 +3,7 @@ package de.hhu.stups.sablecc.gradle;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -103,10 +104,13 @@ public abstract class SableCCTask extends SourceTask {
 	
 	@TaskAction
 	void execute() throws IOException {
+		Path destinationJavaPath = this.getDestinationJavaDir().getAsFile().toPath();
+		Path destinationResourcesPath = this.getDestinationResourcesDir().getAsFile().toPath();
+		
 		// Delete any previously generated source files, so that no longer existing token and node classes aren't kept around.
-		this.getFs().delete(spec -> spec.delete(this.getDestinationJavaDir(), this.getDestinationResourcesDir()));
-		Files.createDirectories(this.getDestinationJavaDir().getAsFile().toPath());
-		Files.createDirectories(this.getDestinationResourcesDir().getAsFile().toPath());
+		this.getFs().delete(spec -> spec.delete(destinationJavaPath, destinationResourcesPath));
+		Files.createDirectories(destinationJavaPath);
+		Files.createDirectories(destinationResourcesPath);
 		
 		// Call SableCC to generate the source files.
 		this.getExecOperations().javaexec(spec -> {
@@ -115,7 +119,7 @@ public abstract class SableCCTask extends SourceTask {
 			spec.getMainClass().set("org.sablecc.sablecc.SableCC");
 			final List<String> args = new ArrayList<>();
 			args.add("-d");
-			args.add(destinationJavaDir.get().getAsFile().getPath());
+			args.add(destinationJavaPath.toString());
 			for (final File file : this.getSource().getFiles()) {
 				args.add(file.getPath());
 			}
@@ -124,13 +128,13 @@ public abstract class SableCCTask extends SourceTask {
 		
 		// Move generated dat files from Java source directory to resources directory.
 		this.getFs().copy(spec -> {
-			spec.from(this.getDestinationJavaDir());
-			spec.into(this.getDestinationResourcesDir());
+			spec.from(destinationJavaPath);
+			spec.into(destinationResourcesPath);
 			spec.include("**/*.dat");
 		});
 		this.getFs().delete(spec -> {
 			ConfigurableFileTree fileTree = this.objectFactory.fileTree();
-			fileTree.from(this.getDestinationJavaDir());
+			fileTree.from(destinationJavaPath);
 			fileTree.include("**/*.dat");
 			spec.delete(fileTree);
 		});