Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1365

Allow override of plugin convention property with project property

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Resolution: Won't Fix
    • Affects Version/s: 0.9.2
    • Fix Version/s: None

      Description

      I am trying to understand how to set a plugin convention property from a project property.

      Here is the customPluginWithConvention example from the gradle distribution (gradle-0.9.2\samples\userguide\organizeBuildLogic\customPluginWithConvention\build.gradle)

      apply plugin: GreetingPlugin

      greeting = 'Hi from Gradle'

      class GreetingPlugin implements Plugin<Project> {
      def void apply(Project project) {
      project.convention.plugins.greet = new GreetingPluginConvention()
      project.task('hello') <<

      { println project.convention.plugins.greet.greeting }

      }
      }

      class GreetingPluginConvention {
      def String greeting = 'Hello from GreetingPlugin'
      }

      Running this script with no project property:

      >gradle hello
      :hello
      Hi from Gradle

      BUILD SUCCESSFUL

      And now trying to set a custom message via setting a project property:

      >gradle -Pgreeting=goodbye hello
      :hello
      Hello from GreetingPlugin

      Instead of the expected "goodbye" the default greeting of the convention is shown. Is it possible to override the message?

      <<Peter Niederwieser>>

      Not yet, but we should try to make it possible. Please create an issue at http://jira.codehaus.org/browse/GRADLE.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              markingram Mark Ingram
              Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: