Quick question: "unknown property 'Paths' for root project gradle-Paths.get"

Hi,

I’m trying to clean up the paths in a build.gradle file. I tried using: Paths.get to concatenate the pathnames but I am getting an error.

Here is my build.gradle file in my test-case:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This is a general purpose Gradle build.
 * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/
 */

apply plugin: 'java'

println file(Paths.get('src/main/java', 'foo', 'bar'))

The full error is:

MacBook-Pro-504% ./gradlew test

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/dlynch/eclipse-workspace/TESTCASES/gradle-Paths.get/build.gradle' line: 10

* What went wrong:
A problem occurred evaluating root project 'gradle-Paths.get'.
> Could not get unknown property 'Paths' for root project 'gradle-Paths.get' of type org.gradle.api.Project.

The gradle project was created with a simple ‘gradle init’ and then I installed the wrapper.

If you’re looking for java.nio.file.Paths, you either need to import it or use the fully qualified name. The java.nio package is neither part of default Java imports nor the additional Gradle default imports that you can reference just by class name.

1 Like