我有一个gradle文件可以工作很长一段时间,直到我的OS X上的gradle被更新(只是猜测,我不记得以前的verison)到4.3.1
这是我的档案:
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'maven'
project.ext {
springBootVersion = '1.3.0.BUILD-SNAPSHOT'
}
configurations {
querydslapt
}
jacoco {
toolVersion = "0.7.0.201403182114"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript {
repositories {
flatDir {
dirs "$rootProject.projectDir/libs"
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
jar {
baseName = 'cnet-ofac-app'
version = '0.5'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://repo.spring.io/snapshot" }
maven { url 'http://repo.spring.io/milestone' }
}
dependencies {
querydslapt group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: '2.8.0', classifier: 'apt-one-jar', transitive: false
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.security:spring-security-web:4.0.0.M1")
compile("org.springframework.security:spring-security-config:4.0.0.M1")
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.0')
compile("org.hibernate:hibernate-core:4.3.4.Final")
compile("org.hibernate:hibernate-entitymanager:4.3.4.Final")
compile("org.hibernate:hibernate-validator")
compile("org.apache.velocity:velocity:1.7")
compile('javax.mail:mail:1.4.1')
compile("org.springframework:spring-context-support")
compile("mysql:mysql-connector-java:5.1.6")
compile("com.h2database:h2:1.3.172")
compile("joda-time:joda-time:2.3")
compile("org.codehaus.groovy.modules.http-builder:http-builder:0.7.1")
compile('org.codehaus.groovy:groovy-all:2.2.1')
compile('org.jadira.usertype:usertype.jodatime:2.0.1')
compile("org.liquibase:liquibase-core")
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
testCompile('org.spockframework:spock-core:1.0-groovy-2.0') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile('org.spockframework:spock-spring:1.0-groovy-2.0') {
exclude group: 'org.spockframework', module: 'spock-core'
exclude group: 'org.spockframework', module: 'spring-beans'
exclude group: 'org.spockframework', module: 'spring-test'
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
testCompile('org.codehaus.groovy.modules.http-builder:http-builder:0.7+')
testCompile("junit:junit")
// for the anontation processor
querydslapt group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: '2.8.0', classifier: 'apt-one-jar', transitive: false
// for compiling
compile("com.mysema.querydsl:querydsl-jpa:4.1.4")
compile("com.mysema.querydsl:querydsl-apt:4.1.4")
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-java8time', version: '2.1.0.RELEASE'
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
//Querydsl
def generatedSrcDir = 'src/main/generated'
task createGeneratedSrcDir << {
file(generatedSrcDir).mkdirs()
}
compileJava.dependsOn createGeneratedSrcDir
compileJava {
options.compilerArgs << '-processor' << 'com.querydsl.apt.jpa.JPAAnnotationProcessor' << '-s' << file(generatedSrcDir).absolutePath
}
clean {
delete generatedSrcDir
}
当我运行“gradle clean build --stacktrace”时,我收到消息:
Configure project : The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use
Task.doLast(Action) instead.
at org.gradle.api.internal.AbstractTask.leftShift(AbstractTask.java:622)
at org.gradle.api.Task$leftShift$0.call(Unknown Source)
at build_bh7od1fqn35ousgvitx2a7m2p.run(/Users/davidclark/projects/ofac/build.gradle:120)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:209)
.... FAILURE: Build failed with an exception.
* What went wrong: Failed to capture snapshot of input files for task ':compileJava' property 'classpath' during up-to-date check.
> java.lang.UnsupportedOperationException (no error message)
* Try: Run with --info or --debug option to get more log output.
* Exception is: org.gradle.api.UncheckedIOException: Failed to capture snapshot of input files for task ':compileJava' property 'classpath'
during up-to-date check.
at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.snapshotTaskFiles(CacheBackedTaskHistoryRepository.java:333)
我尝试将Spring Boot升级到1.5.9,希望能解决它,但显然Spring-Boot&amp; amp; QueryDSL所以为了时间的利益我不能那样做。
我也试过改变这个:
def generatedSrcDir = 'src/main/generated'
task createGeneratedSrcDir << {
file(generatedSrcDir).mkdirs()
}
到
def generatedSrcDir = 'src/main/generated'
task createGeneratedSrcDir {
doLast {
file(generatedSrcDir).mkdirs()
}
}
但这根本没有帮助。