Command line options in gradle task (with dependsOn)

(Thomas B) #1


I developed my gradle plugin which provides one task (myTask1) with one option ‘platform’. The task i called by the following syntax :
./gradlew myTask1 --platform=MyPlatform

But now I want to plug with other tasks ( myTask2 dependsOn myTask1 ).
The previous syntax doesn’t work : ./gradlew myTask2 --platform=MyPlatform. I got this error : Unknown command-line option ‘–platform’.

Do you know a workaround for this error or only -Dplatform=MyPlatform works to get parameter tasks into tasks ?

Thank you


(Sterling Greene) #2

Yes, that’s a known issue (options need to follow the task that understands them).

The other way to do this is to not use a single task + parameters, but separate tasks. This is better in many ways (discoverability, usability, correctness) if the options are known up front.

So you’d have myTask1MyPlatform, myTask1YourPlatform, myTask1TheirPlatform, etc.

(Thomas B) #3

I did not find the answer. I will change my code as necessary then.

Thank you :slight_smile: