This article is very simple, that is, the following Gradle script back to the prototype:
Version = 1.0
Groovy Syntax sugar
Java programmers are certainly not unfamiliar with JavaBeans and getter/setter methods, so they don't introduce much. Although modern Ides provide shortcuts that make it easy to generate getter and setter methods for fields, I still hate them. Fortunately, there is groovy grammar sugar in hand, you can say goodbye to the Getter/setter Method! The above script is actually the Setversion method that calls the project interface:
Project.setversion (1.0)
The project interface also defines the GetVersion method, so we can get the version information of the item in the following way:
println project.version//Groovyprintln (Project.getversion ())//Java
Set task properties
Then look at the following script:
Task HelloWorld { group = ' MyTasks ' description = ' Prints Hello World ' . dolast { println ' Hello world! ' }}
Well, the point is that the task
Configuring Closures, we can
Implicitof the control task.
GroupAnd
Description, just the two properties of the task:
public void Setgroup (string group) public string Getgroup () public void stdescription (string description) public string get Description ()
Conclusion
Gradle's domain objects , most of which provide a lot of properties (i.e. getter and setter), in the build script, we can easily set and access these properties.