我已经开始在SpringBoot 2项目中使用Spring Cloud Contract。 Groovy合同的默认位置是${project.rootDir}/src/test/resources/contracts
,我想更改此文件夹,因为当IntelliJ仅包含软件包/文件夹而没有groovy文件时,它会隐藏该文件夹。例如${project.rootDir}/src/test/resources/contracts/my_contracts/testContract.groovy
我尝试设置contractsDslDir
,但这无效。当我删除文件夹src/test/resources/contracts
时,它将在构建时重新创建。以下是我的Gradle构建文件的摘要。
buildscript {
repositories {
maven {
name "spring-plugins-releases"
url "..."
}
}
ext {
springContractVersion = "2.0.1.RELEASE"
}
dependencies {
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${springContractVersion}"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${project.springContractVersion}"
}
}
apply plugin: "spring-cloud-contract"
dependencies {
...
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.cloud:spring-cloud-starter-contract-verifier")
}
contracts {
testMode = 'EXPLICIT'
contractsDslDir = new File("${project.rootDir}/src/test/contracts")
baseClassMappings {
...
}
}