gretty appStart 失败,未知 属性 'classesDirs'

gretty appStart fails with unknown property 'classesDirs'

我正在尝试使用 gradle gretty 插件(gradle 版本 3.4)构建一个 Java Servlet。 我依赖于另一个项目 databaseprovider:1.0-SNAPSHOT(包括与数据库的连接和一些 spring 定义...)。 当我 运行 任务 "gradle war" 时,.war 文件与 WEB-INF/lib 中的所有依赖项一起正确构建。 但是当我尝试从 "gradle appStart" 开始时,我遇到了以下问题:

What went wrong: Execution failed for task ':appStart'. Could not get unknown property 'classesDirs' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'classesDirs' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

没有依赖项 databaseprovider:1.0-SNAPSHOT 码头启动没有问题:

INFO Jetty 9.2.22.v20170606 started and listening on port 8080

build.gradle:

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath "org.akhikhl.gretty:gretty:+"
    classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE"
  }
}

apply plugin:'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'

repositories {
    maven {
        url "http://..."
    }
    mavenLocal()
}

dependencies {
    compile('databaseprovider:1.0-SNAPSHOT'){
        changing=true
    }
}

gretty {
    httpPort = 8080
    contextPath = '/'
    servletContainer = 'jetty9'    
}

build.gradle 来自数据库提供者:

buildscript {
    repositories {
      maven {
          url "http://..."
      }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply from: 'liquibase.gradle'


jar {
    baseName = 'databaseprovider'
    version =  '1.0-SNAPSHOT'
}

repositories {
    maven {
        url "http://..."
    }
    mavenLocal()
    jcenter()
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-jpa:1.4.0.RELEASE")
    compile group: 'org.springframework.data', name: 'spring-data-jpa', version:'1.10.2.RELEASE'
    compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.0.9.Final'
    testRuntime group: 'com.h2database', name: 'h2', version: '1.4.192'
    compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.0.13'
    compile group: 'ch.qos.logback', name: 'logback-core', version:'1.0.13'
    compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.5'
    compile group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.5'
    compile group: 'org.slf4j', name: 'log4j-over-slf4j', version:'1.7.5'
    compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
    compile (group: 'com.mattbertolini', name: 'liquibase-slf4j', version: "1.2.1")
    compile (group: 'org.liquibase', name: 'liquibase-core', version: "3.5.3")
    compile group: 'javax.validation', name: 'validation-api', version: '1.1.0.Final'
    testCompile("junit:junit")
    runtime("mysql:mysql-connector-java:5.1.39")
    testCompile("org.springframework:spring-test")
}

我可以通过添加 gretty 的版本来解决问题:

我在 build.gradle 中更改类路径后

classpath "org.akhikhl.gretty:gretty:+"

classpath "org.akhikhl.gretty:gretty:1.4.2"

(与 gradle 3.4 兼容的版本)jetty 无异常启动。

当我遇到这个问题时,我通过谷歌搜索错误消息发现了这个问题。对我来说,我在 this Github thread 中找到了答案。基本上,通过将我的 Gradle 版本升级到 4.8,我能够解决这个问题。