Search code examples
gradlejettygretty

pass in gretty options on the command line


Does anybody know if there is an easy way to override the gretty, or any gradle configuration on the command line?

(the ones here: http://akhikhl.github.io/gretty-doc/Gretty-configuration.html)

I have tried this

gradle -Dgretty.httpPort=8111 :web:jettyRun

but it still runs on port 8080.


Solution

  • You can configure it like below,

    gretty {
       if(project.hasProperty('portNumber')){ // if variable passed use it
           httpPort=Integer.parseInt(portNumber)
       }
       else{ // if it is not passed use a default port
          httpPort=8080
       }
    ...
    }
    

    And when you want to use a specific port gradle ... -PportNumber=8111