无法添加任务':jettyRun'作为具有该名称的任务已存在

时间:2017-02-05 11:54:33

标签: spring-mvc gradle gretty

我使用gretty作为构建弹簧项目的容器。但是当我发出命令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
    }
}

1 个答案:

答案 0 :(得分:0)

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

  

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