Search code examples
javagradlebuild.gradlegradle-plugingradlew

How can I add gradle-api library to my project?


I have a spring boot project build with Gradle. When I clean/build project, I have these external libraries, marked as library root. And I can use it in my classes: import org.gradle.api.tasks.*

enter image description here

Now I create a new project, and these libraries absent. I don't understand how can I configure it. I want to use import org.gradle.api.tasks.* in a new project but I can't do it.


Solution

  • Just add the "gradleApi" into your new project dependencies :

    dependencies {   
        implementation gradleApi()
    }
    

    See : https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/DependencyHandler.html#gradleApi--