Writing Build Scripts
1 Accessing property of the Project object
println name
println project.name
2 Standard project properties
| Name |
Type |
Default Value |
| project |
Project |
The Project instance |
| name |
String |
The name of the project directory. |
| path |
String |
The absolute path of the project. |
| description |
String |
A description for the project. |
| projectDir |
File |
The directory containing the build script. |
| buildDir |
File |
projectDir/build |
| group |
Object |
unspecified |
| version |
Object |
unspecified |
| ant |
AntBuilder |
An AntBuilder instance |
3 Using local variables
def dest = "dest"
task copy(type: Copy) {
from "source"
into dest
}
apply plugin: "java"
ext {
springVersion = "3.1.0.RELEASE"
emailNotification = "[email protected]"
}
sourceSets.all { ext.purpose = null }
sourceSets {
main {
purpose = "production"
}
test {
purpose = "test"
}
plugin {
purpose = "production"
}
}
task printProperties {
doLast {
println springVersion
println emailNotification
sourceSets.matching { it.purpose == "production" }.each { println it.name }
}
}