Skip to content

Instantly share code, notes, and snippets.

@lifuzu
Created December 15, 2013 04:21
Show Gist options
  • Save lifuzu/7968831 to your computer and use it in GitHub Desktop.
Save lifuzu/7968831 to your computer and use it in GitHub Desktop.
Copying a file with keyword expansion
//Copying a file with keyword expansion
versionId = '1.6'
task copyProductionConfig(type: Copy) {
from 'source'
include 'config.properties'
into 'build/war/WEB-INF/config'
expand([
databaseHostname: 'db.company.com',
version: versionId,
buildNumber: (int)(Math.random() * 1000),
date: new Date()
])
}
#
# Application configuration file
#
hostname: db.company.com
appVersion: 1.6
locale: en_us
initialConnections: 10
transferThrottle: 5400
queueTimeout: 30000
buildNumber: 77
buildDate 20120105T162959-0700
#
# Application configuration file
#
hostname: ${databaseHostname}
appVersion: ${version}
locale: en_us
initialConnections: 10
transferThrottle: 5400
queueTimeout: 30000
buildNumber: ${buildNumber}
buildDate: ${date.format("yyyyMMdd'T'HHmmssZ")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment