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

1

5

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.

Pretonic answered 17/5, 2019 at 9:3 Comment(2)
You should add the current project as Parent project to your new project in its build.gradale filePossessory
these are different projects.Pretonic
K
10

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--

Khamsin answered 17/5, 2019 at 9:9 Comment(2)
it helps! But how can it work in my first project if I haven't this dependency in first project?Pretonic
maybe you have a plugin applied to your first project, that brings this dependency. (some plugins like java-gradle-plugin do that, for example)Khamsin

© 2022 - 2024 — McMap. All rights reserved.