gpt4 book ai didi

gradle - 找不到根项目参数的方法 sonarqube()

转载 作者:行者123 更新时间:2023-12-04 18:59:39 28 4
gpt4 key购买 nike

执行以下命令时出现以下错误

gradle sonarqube --stacktrace


1.0.0-SNAPSHOT

FAILURE: Build failed with an exception.

* Where:
Build file '<some-path>/build.gradle' line: 82

* What went wrong:
A problem occurred evaluating root project 'hello-world'.
> Could not find method sonarqube() for arguments [build_1xxy82reobx5azrndj0huuw7k$_run_closure2@60ed12e8] on root project 'hello-world'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'hello-world'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:144)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:149)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:496)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:87)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method sonarqube() for arguments [build_1xxy82reobx5azrndj0huuw7k$_run_closure2@60ed12e8] on root project 'hello-world'.
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:175)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_1xxy82reobx5azrndj0huuw7k.run(<some-path>/build.gradle:82)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 47 more


BUILD FAILED

build.gradle
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
mavenLocal()
mavenCentral()

}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.2.4'
classpath 'org.ajoberstar:gradle-jacoco:0.1.0'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2'
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE")
}
}

repositories {
mavenCentral()
mavenLocal()
maven {
credentials {
username "hello"
password "world"
}
url "nexus-url/nexus-artifact"
}
}

apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'


group = 'com.company.project'

/* Determining version from jenkins pipeline, otherwise is set to 1.0.0-SNAPSHOT */
version = new ProjectVersion(1, 0, System.env.SOURCE_BUILD_NUMBER, System.env.RELEASE_TYPE)

println(version)


class ProjectVersion {
Integer major
Integer minor
String build
String releaseType

ProjectVersion(Integer major, Integer minor, String build, String releaseType) {

this.major = major
this.minor = minor
this.build = build
this.releaseType = releaseType
}

@Override
String toString() {
String fullVersion = "$major.$minor"

if(build) {
fullVersion += ".$build"
}
else{
fullVersion += ".0"
}

if(releaseType) {
fullVersion += "-RELEASE"
}
else{
fullVersion += "-SNAPSHOT"
}

fullVersion
}
}

/*Sonarqube linting of your repository.*/
sonarqube {
properties {
property "sonar.language", "java"
}
}


/* Please don't comment out the part below
To run the same on your laptops/prod boxes/CUAT boxes, just edit the gradle.properties file.
(It will be present in the home directory of the user you are using to run gradle with.`sudo` means root user and likewise)
Enter the following lines(and yes, it will run without values, thank you gradle!)

nexusUrl=
nexusRelease=
nexusSnapshot=
nexusUsername=
nexusPassword=

*/

uploadArchives {
repositories {
mavenDeployer {
repository(url: nexusUrl+"/"+nexusRelease+"/") {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: nexusUrl+"/"+nexusSnapshot+"/"){
authentication(userName: nexusUsername, password: nexusPassword)
uniqueVersion = false
}
}
}
}






publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}

publishing {
publications {
maven(MavenPublication) {
groupId 'com.company.project'
artifactId 'project'
version '2.0.0'
from components.java
}
}
}

/*
publishing {
repositories {
maven {
url "~/.m2/repository/"
}
}
}
*/

task wrapper(type: Wrapper) {
gradleVersion = '2.9'
distributionUrl = "https://services.gradle.org/distributions/gradle-$GradleVersion-all.zip"
}

dependencies {
compile('org.projectlombok:lombok:1.16.6')
compile("com.company.commons:something:someversion")
compile group: 'com.google.guava', name: 'guava', version: '19.0'
compile("com.squareup.retrofit2:retrofit:2.0.1")
compile("com.squareup.retrofit2:converter-jackson:2.0.1")

compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
compile("com.getsentry.raven:raven-logback:7.2.2")
compile("org.springframework.boot:spring-boot-starter-actuator")

// testCompile("com.h2database:h2")
testCompile("junit:junit")
// testCompile("org.springframework.boot:spring-boot-starter-test")
// testCompile group: 'org.hibernate', name: 'hibernate-validator', version: '4.2.0.Final'
}

settings.gradle
rootProject.name = 'hello-world'

gradle.properties
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)

gradle.properties
systemProp.sonar.host.url=<url>
systemProp.sonar.login=<user>
systemProp.sonar.password=<password>
systemProp.sonar.jdbc.url=<jdbc link>
systemProp.sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
systemProp.sonar.jdbc.username=<user>
systemProp.sonar.jdbc.password=<password>
systemProp.sonar.projectName=<project name>
systemProp.sonar.sources=<path to project>
nexusUrl=<nexus url>
nexusPassword=<password>
nexusRelease=<release snapshot>
nexusSnapshot=<uat snapshot>

如果上面有任何不清楚的地方或需要任何其他信息,请告诉我。

最佳答案

看来,您忘记了应用插件本身:

apply plugin: "org.sonarqube"

我没有在您应用的插件中看到它,尽管您已将存储库和依赖项添加到您的 buildscript 配置中。

关于gradle - 找不到根项目参数的方法 sonarqube(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40786797/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com