Sonarqube gradle 错误:无法将任务'downloadNode'添加为已具有该名称的任务



我是sonarqube的新手,正在尝试使用gradle在java/jaxrs后端执行代码扫描。

我的build.gradle如下所示:

buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "4.4.5"
classpath group: "org.sonarsource.scanner.gradle", name:"sonarqube-gradle-plugin", version:"3.3"
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "org.sonarqube"
apply plugin: "com.liferay.plugin"
dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs", version: "1.0.0"
compile group: 'com.liferay', name: 'com.liferay.portal.remote.cors.api', version: '1.0.4'
compileInclude group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
compileOnly group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.9'
compileOnly group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.5'
implementation group: 'com.liferay.portal', name: 'release.portal.api', version: '7.3.1-ga2'
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
//
implementation group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.7.0'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')
testCompile('org.junit.jupiter:junit-jupiter-params:5.4.2')
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.0'
testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.7.0'
testCompile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
testImplementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
testImplementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.9'
testImplementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.5'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
task copyJar(type: Copy) {
from "build/libs"
into "../../../../files/osgi/modules/"
}
copyJar.dependsOn(build)
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
test {
useJUnitPlatform()
}

当我试图从windows powershell或cmd:执行声纳扫描仪命令时

.gradlew sonarqube -Dsonar.projectKey=be_d254_enroll_center -Dsonar.host.url=http://localhost:9000 -Dsonar.login=1f774e64a98490b5e01646104342de340e40f263 -Dsonar.sources=src

我得到以下错误,指向另一个项目be_256,该项目与我执行命令的项目不同,该命令为be_261

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':LR/rs/256/be_256'.
> Cannot add task 'downloadNode' as a task with that name already exists.

配置

  • Sonarqube LTS 8.9.3
  • Gradle版本4.10.2
  • Java版本11

我试图清除渐变缓存,但没有成功。感谢您的帮助。谢谢

编辑1

我已经能够通过完全卸载Gradle并重新安装来解决以前的错误,我现在有以下错误:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':LR/rs/261/be_261'.
> Could not resolve all artifacts for configuration ':LR/resident_services/d261_update_address/be_d261_update_address:classpath'.
> Could not download sonar-scanner-api.jar (org.sonarsource.scanner.api:sonar-scanner-api:2.16.1.361)
> Could not get resource 'https://repository-cdn.liferay.com/nexus/content/groups/public/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar'.
> Could not GET 'https://repository-cdn.liferay.com/nexus/content/groups/public/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar'.
> Received fatal alert: handshake_failure

编辑2

我再次陷入这个问题,我再次尝试清除gradle的缓存,但它不起作用

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':LR/rs/256/be_256'.
> Cannot add task 'downloadNode' as a task with that name already exists.

在我将BE文件夹移到另一个目录后,这个问题得到了修复。

最新更新