How do I set task properties in a Gradle Plugin
-
I am creating a gradle plugin to apply the sonar-runner plugin and default many of the values such as the sonar host URL and the sonar JDBC URL. I cannot figure out how to set the properties though. When I set this up in build.gradle I use: apply plugin: 'sonar-runner' sonarRunner { sonarProperties { property 'sonar.host.url', 'http://mySonar.company.com' property 'sonar.jdbc.url', 'jdbc:mysql://127.0.0.1:1234/sonar' } } My gradle plugin looks like: class MySonarPlugin implements Plugin<Project> { @Override void apply(Project project) { project.apply plugin: 'sonar-runner' project.configurations { sonarRunner { sonarProperties { property 'sonar.host.url', 'http://mySonar.company.com' property 'sonar.jdbc.url', 'jdbc:mysql://127.0.0.1:1234/sonar' } } } } } With this setup I get a No signature of method exception. How should I be setting these properties?
-
Answer:
I discovered that I could use project.getExtensions().sonarRunner.sonarProperties{ ... } to set the sonar properties. See example below. class MySonarPlugin implements Plugin<Project> { @Override void apply(Project project) { project.apply plugin:'sonar-runner' project.getExtensions().sonarRunner.sonarProperties { property 'sonar.host.url', 'http://mySonar.company.com' property 'sonar.jdbc.url', 'jdbc:mysql://127.0.0.1:1234/sonar' } } }
Mike Rylander at Stack Overflow Visit the source
Other answers
It should be: class MySonarPlugin implements Plugin<Project> { @Override void apply(Project project) { project.apply plugin: 'sonar-runner' project.sonnarRunner { sonarProperties { property 'sonar.host.url', 'http://mySonar.company.com' property 'sonar.jdbc.url', 'jdbc:mysql://127.0.0.1:1234/sonar' } } } } configurations is something completely different.
Opal
Related Q & A:
- How do I set a Gtk.StatusIcon as Text?Best solution by stackoverflow.com
- How do I set the first and last frame of a video to be an image?Best solution by stackoverflow.com
- How do I set my e-mail to alert me when I get a new message?Best solution by Yahoo! Answers
- How do I set a video as a picture?Best solution by Yahoo! Answers
- How do I set up Yahoo for a new computer?Best solution by dell.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.