Kotlin 1.5.10,Gradle 7.0.2_2 - 找不到方法 testCompile() group=org.junit.jupiter,name=junit-jupiter-api,ve
Posted
技术标签:
【中文标题】Kotlin 1.5.10,Gradle 7.0.2_2 - 找不到方法 testCompile() group=org.junit.jupiter,name=junit-jupiter-api,version=5.7.2【英文标题】:Kotlin 1.5.10, Gradle 7.0.2_2 - Could not find method testCompile() group=org.junit.jupiter, name=junit-jupiter-api, version=5.7.2 【发布时间】:2021-08-05 07:21:20 【问题描述】:关注后:https://youtrack.jetbrains.com/issue/KT-46090
我仍然有问题:
配置项目:Gradle 不完全支持 POM 重定位到其他版本号:xml-apis:xml-apis:2.0.2 重定位到 xml-apis:xml-apis:1.0.b2。请直接更新您的依赖项 使用正确的版本“xml-apis:xml-apis:1.0.b2”。决议将 只选择重定位元素的依赖项。文物及其他 元数据将被忽略。
FAILURE:构建失败并出现异常。
其中:构建文件 '/Users/NOTiFY/IdeaProjects/GoStopHandle/build.gradle' 行:53
出了什么问题:评估根项目“GoStopHandle”时出现问题。
找不到参数 [group=org.junit.jupiter, name=junit-jupiter-api, version=5.7.1] 的方法 testCompile() 类型的对象 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。
分级:
plugins
id "war"
id "ear"
id "idea"
// id "org.jetbrains.kotlin.jvm" version "1.4.32"
// id "org.jetbrains.kotlin.plugin.jpa" version "1.4.32"
id "org.jetbrains.kotlin.jvm" version "1.5.0"
id "org.jetbrains.kotlin.plugin.jpa" version "1.5.0"
// Static Code Checkers x 4
id "checkstyle"
id "com.github.spotbugs" version "4.7.1"
id "pmd"
id "org.sonarqube" version "3.1.1"
id "org.wildfly.build.provision" version "0.0.11"
sourceCompatibility = 1.13
repositories
mavenLocal()
mavenCentral()
//noinspection MultipleRepositoryUrls
maven
name "jboss-nexus"
url "http://repository.jboss.org/nexus/content/groups/public/"
url "https://repository.jboss.org/nexus/content/groups/public-jboss"
url "https://repository.jboss.org/nexus/content/repositories"
url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases"
//url "http://repository.primefaces.org"
url "https://repository.primefaces.org"
jcenter()
flatDir
dirs "lib"
checkstyle
//toolVersion "8.42"
toolVersion "8.41.1"
configFile = file("config/checkstyle/checkstyle.xml")
dependencies
// JUnit 5 (Jupiter) 5.7.1 Feb, 2021
testCompile group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.7.1"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.7.1"
testCompile group: "org.junit.vintage", name: "junit-vintage-engine", version: "5.7.1"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-params", version: "5.7.1"
// org.slf4j 25/08/2020
testCompile group: "org.slf4j", name: "slf4j-nop", version: "1.7.30"
testCompile group: "org.slf4j", name: "slf4j-simple", version: "1.7.30"
testCompile group: "org.slf4j", name: "slf4j-jdk14", version: "1.7.30"
// JBoss Weld 3.1.5.Final CDI 2.0
//compile group: "org.jboss.weld.se", name: "weld-se-core", version: "4.0.0.Final"
//compile group: "org.jboss.weld.se", name: "weld-se-core", version: "3.1.6.Final"
compile group: "org.jboss.weld.module", name: "weld-web", version: "3.1.5.Final"
compile group: "javax.ejb", name: "javax.ejb-api", version: "3.2.2"
compile group: "org.jboss.spec.javax.ejb", name: "jboss-ejb-api_3.2_spec", version: "2.0.0.Final"
compile group: "org.eclipse.persistence", name: "javax.persistence", version: "2.2.1"
compile group: "javax.inject", name: "javax.inject", version: "1"
compile group: "javax.faces", name: "javax.faces-api", version: "2.3"
compile group: "javax.enterprise", name: "cdi-api", version: "2.0.SP1"
// 09/12/20 - Fix pom -> Gradle for
compile group: "com.sun.xml.bind", name: "jaxb-impl", version: "3.0.0"
compile group: "javax.xml.bind", name: "jaxb-api", version: "2.3.1"
// 3 x Hibernate Feb, 2021
compile group: "org.hibernate", name: "hibernate-core", version: "5.4.31.Final"
compile group: "org.hibernate", name: "hibernate-entitymanager", version: "5.4.31.Final"
compile group: "org.hibernate", name: "hibernate-commons-annotations", version: "3.2.0.Final"
compile group: "org.hibernate", name: "hibernate-search-orm", version: "5.11.8.Final"
compile group: "org.hibernate.ogm", name: "hibernate-ogm-mongodb", version: "5.4.1.Final"
// 10/10/2020 x 3
compile group: "org.jboss.resteasy", name: "resteasy-jaxrs", version: "3.14.0.Final"
compile group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.13"
compile group: "org.apache.httpcomponents", name: "httpcore", version: "4.4.13"
// Omnifaces + WEB-INF 2021-01-24 16:49
compile group: "org.omnifaces", name: "omnifaces", version: "3.11"
// compile group: "org.primefaces", name: "primefaces", version: "10.0.1"
implementation group: 'org.primefaces', name: 'primefaces', version: '10.0.1'
compile group: "org.primefaces.themes", name: "bootstrap", version: "1.0.10"
// mongodb - 6 February 2021
compile group: "org.mongodb", name: "mongo-java-driver", version: "3.12.8"
compile group: "com.google.code.gson", name: "gson", version: "2.8.6"
compile group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1.1"
compile group: "org.slf4j", name: "slf4j-api", version: "1.7.30"
// Kotlin - 21-05-05
// compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.4.32"
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.5.0"
// JSoup Java html Parser - 01/03/2020
compile group: "org.jsoup", name: "jsoup", version: "1.13.1"
// JUnit Jupiter
//compile group: "org.junit.platform", name: "junit-platform-commons", version: "1.3.2"
//compile group: "org.opentest4j", name: "opentest4j", version: "1.1.1"
// https://mvnrepository.com/artifact/org.picketlink/picketlink-idm-parent
//compile group: "org.picketlink", name: "picketlink-idm-parent", version: "2.5.5.SP12", ext: "pom"
providedCompile "javax.ejb:javax.ejb-api:3.2.2"
//providedCompile "org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.1.Final"
providedCompile group: "org.jboss.spec.javax.ejb", name: "jboss-ejb-api_3.2_spec", version: "2.0.0.Final"
providedCompile "org.eclipse.persistence:javax.persistence:2.2.0"
providedCompile "javax.inject:javax.inject:1"
providedCompile "javax.faces:javax.faces-api:2.3"
providedCompile group: "javax.enterprise", name: "cdi-api", version: "2.0.SP1"
providedCompile group: "javax.servlet", name: "javax.servlet-api", version: "4.0.1"
// Hibernate - Feb, 2021
providedCompile "org.hibernate:hibernate-core:5.4.28.Final"
providedCompile "org.hibernate:hibernate-entitymanager:5.4.28.Final"
// org.hibernate:hibernate - Mar, 2010
providedCompile "org.hibernate:hibernate-commons-annotations:3.2.0.Final"
providedCompile "org.hibernate:hibernate-search-orm:5.11.8.Final"
providedCompile "org.jboss.resteasy:resteasy-jaxrs:3.14.0.Final"
providedCompile "com.google.code.gson:gson:2.8.6"
providedCompile "org.slf4j:slf4j-api:1.7.30"
providedCompile "javax.ws.rs:javax.ws.rs-api:2.1.1"
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0"
checkstyleMain
source = ["src/main/java"]
spotbugs
ignoreFailures = true
toolVersion = "4.2.3"
reportsDir = file("reports/spotbugs")
effort = "max"
reportLevel = "high"
// ignoreFailures = false
// showProgress = true
// effort = "default"
// reportLevel = "default"
// visitors = [ "FindSqlInjection", "SwitchFallthrough" ]
// omitVisitors = [ "FindNonShortCircuit" ]
// reportsDir = file("$buildDir/ƒprime")
// includeFilter = file("include.xml")
// excludeFilter = file("exclude.xml")
// onlyAnalyze = [ "com.foobar.MyClass", "com.foobar.mypkg.*" ]
// maxHeapSize = "1g"
// extraArgs = [ "-nested:false" ]
// jvmArgs = [ "-Duser.language=ja" ]
pmd
ignoreFailures = true
reportsDir = file("reports/pmd")
ruleSets = [
"java-basic",
"java-braces",
"java-clone",
"java-codesize",
"java-comments",
"java-controversial",
"java-coupling",
"java-design",
"java-empty",
"java-finalizers",
"java-imports",
"java-optimizations",
"java-strictexception",
"java-strings",
"java-typeresolution",
"java-unnecessary",
"java-unusedcode"
]
tasks.withType(Pmd)
reports
xml.enabled = true
html.enabled = true
tasks.withType(Checkstyle)
reports
html.destination rootProject.file("reports/checkstyle/checkstyle.html")
task deleteFiles(type: Delete)
project.logger.lifecycle(">>>>> 1 deleteFiles")
delete fileTree("./build/libs")
include "**/GoStopHandle*.?ar"
delete fileTree("./src/main/application")
include "**/GoStopHandle*.war"
include "**/GoStopHandle*.jar"
include "**/GoStopHandle*.ear"
task GoStopHandleWAR(type: War)
project.logger.lifecycle(">>>>> 2 GoStopHandleWAR")
dependsOn deleteFiles
archiveName "GoStopHandleWAR.war"
//archiveFileName "GoStopHandleWAR.war"
//webInf
// from "WEB-INF"
//
rootSpec.exclude("**/dto/*")
rootSpec.exclude("**/ean/*")
rootSpec.exclude("**/ejb/*")
rootSpec.exclude("**/entity/*")
rootSpec.exclude("**/filter/*")
rootSpec.exclude("**/gson/*")
//rootSpec.exclude("**/omnifaces/*")
rootSpec.exclude("**/controller/*")
// Exclude push PushEvent.class
rootSpec.exclude("**/push/PushEvent.class")
rootSpec.exclude("**/push/PushEvent.class")
rootSpec.exclude("**/webservices/*")
rootSpec.exclude("**/GoStopHandle*.jar")
rootSpec.exclude("**/GoStopHandle*.war")
task GoStopHandleJAR(type: Jar)
project.logger.lifecycle(">>>>> 3 GoStopHandleJAR")
dependsOn GoStopHandleWAR
archiveName "GoStopHandleJAR.jar"
// archiveFileName "GoStopHandleJAR.jar"
from("./src/main/java")
include "META-INF/**"
// Exclude
rootSpec.exclude("**/jsf/SliderViewBean.class")
rootSpec.exclude("**/push/PushBean.class")
from("./build/classes/java/main")
include "*/**"
// Kotlin
from("./build/classes/kotlin/main")
include "*/**"
task copyGoStopHandleWAR(type: Copy)
project.logger.lifecycle(">>>>> 4 copyGoStopHandleWAR")
dependsOn GoStopHandleJAR
from file("./build/libs/GoStopHandleWAR.war")
into file("./src/main/application")
task copyGoStopHandleJAR(type: Copy)
project.logger.lifecycle(">>>>> 5 copyGoStopHandleWAR")
dependsOn copyGoStopHandleWAR
from file("./build/libs/GoStopHandleJAR.jar")
into file("./src/main/application")
task GoStopHandleEAR(type: Ear)
project.logger.lifecycle(">>>>> 6 GoStopHandleEAR")
apply plugin: "ear"
dependsOn copyGoStopHandleJAR
archiveName "GoStopHandle.ear"
// archiveFileName "GoStopHandle.ear"
manifest
from("./src/main/resources/META-INF/MANIFEST.MF")
exclude "**/*.class"
exclude "**/asm-Java.jar"
exclude "**/jboss-deployment-structure.xml"
exclude("**/beans.xml")
dependencies
earlib group: "com.google.code.gson", name: "gson", version: "2.8.6", ext: "jar"
earlib group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.13", ext: "jar"
earlib group: "org.apache.httpcomponents", name: "httpcore", version: "4.4.13", ext: "jar"
// earlib group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.4.32", ext: "jar"
earlib group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.5.0", ext: "jar"
Kotlin 1.5.0 和 JUnit 5.7.1 的进展或问题是什么?
TIA。
【问题讨论】:
【参考方案1】:2021 年 5 月 19 日使用 5.7.2_1 升级 JUnit 仍可获得:
What went wrong:
A problem occurred evaluating root project 'GoStopHandle'.
> Could not find method testCompile() for arguments [group=org.junit.jupiter, name=junit-jupiter-api, version=5.7.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
迁移:
编译组:-> 实现组:
【讨论】:
以上是关于Kotlin 1.5.10,Gradle 7.0.2_2 - 找不到方法 testCompile() group=org.junit.jupiter,name=junit-jupiter-api,ve的主要内容,如果未能解决你的问题,请参考以下文章
Kotlin 编译“错误:Android Gradle 插件仅支持 Kotlin Gradle 插件版本 1.3.0 及更高版本。”但 build.gradle 中没有 kotlin_version?
Kotlin gradle 无法初始化类 org.jetbrains.kotlin.gradle.internal.KotlinSourceSetProviderImplKt