Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method sonarqube() for arguments on root project

I am getting the below error when executing the following command

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>

Please let me know if anything is not clear from above or anyother information is needed.

like image 757
Munai Das Udasin Avatar asked Nov 24 '16 12:11

Munai Das Udasin


1 Answers

It seems, that you've forgot to apply the plugin itself with:

apply plugin: "org.sonarqube"

I don't see it within your applied plugins, though you've added repository and dependencies to your buildscript configuration.

like image 100
Stanislav Avatar answered Oct 03 '22 21:10

Stanislav