Task 'install' not found in root project gradle

14,912

Solution 1

Did you maybe mean gradle init as described at https://docs.gradle.org/current/userguide/build_init_plugin.html?

The install task is added by the maven plugin if you apply it to your build which you didn't do. It installs the built artefact to your local maven repository. That is not what you want in your situation. Anyway I'd recommend using the maven-publish plugin instead of the maven plugin.

Solution 2

If you add apply plugin: 'maven' the gradle install creates a POM.

Gradle script is this.

buildscript {
     repositories {
         maven { url "http://repo.spring.io/snapshot" }
         maven { url "http://repo.spring.io/milestone" }
         maven { url "https://repo1.maven.org/maven2/" }
         mavenLocal()
        mavenCentral()

    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "org.springframework.boot"
apply plugin: 'io.spring.dependency-management'
jar {
    baseName = 'Angular-Boot-Rest'
    version =  '0.1.0'
}

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "http://repo.spring.io/libs-release" }
}


tasks.withType(Copy) {
    eachFile { println it.file }
}
jar {
    enabled = true
}
dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("junit:junit")
} 

task stage(dependsOn: ['clean','build','jar', 'installApp']){}

POM created is this.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId/>
  <artifactId>Angular-Boot-Rest</artifactId>
  <version>unspecified</version>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>tomcat-annotations-api</artifactId>
          <groupId>org.apache.tomcat</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.0.5.RELEASE</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>
Share:
14,912
LowCool
Author by

LowCool

Updated on June 18, 2022

Comments

  • LowCool
    LowCool about 2 years

    I am trying to convert my Gradle project to Maven using Maven plugin. I am following this SO link but when I ran the Gradle install command I got the following error

    C:\Users\>gradle install
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Task 'install' not found in root project .
    
    * Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log outpu
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 0s
    

    When I did gradle -tasks it is not showing install. what to do in this?

  • Hodglem
    Hodglem over 2 years
    Thanks for this. It looks like gradle removed maven plugin with gradle 7. There is a new plugin called maven-publish. More detail here: docs.gradle.org/7.0/userguide/…