Gradle

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
To raise new issues or bugs against Gradle, please use forums.gradle.org.
  • Gradle
  • GRADLE-1813

Sonar fails on nested multiproject builds

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Resolution: Not A Bug
  • Affects Version/s: 1.0-milestone-5
  • Fix Version/s: 1.0-milestone-8

Description

When applying the sonar plugin to the gradle sample project (subprojects/docs/samples/java/multiproject) the build fails with the message:
There's an extension registered with name 'sonar'. You should not reassign it via a property setter.

It seems that applying the Plugin to (:services:shared) fails because the plugin was already applied to (:shared). INMHO, the full qualified project name is not considered. Find the full stack trace below:

org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'multiproject'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:474)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:73)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:450)
at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:445)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:138)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:109)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:77)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:231)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:215)
at org.gradle.launcher.Main.execute(Main.java:57)
at org.gradle.launcher.Main.main(Main.java:42)
Caused by: java.lang.IllegalArgumentException: There's an extension registered with name 'sonar'. You should not reassign it via a property setter.
at org.gradle.api.internal.plugins.ExtensionsStorage.checkExtensionIsNotReassigned(ExtensionsStorage.java:49)
at org.gradle.api.internal.plugins.DefaultConvention.propertyMissing(DefaultConvention.java:95)
at org.gradle.api.plugins.sonar.SonarPlugin.configureSonarRootModel(SonarPlugin.groovy:54)
at org.gradle.api.plugins.sonar.SonarPlugin.this$2$configureSonarRootModel(SonarPlugin.groovy)
at org.gradle.api.plugins.sonar.SonarPlugin$this$2$configureSonarRootModel.callCurrent(Unknown Source)
at org.gradle.api.plugins.sonar.SonarPlugin.apply(SonarPlugin.groovy:42)
at org.gradle.api.plugins.sonar.SonarPlugin.apply(SonarPlugin.groovy)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.providePlugin(DefaultProjectsPluginContainer.java:107)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.addPluginInternal(DefaultProjectsPluginContainer.java:71)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:841)
at build_5cq9j6nrhfkicsrn91fucm243h$_run_closure1.doCall(/Users/Rene/temp/multiproject/build.gradle:4)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:112)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:861)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:866)
at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractProject.java:849)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
at org.gradle.api.internal.project.DefaultProject_Decorated.invokeMethod(Unknown Source)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.groovy:72)
at build_5cq9j6nrhfkicsrn91fucm243h.run(/Users/Rene/temp/multiproject/build.gradle:2)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 23 more

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
  • TeamCity
  • Commits
  • Source
  • Reviews
Hide
Permalink
Rob Kirkbride added a comment - 09/Oct/11 10:11 AM

I've hit this as well in milestone 5 nightly. Unless there's a workaround, it's a show stopper for us moving to milestone 5.

Show
Rob Kirkbride added a comment - 09/Oct/11 10:11 AM I've hit this as well in milestone 5 nightly. Unless there's a workaround, it's a show stopper for us moving to milestone 5.
Hide
Permalink
René Gröschke added a comment - 17/Oct/11 2:18 PM

With the latest snapshot I've found a convenient 'workaround' for this.
You can apply the sonar plugin to the root project. Running "sonarAnalyze" task on your multi project build considers now all related submodules.

It should be well documented, that the sonar plugin for multi projects shall be applied to the root project only. Maybe I find the time to create a pull request for this. IMHO there are be two ways to solve issue:
1. Provide the "old" sonar behaviour for sonar plugins applied to sub projects. This means considering each submodule as a separate project in sonar.
2. Refactor the error message mentioned above, as this message is not very helpful for fixing this issue.

regards,
Rene

Show
René Gröschke added a comment - 17/Oct/11 2:18 PM With the latest snapshot I've found a convenient 'workaround' for this. You can apply the sonar plugin to the root project. Running "sonarAnalyze" task on your multi project build considers now all related submodules. It should be well documented, that the sonar plugin for multi projects shall be applied to the root project only. Maybe I find the time to create a pull request for this. IMHO there are be two ways to solve issue: 1. Provide the "old" sonar behaviour for sonar plugins applied to sub projects. This means considering each submodule as a separate project in sonar. 2. Refactor the error message mentioned above, as this message is not very helpful for fixing this issue. regards, Rene
Hide
Permalink
Gunnar Hillert added a comment - 10/Jan/12 2:43 PM

In my opinion both use-cases should be possible. Usually I do want to run Sonar globally from the Root project as part of a nightly build. However, throughout the day I may run the Sonar task locally to get a report for a sub-module without have to through the pain of running the entire build.

This has been working fine in Maven based builds and should also be supported by Gradle.

Show
Gunnar Hillert added a comment - 10/Jan/12 2:43 PM In my opinion both use-cases should be possible. Usually I do want to run Sonar globally from the Root project as part of a nightly build. However, throughout the day I may run the Sonar task locally to get a report for a sub-module without have to through the pain of running the entire build. This has been working fine in Maven based builds and should also be supported by Gradle.
Hide
Permalink
Peter Niederwieser added a comment - 13/Jan/12 9:46 AM - edited

It's already supported. If you apply the plugin to the root project, you can analyze just a subproject. What you cannot do is apply the plugin both to a parent and a child project. The plugin is not supposed to be used like that.

Show
Peter Niederwieser added a comment - 13/Jan/12 9:46 AM - edited It's already supported. If you apply the plugin to the root project, you can analyze just a subproject. What you cannot do is apply the plugin both to a parent and a child project. The plugin is not supposed to be used like that.
Hide
Permalink
Peter Niederwieser added a comment - 13/Jan/12 9:53 AM

Apparently I was wrong about this. Seems there is no easy way to have both things. If you want this, please create a feature request. It's not something that's easy to implement though.

Show
Peter Niederwieser added a comment - 13/Jan/12 9:53 AM Apparently I was wrong about this. Seems there is no easy way to have both things. If you want this, please create a feature request. It's not something that's easy to implement though.
Hide
Permalink
Peter Niederwieser added a comment - 13/Jan/12 2:56 PM

What you can do is to apply the plugin to each leaf project. This is how the first version of the plugin worked. Drawbacks are that you get no accumulated view in the Sonar web interface and that analysis takes longer and requires more memory.

Show
Peter Niederwieser added a comment - 13/Jan/12 2:56 PM What you can do is to apply the plugin to each leaf project. This is how the first version of the plugin worked. Drawbacks are that you get no accumulated view in the Sonar web interface and that analysis takes longer and requires more memory.
Hide
Permalink
Peter Niederwieser added a comment - 13/Jan/12 2:58 PM

Works as designed. I'll add some clarifying words to the user guide.

Show
Peter Niederwieser added a comment - 13/Jan/12 2:58 PM Works as designed. I'll add some clarifying words to the user guide.

People

  • Assignee:
    Unassigned
    Reporter:
    René Gröschke
Vote (2)
Watch (1)

Dates

  • Created:
    28/Sep/11 12:54 AM
    Updated:
    04/Jan/13 5:09 AM
    Resolved:
    13/Jan/12 2:58 PM
  • Atlassian JIRA (v5.0.3#729-sha1:bf569e4)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Gradle. Try JIRA - bug tracking software for your team.