Custom plugin/task with properties

Hi,

I created a plugin which does some rest calls to a a rabbitmq management api. However I can’t seem to pass any properties into the plugin.

This is my gradle.properties

# properties for cleaning rabbitmq
rabbitmq_mgmt_baseUrl=http://localhost:7070/api
rabbitmq_mgmt_userName=guest
rabbitmq_mgmt_password=guest

My build.gradle looks like this:

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }
  dependencies {
    classpath("my.gradle:rabbitmq-upgrade-gradle:DEVEL")
  }
}

apply plugin: 'java'
apply plugin: 'my.gradle.rabbitmq'

rabbitMQUpgrade {
  baseUrl project.ext.rabbitmq_mgmt_baseUrl
  userName project.ext.rabbitmq_mgmt_userName
  password project.ext.rabbitmq_mgmt_password
  prefixOfQueuesToRemove = 'x.'
  prefixOfExchangesToRemove = 'x.'
  exchangesToCreate = [
          new gradle.rabbitmq.model.Exchange('exchange1', 'fanout', '%2F'), 
          new gradle.rabbitmq.model.Exchange('exchange2', 'fanoet', '%2F')
  ]
}

However, I get the following error when running the task defined by the plugin:

domeniquet@domeniquet-desktop:~/test: » gradle cleanRabbitMQ
:cleanRabbitMQ FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cleanRabbitMQ'.
> Unable to determine the current character, it is not a string, number, array, or object
  The current character read is 'N' with an int value of 78
  Unable to determine the current character, it is not a string, number, array, or object
  line number 1
  index number 0
  Not found.
  ^
* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
Total time: 5.827 secs
domeniquet@domeniquet-desktop:~/test: »

When not using properties, the task runs just fine.

Does anyone have any idea ?

Properties added via a gradle.properties file aren’t added to the extra properties extension, which means they aren’t part of the ext object. Just use project.rabbitmq_mgmt_baseUrl.

doing the proposed change still does the same. so project.rabbitmq_mgmt_baseUrl does not fix it either. I can println that var though an it outputs the value from the gradle file.

You might want to try using the --stacktrace option to debug this. I anticipate the error is originating from somewhere in the rabbitmq managment plugin.