maven - 在根项目 gradle 中找不到任务 'install'

标签 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它没有显示安装。怎么办?

最佳答案

如果您添加 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>

关于maven - 在根项目 gradle 中找不到任务 'install',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47606222/

相关文章:

java - 配置 Junit + spring + hibernate 4 + maven : Null pointer getting session

java - 如何解决与 Gradle 的依赖冲突?

java - 无法访问 Play-1.2 View 模板内的 HashMap

Jenkins pipelineJob DSL 不解释管道脚本中的变量

css - 如何在 JSF 中使用来自 webjars.org 的 Font Awesome

spring - 用于编写 Spring AOP 程序的 Maven 依赖项?

java - 无法安装 m2e 生命周期映射

spring - 使用 kotlin-spring 插件,仍然得到 class not open 错误

plugins - 如何从自定义插件设置Gradle Artifactory Publish插件默认配置/属性

grails - 性能问题碧 Jade 报告和grails/groovy