0

我使用 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
    }
}
4

1 回答 1

0

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

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

于 2017-02-08T09:24:03.167 回答