Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle custom Type : Default Task "error: cannot find symbol"

Tags:

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'
like image 945
Marcel kobain Avatar asked Jun 05 '20 12:06

Marcel kobain


1 Answers

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()
}
like image 73
Bjørn Vester Avatar answered Oct 20 '22 04:10

Bjørn Vester