build - How to make up-to-date check notice non-file arguments in a Gradle Task? -


suppose have task class mytask reads input file, conversion on , writes output file (build.gradle):

class mytask extends defaulttask {     @inputfile file input     @outputfile file output     string conversion      @taskaction void generate() {         def content = input.text         switch (conversion) {             case "lower":                 content = content.tolowercase()                 break;             case "upper":                 content = content.touppercase()                 break;         }         output.write content     } }  project.task(type: mytask, "mytask") {     description = "convert input output based on conversion"     input = file('input.txt')     output = file('output.txt')     conversion = "upper" } 

now works fine, when change input.txt or remove output.txt in file system executes again. problem it doesn't execute if change "upper" "lower", wrong.

i can't (don't want to) put build.gradle in inputs list because hack, wouldn't work if, say, command line argument changes gets mytask.conversion field. 1 thought of write value file in setconversion() method , put on inputs list, again, that's hack.

how can make gradle notice change official way? if know can read more this, don't hold on links ;)

i read more tasks , writing custom plugins, gave me no clue.

not sure if it's helpful i'd try:

class mytask extends defaulttask {     @inputfile file input     @outputfile file output     string conversion      @taskaction void generate() {         def content = input.text         switch (conversion) {             case "lower":                 content = content.tolowercase()                 break;             case "upper":                 content = content.touppercase()                 break;         }         output.write content     }      void setconversion(string conversion) {        this.inputs.property('conversion', conversion)        this.conversion = conversion     } } 

could please check it?


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -