Parameterizing tasks with @Option in org.gradle.tooling.GradleConnector

Hi to all,

I want to use GradleConnector to execute an integration test. Also I have tasks, which are using the cool command line parameter api (org.gradle.api.internal.tasks.options.Option), e.g.

@Option(option=‘host’, description=‘host to be configured’)

public void setHost(String host) { … }

I tried to use BuildLauncher#withArguments() to parameterize those tasks, but that didn’t work. I am only getting a CommandLineArgumentException: Unknown command-line option ‘–host’

Is it possible to use both concepts together?

Cheers Markus

As always I want to make clear that you’re using an internal feature here, but I told you about the risks before :wink:

which version of gradle are you using? we have a dedicated test where we do something similar for testing test name filtering. see

Hi Rene,

Yes I know - but like and need this features very much and never had a problem with it. Looking forward to getting it as official one :slight_smile:

Thank you for your example. This use case works for me, as well - normal – parameters - but the ones which come to build with @Option didn’t work for me this way.

I was running the test with gradle 2.0 as well as with 2.1

Are these options not supported in GradleConnector in the end?

Cheers Markus

Hey Markus,

I just created a small testcase and this works for me with gradle 2.1. You can find my testcase at
Is there any chance of a typo causing this problem?

Hi Rene,

thank you a lot for your example. I have rewritten my test with spock and it’s working,

Cheers Markus