hello,
i can run gradle build command successfully but when i run ‘gradle build install’ or ‘gradle install’ i get error - Task ‘install’ not found in root project. Gradle version i am using is 7.0
Please advise on how can i resolve the error.
Thanks
Obviously the build you are trying to run does not have a task with that name.
If you search for something like the install goal in Maven, chances are you have publishToMavenLocal task available.
Thank you Bjorn. Will I be able to use install task if i use another gradle version. In that case, will you kindly suggest me which gradle version shall i use.
Thank you again.
That’s not a question of Gradle version, but of the build you are running.
Each build can define a task called install by just writing one line in the build script.
The task will then just not do anything.
You can also apply some plugin that adds an install task to a build with some semantic, but that is totally up to the author of a build script.
No Gradle version will by default add any task to any build besides the most basic utility tasks like tasks, or projects.
If this is a foreign build you want to run, look at its documentation how to run it or ask the author.
If you are trying to create a build, you should maybe look at the user guide and sample projects.
@Vampire I did look at your response https://stackoverflow.com/a/47606508/3236309 on a similar question as well. I’m an absolute newbie to gradle and know nothing about it. I’m having this similar issue where I want to convert my gradle project to maven and when I add apply plugin: 'maven' to build.gradle file and run gradle install command, it fails with Task 'install' not found in root project.
I’m sorry, but I do not understand your answer. Could you please tell me a little bit in detail on how to unblock myself from this issue. What do you mean by The install task is added by the maven plugin if you apply it to your build which you didn’t do? Do I have to run gradle init on an already gradle project?
If you are new to Gradle, you should start with the official documentation, not with age-old StackOverflow answers, that are long outdated.
If you want to publish to a Maven repository which I interpret from your question, even in that SO answer I recommended using maven-publish instead of maven.
In current versions of Gradle this is not even a recommendation anymore as the legacy deprecated maven plugin was removed in the meantime for recent Gradle versions (7+).
Any answer or tutorial you find for Gradle that has reached a certain age has good chances to be outdated, as Gradle is evolving. If you see something using compile '...' => outdated. If you see something using apply plugin: ... most probably outdated. …
If you want to publish to a Maven repository, use the maven-publish plugin and generally apply plugins in a plugins { ... } block, not using the legacy apply plugin: ... which will be deprecated at some point.