【问题标题】:Cannot add task ':jettyRun' as a task with that name already exists无法添加任务“:jettyRun”,因为具有该名称的任务已存在
【发布时间】:2017-02-05 11:54:32
【问题描述】:

我使用 gretty 作为构建我的 spring 项目的容器。但是当我发出命令 gradle clean 或 gradle jettyRun 时,我遇到了以下问题

无法添加任务“:jettyRun”,因为该名称的任务已存在。

PFB 我的 build.gradle 文件

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'jetty' //too old, Jetty6, use gretty
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'idea'
apply plugin: 'jacoco' //code coverage

def springVersion = "4.2.4.RELEASE"
def jdkVersion = 1.8
def junitVersion = "4.12"
def logbackVersion = "1.1.3"
def jclOverSlf4jVersion = "1.7.14"
def jstlVersion = "1.2"
def hamcrestVersion = "1.3"
def servletApiVersion = "3.1"

sourceCompatibility = jdkVersion
targetCompatibility = jdkVersion

repositories {
    mavenLocal()
    mavenCentral()
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.10'
}

configurations.all {
    exclude group: "commons-logging", module: "commons-logging"
}

dependencies {

    compile 'org.slf4j:jcl-over-slf4j:' + jclOverSlf4jVersion
    compile 'ch.qos.logback:logback-classic:' + logbackVersion
    compile 'org.springframework:spring-webmvc:' +springVersion
    compile 'javax.servlet:jstl:' + jstlVersion
    compile 'org.springframework:spring-test:' + springVersion
    //exclude the build in hamcrest
    testCompile('junit:junit:' + junitVersion) {
        exclude group: 'org.hamcrest'
    }
    testCompile 'org.hamcrest:hamcrest-library:' + hamcrestVersion
    //include in compile only, exclude in the war
    providedCompile 'javax.servlet:javax.servlet-api:' + servletApiVersion

}

//Gretty
buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'org.akhikhl.gretty:gretty:+'
  }
}

gretty {
  //port = 9000
  contextPath = 'loanSharks'
  servletContainer = 'jetty9'
}


//For Eclipse IDE only
eclipse {

  wtp {
    component {

      //define context path, default to project folder name
      contextPath = 'loanSharks'

    }

  }
}

jacoco {
    toolVersion = "0.7.5+"
    reportsDir = file("$buildDir/reports/jacoco")
}

jacocoTestReport {
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

【问题讨论】:

  • 似乎jetty插件和gretty插件都将任务jettyRun添加到项目中。你可以删除码头插件吗?
  • 感谢@AdamSkywalker 成功

标签: spring-mvc gradle gretty


【解决方案1】:

甚至删除了插件:'jetty',但我仍然遇到错误:

任务“:jettyRun”执行失败。 任务开始执行后,无法在任务 ':jettyRun' 上调用 TaskInputs.property(String, Object)。

【讨论】:

  • 你能发布你的 build.gradle 文件吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-29
  • 2019-08-02
  • 2016-07-10
  • 2013-03-21
相关资源
最近更新 更多