build.gradle
Gradle builds a script file for handling two things; one is projects and another one is tasks.
task hello { doLast { println 'tutorialspoint' } } C:\> gradle –q hello
The Gradle script mainly uses two real Objects;
- Project Object
- Script Object.
Project Object − Each script describes about one or multiple projects. While in the execution, this script configures the Project Object. You can call some methods and use property in your build script which are delegated to the Project Object.
Script Object − Gradle takes script code into classes, which implements Script Interface and then executes. This means that of all the properties and methods declared by the script interface are available in your script.
Sr. No. | Name | Type | Default Value |
---|---|---|---|
1 | project | Project | The Project instance |
2 | name | String | The name of the project directory. |
3 | path | String | The absolute path of the project. |
4 | description | String | A description for the project. |
5 | projectDir | File | The directory containing the build script. |
6 | buildDir | File | projectDir/build |
7 | group | Object | Unspecified |
8 | version | Object | Unspecified |
9 | ant | AntBuilder | An AntBuilder instance |
If you think task works similar to ANT’s target, then that’s right - Gradle task is equivalent to ANT target.
task hello << { println 'tutorialspoint' }
task upper << { String expString = 'TUTORIALS point' println "Original: " + expString println "Upper case: " + expString.toUpperCase()}
C:\> gradle –q upper
Gradle build script describes one or more Projects.
Each project is made up of different tasks.
A task is a piece of work which a build performs.
The task might be compiling
- some classes,
- storing class files into separate target folder,
- creating JAR,
- generating Javadoc,
- or publishing some archives to repositories.
No comments:
Post a Comment