Build Tools · interview question
In Gradle, how can you configure a task to execute only if another task has been executed without failure?
Multiple choiceHardchapter-10-curatedpremiumbuild-toolsbuild-lifecycle
Answer and explanation
Correct answer
D. Use onlyIf predicate
Why
The 'onlyIf' predicate in Gradle allows you to specify conditions under which a task should execute. It ensures that a task only runs if a specified condition is met, such as the successful completion of another task.
Test yourself on Build Tools
A free test with instant, explained results. No account needed.
More Build Tools questions
- In a Maven project, where do you declare a dependency for a new library you want to use?
- Which Maven command would you use to ensure that the project is cleaned and rebuilt, including tests?
- When using Maven, which phase is responsible for verifying the quality of the code by running integration tests?
- In a Maven project, how are dependencies typically fetched?
- How does Maven resolve dependencies that are not present in the local repository?
- Which of the following is a primary benefit of using Gradle over Ant for building Java projects?