Thursday, March 1, 2018

Gradle





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.NameTypeDefault Value
1projectProjectThe Project instance
2nameStringThe name of the project directory.
3pathStringThe absolute path of the project.
4descriptionStringA description for the project.
5projectDirFileThe directory containing the build script.
6buildDirFileprojectDir/build
7groupObjectUnspecified
8versionObjectUnspecified
9antAntBuilderAn 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