title: Gradle / Groovy properties
body: <p>I would like to control 'global' config in Gradle build scripts using external property files on each build machine (dev, ci, uat,...) and specify the filename with a command line argument.</p>
  
  <p>e.g. <code>gradle -DbuildProperties=/example/config/build.properties</code> </p>
  
  <p>I specifically don't want to use gradle.properties as we have existing projects that already use this approach and (for example) we want to be able to amend database urls and jdbc drivers without having to change every project.</p>
  
  <p>So far have tried:-</p>
  
  <pre><code>Properties props = new Properties() 
  props.load(new FileInputStream("$filename")) 
  project.setProperty('props', props) 
  </code></pre>
  
  <p>which works but has a deprecated warning, but I can't figure out how to avoid this.</p>
  
  <p>Have also tried using groovy style config files with ConfigSlurper:-</p>
  
  <pre><code>environments {
      dev {
          db.security {
              driver=net.sourceforge.jtds.jdbc.Driver
              url=jdbc:someserver://somehost:1234/some_db
              username=userId
              password=secret
          }
      }
  }
  </code></pre>
  
  <p>but the colons and forward slashes are causing exceptions and we don't want to have to mess up config with escape characters.</p>
  
  <p>There must be a non-deprecated way to do this - can anyone suggest the 'right' way to do it?</p>
  
  <p>Thanks</p>