我在gradle build中遇到了一个问题。
这是我的构建。Gradle文件:
import groovy.xml.XmlSlurper
import groovy.xml.MarkupBuilder
def property(String key) { return project.findProperty(key).toString() }
static def definedInPluginXml(String key) {
File pluginXmlFile = new File('src/main/resources/META-INF/plugin.xml')
def idea = new XmlSlurper().parse(pluginXmlFile)
return idea."$key"
}
plugins {
id 'org.jetbrains.intellij' version '1.5.3'
id 'groovy'
id 'java'
id 'org.jetbrains.changelog' version '1.2.1'
}
apply plugin: 'org.jetbrains.changelog'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2022.1'
plugins = ['java', 'com.intellij.java', 'org.intellij.groovy']
}
/**
* Refreshes the plugin.xml file for deployment
*/
String ideaMinVersion = property("ideaMinVersion")
String ideaMaxVersion = property("ideaMaxVersion")
String pluginVersion = property("version")
patchPluginXml {
changeNotes = changelog.get(pluginVersion).toHTML()
version = pluginVersion
sinceBuild = ideaMinVersion
untilBuild = ideaMaxVersion
}
test {
useJUnit()
filter{
includeTestsMatching "fr.nereide.*"
}
}
tasks {
runIde {
jvmArgs("-Xmx2048m")
}
}
/**
* Config for changelog Plugin
*/
changelog {
itemPrefix = "-"
keepUnreleasedSection = false
unreleasedTerm = "[Unreleased]"
groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]
}
/**
* Generates the updatePlugin.xml files used for the repo.
*/
task generateUpdatePluginXml {
//...
}
/**
* Adds tests on build
*/
buildPlugin {
dependsOn 'test'
dependsOn 'generateUpdatePluginXml'
tasks.findByName('generateUpdatePluginXml').mustRunAfter 'patchPluginXml'
}
版本信息:
./gradlew --version
Welcome to Gradle 7.1!
Here are the highlights of this release:
- Faster incremental Java compilation
- Easier source set configuration in the Kotlin DSL
For more details see https://docs.gradle.org/7.1/release-notes.html
------------------------------------------------------------
Gradle 7.1
------------------------------------------------------------
Build time: 2021-06-14 14:47:26 UTC
Revision: 989ccc9952b140ee6ab88870e8a12f1b2998369e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.15 (Oracle Corporation 11.0.15+3)
OS: Linux 5.15.32-1-MANJARO amd64
我更新了以下依赖项:
- org.jetbrains.intellij从1.1.4到1.5.3
- org.codehaus。groovy:groovy-all:从2.5.14到3.0.9
也更新intellij { version = '2022.1' } // from 2021.2
在更新之前,测试发现一切正常。现在,在更新之后,我得到以下错误:
任务:test FAILED任务":test"执行失败。未找到给定的测试包括:fr.nereide.*
我是一个新手,对我来说它是如何工作的很不清楚,我觉得文档很肤浅。
我的问题是:
- 是否有一种简单的方法来启动所有测试(没有任何限制)
- 我必须添加
@Test
装饰器吗?这在更新之前是不必要的,并且在当前版本中没有太大变化。 - 我在哪里可以找到我可以用来找到我更新的包上的迁移信息的文档和信息 有没有像Gradle for Dummies这样的资源,有人可以实际推荐?
提前感谢!
发现这个问题,我知道已经有一段时间了。用useJUnitPlatform()
代替useJUnit()
和
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation platform('org.junit:junit-bom:5.8.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}