当前位置: 首页 > 知识库问答 >
问题:

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

别浩漫
2023-03-14

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

我的身材。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执行sonar scanner命令时:

.\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缓存,但没有成功。感谢您的帮助。谢谢

我已经能够通过完全卸载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

我又一次陷入了这个问题,我又一次试图清除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.

共有1个答案

宗增
2023-03-14

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

 类似资料:
  • 看起来是这样的 我来来回回地想弄清楚这到底是怎么回事。有些东西不能直接开箱操作,这似乎很奇怪。有人面临类似的问题吗?

  • 以下是我的代码尝试执行的操作:编写一个名为 processName 的方法,该方法接受控制台的扫描仪作为参数,并提示用户输入全名,然后以相反的顺序打印名称(即姓氏、名字)。 以下是与用户的示例对话: 请输入您的全名:Sammy Jankis 你的名字倒过来是詹基斯,萨米 我在阅读时出错: 我的问题是,如何将名称字符串分成两部分,以便将其反转?请使用简单的术语,因为我是编码新手。

  • 清理用户需要清理2个表,新建类net.wendal.nutzbook.quartz.job.CleanNonActiveUserJob package net.wendal.nutzbook.quartz.job; import java.util.Date; import net.wendal.nutzbook.bean.User; import net.wendal.nutzbook.be

  • 问题内容: 我将在春季使用任务名称空间设置一个计划任务计划。 我想根据cron表达式大多数的任务安排到火,有的在启动后只启动一次,一个固定的延迟,然后再也没有(即什么设置,以将实现在SimpleTriggerBean)。 是否有可能在任务名称空间中实现此目标,还是我需要恢复为触发器定义bean? 问题答案: 如果你看看任务命名空间XSD,你会发现只有三个不同的配置类型:,和。 并且,如果您查看Sc

  • 首先,新建一个配置文件 conf/custom/cron.properties # clean non-active user cron.net.wendal.nutzbook.quartz.job.CleanNonActiveUserJob=0 0/2 * * * ? cron.pkgs=net.wendal.nutzbook.quartz.job 这个文件是定义Job类与cron表达式的关系