Debug School

rakesh kumar
rakesh kumar

Posted on

Gradle Question

What are the parts of the task lifecycle?
If I want to run a java application which plugin do I use?
What does the wrapper task do?
What is the syntax for filtering tests in gradle?
What does taskA.finalizedBy taskB do?
When you taskA.mustRunAfter taskB
When you call doLast on a task twice passing different closures what happens?
How do you add the java plugin?
When copying files you can use which method to replace text?
Which of the following is valid gradle syntax to add a compile dependency on junit?
What is the syntax for defining a repository in Gradle?
In a multi project build which two files do I need to add to the top level project?
How do you declare a task?
If you use the gradle-testsets-plugin how do you add an integrationTest sourceset in gradle?
When you use the << syntax which method on the task is executed?
How do I tell the plugin where my Java files are if I don’t follow the Gradle convention?
How do you declare a typed task?

SUBJETIVE QUESTION

** What is Gradle build tool?**
Is Gradle a framework?
What is DSL in Gradle?
What is closure in Gradle?
What is assemble in Gradle?
Is Gradle only for Java?
What is EXT in build gradle?
What is apply from in Gradle?
Does Gradle use Groovy?
How can you run Gradle build?

What are the parts of the task lifecycle?

A. Configuration, Execution
B. Initialization, Configuration, Execution
C. Initialization, Configuration, Execution, Finalization
D. Execution

Ans: B. Initialization, Configuration, Execution

If I want to run a java application which plugin do I use?

A. java
B. run
C. application
D. java-runner

Ans: C. application

What does the wrapper task do?

A. Ensures that all developers use the same version of Gradle to build the code
B. Wraps up the code so that any exceptions are caught
C. Wraps gradle so it can be used from an IDE such as Eclipse
D. Installs an extra set of Java tasks to make testing easier

Ans: A. Ensures that all developers use the same version of Gradle to build the code

What is the syntax for filtering tests in gradle?

A. add a test { filter {} } closure
B. you have to run all the tests, you cannot filter
C. add the test-filter plugin
D. build only the tests you want to run

Ans: A. add a test { filter {} } closure

What does taskA.finalizedBy taskB do?

A. Causes taskB to run before taskA
B. Causes taskA and taskB to run in parallel
C. Nothing, this is not yet available in Gradle
D. Causes taskB to run after taskA

Ans: D. Causes taskB to run after taskA

When you taskA.mustRunAfter taskB

A. When you taskA.mustRunAfter taskB
B. taskA runs after taskB only if both tasks are scheduled to run
C. taskB always runs after

Ans: B. taskA runs after taskB only if both tasks are scheduled to run

When you call doLast on a task twice passing different closures what happens?

A. Only the first closure is executed
B. Only the last closure is executed
C. Neither closure is executed, it is an error
D. Both closures are executed

Ans: D. Both closures are executed

How do you add the java plugin?

A. Do nothing. The plugin is always enabled
B. apply java plugin
C. java ‘plugin’
D. apply plugin ‘java’

Ans: D. apply plugin ‘java’

When copying files you can use which method to replace text?

A. expand
B. replace
C. regex
D. insert

Ans: A. expand

Which of the following is valid gradle syntax to add a compile dependency on junit?

A. compile name=junit version=4.1.2
B. compile ‘junit:4.12’
C. compile ‘junit:version:4.1.12’
D. compile ‘junit:junit:4.1.12’

Ans: D. compile ‘junit:junit:4.1.12’

What is the syntax for defining a repository in Gradle?

A. use jcenter()
B. repositories: jcenter()
C. repository: jcenter()
D. repositories { jcenter() }

Ans: D. repositories { jcenter() }

In a multi project build which two files do I need to add to the top level project?

A. build.gradle and build.settings
B. multi.gradle and settings.gradle
C. build.gradle and settings.properties
D. build.gradle and settings.gradle

Ans: D. build.gradle and settings.gradle

How do you declare a task?

A. Task.withName taskName
B. Task taskName
C. Task: taskName
D. taskName: Task

Ans: B. Task taskName

If you use the gradle-testsets-plugin how do you add an integrationTest sourceset in gradle?

A. testSets { integrationTest { dirName=’myDir’ } }
B. testSets { dirName=’myDir’}
C. testSets { integrationTest = ‘myDir’ }
D. integrationTest { dirName=’myDir’}

Ans: A. testSets { integrationTest { dirName=’myDir’ } }

When you use the << syntax which method on the task is executed?

A. last
B. first
C. doFirst
D. doLast

Ans: D. doLast

How do I tell the plugin where my Java files are if I don’t follow the Gradle convention?

A. use a sources closure
B. set a source property in the gradle build file
C. use a sourceSets closure
D. set a source property on the command line of the gradle build tool

Ans: C. use a sourceSets closure

How do you declare a typed task?

A. task copyImages (type: Copy)
B. task copyImages (type: Copy)
C. Copy copyImages

Ans: A. task copyImages (type: Copy)

What is Gradle build tool?

Gradle is a build automation tool based on Groovy and Kotlin. It’s open-source and flexible enough to build almost any type of software. It also supports both the automatic download of dependencies and many repositories, including Maven and Ivy.

Is Gradle a framework?

Gradle is a build automation tool for multi-language software development. … Gradle builds on the concepts of Apache Ant and Apache Maven, and introduces a Groovy- & Kotlin-based domain-specific language contrasted with the XML-based project configuration used by Maven.

What is DSL in Gradle?

Simply, it stands for ‘Domain-Specific Language’. IMO, in Gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it’s a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

What is closure in Gradle?

Note in Gradle DSL, closures are frequently (and idiomatically) used as the last method parameter to configure some object. This is a pattern called configuration closure. … Gradle uses this for configuration closures, where the delegate object is set to the object to be configured.

What is assemble in Gradle?

Assemble will build your artifacts, and build will assemble your artifacts with additional checks. Build depends on assemble, so build is sort of a superset of assemble. You can have a look on the tasks that will be executed by using the –dry-run flag. e.g. gradlew build –dry-run.

Is Gradle only for Java?

Gradle runs on the JVM and you must have a Java Development Kit (JDK) installed to use it. … Several major IDEs allow you to import Gradle builds and interact with them: Android Studio, IntelliJ IDEA, Eclipse, and NetBeans.

What is EXT in build gradle?

ext is shorthand for project. ext , and is used to define extra properties for the project object. (It’s also possible to define extra properties for many other objects.) When reading an extra property, the ext. is omitted (e.g. println project.

What is apply from in Gradle?

The actual difference between apply from: and apply plugin: is that the former is to be used for script plugins given a path to the local file system or a URL to a remote location, and the latter is used for binary plugins using the plugin id.

Does Gradle use Groovy?

Gradle is a Groovy script. Thus it can execute arbitrary code and access any Java library, build-specific Gradle DSL, and the Gradle API.

How can you run Gradle build?

The Gradle command will run Gradle on the Gradle build script located in the same directory as the command prompt is located in. That means, that to run Gradle on a specific gradle build script you must change the directory in the command prompt into the directory where the build script is located.

Top comments (0)