在根项目gradle中找不到任务“install”

时间:2017-12-02 09:02:26

标签: maven gradle groovy

我正在尝试使用maven插件将我的gradle项目转换为maven。我正在关注此SO link但是当我运行gradle install命令时出现以下错误

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

当我gradle -tasks时,它没有显示安装。该怎么做?

2 个答案:

答案 0 :(得分:2)

您是否可能按https://docs.gradle.org/current/userguide/build_init_plugin.html所述gradle init来表示install

maven插件添加了maven-publish任务,如果将其应用到您未构建的构建中。它将构建的artefact安装到您的本地maven存储库。这不是你想要的情况。无论如何,我建议使用maven插件而不是 let indexPath = IndexPath(item: tag, section: 0) self.tableCommunity.reloadRows(at: [indexPath], with: .fade) 插件。

答案 1 :(得分:0)

如果添加apply plugin: 'maven',则gradle install将创建一个POM。

Gradle脚本是这个。

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是这个。

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