Passing system properties from JavaExec task doesn't seem to work


(Roger Hoover) #1

Noob here. Sorry for “simple” question. I appreciate any help.

I’m trying to set a system property called “metadata.broker.list” on a JavaExec task.

task(producer, dependsOn: 'classes', type: JavaExec) {
  main = 'com.foo.kafka_test.ExampleProducerClient'
  classpath = sourceSets.main.runtimeClasspath
  standardInput = System.in
  systemProperties = [
    'metadata.broker.list': '13.4.44.16:9092'
  ]
}

When I run the task, it seems that it’s not set

$ gradle -d -q producer < ../hadoop/src/main/resources/occupancy.json
 Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: Missing required property 'metadata.broker.list'
 at scala.Predef$.require(Predef.scala:145)
 at kafka.utils.VerifiableProperties.getString(VerifiableProperties.scala:158)
 at kafka.producer.ProducerConfig.<init>(ProducerConfig.scala:66)
 at kafka.producer.ProducerConfig.<init>(ProducerConfig.scala:56)
 at com.foo.kafka_test.ExampleProducer.<init>(ExampleProducer.java:18)
 at com.foo.kafka_test.ExampleProducerClient.main(ExampleProducerClient.java:11)
   FAILURE: Build failed with an exception.

Gradle 1.8 Groovy:

1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.6.0_65 (Apple Inc. 20.65-b04-462) OS:

Mac OS X 10.8.5 x86_64


(Peter Niederwieser) #2

Are you sure it’s complaining about a missing system property?


(Roger Hoover) #3

You’re right. The Kafka client was not looking for system properties but instead a custom set of properties. Thanks for your help.