I want to create a SimpleTask Gradle with JAVA. However I cannot compile my projet because "import org.gradle.api.DefaultTask' is not found. GradleVersion : 6.3
As said on documentation I create a class on root/buildSrc/src/main/java/SimpleTask.java
With this code I have an : "error: cannot find symbol" symbol: class DefaultTask.
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
public class SimpleTask extends DefaultTask {
}
I've tried to add the dependency (but same effect)
dependencies {
// https://mvnrepository.com/artifact/org.gradle/api
implementation group: 'org.gradle', name: 'api', version: '1.0'
I am not familiar with that dependency, but if it exists, it is for Gradle 1.0 from five years ago. That is definitely not what you want.
I don't believe the official Gradle API is published as a dependency. But you can declare a dependency on the API of the current version of Gradle by using the DependencyHandler.gradleApi() method like this:
dependencies {
implementation gradleApi()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With