slashms
slashms

Reputation: 978

Passing property to Gradle Tooling API ProjectConnection

I am using gradle tooling api and I encountered the following scenario. There is a project that applies a certain plugin P which creates a task T only if the property shouldApplyP is passed.

Hence, if you will run ./gradlew tasks --all you won't see task T, but if you will run ./gradlew -PshouldApplyP tasks --all you will see task T.

In gradle tooling api, once a ProjectConnection has created I can do connection.getModel(GradleProject.class).getTasks()

But I can't see this specific task. Is there a way to pass the project connection this property -PshouldApplyP so it will be presented in the getTasks() method?

Upvotes: 0

Views: 246

Answers (1)

Abhijit Sarkar
Abhijit Sarkar

Reputation: 24593

connection.newBuild()
    .withArguments("-PshouldApplyP", "tasks --all")
    .run()

Upvotes: 1

Related Questions