Saturday 7 April 2018

Executing tasks

Executing tasks

You can run a task and all of its dependencies.
❯ gradle myTask
You can learn about what projects and tasks are available in the project reporting section.

Executing tasks in multi-project builds

In a multi-project build, subproject tasks can be executed with ":" separating subproject name and task name. The following are equivalent when run from the root project.
❯ gradle :mySubproject:taskName
❯ gradle mySubproject:taskName
You can also run a task for all subprojects using the task name only. For example, this will run the "test" task for all subprojects when invoked from the root project directory.
❯ gradle test
When invoking Gradle from within a subproject, the project name should be omitted:
❯ cd mySubproject
❯ gradle taskName
When executing the Gradle Wrapper from subprojects, one must reference gradlew relatively. For example: ../gradlew taskName. The community gdub project aims to make this more convenient.

Executing multiple tasks

You can also specify multiple tasks. For example, the following will execute the test and deploy tasks in the order that they are listed on the command-line and will also execute the dependencies for each task.
❯ gradle test deploy

Excluding tasks from execution

You can exclude a task from being executed using the -x or --exclude-task command-line option and providing the name of the task to exclude.
Figure: Example Task Graph
Example Task Graph
Example: Excluding tasks
Output of gradle dist --exclude-task test
> gradle dist --exclude-task test
:compile
compiling source
:dist
building the distribution

BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed
You can see that the test task is not executed, even though it is a dependency of the dist task. The test task’s dependencies such as compileTest are not executed either. Those dependencies of test that are required by another task, such as compile, are still executed.

Forcing tasks to execute

You can force Gradle to execute all tasks ignoring up-to-date checks using the --rerun-tasks option:
❯ gradle test --rerun-tasks
This will force test and all task dependencies of test to execute. It’s a little like running gradle clean test, but without the build’s generated output being deleted.

Continuing the build when a failure occurs

By default, Gradle will abort execution and fail the build as soon as any task fails. This allows the build to complete sooner, but hides other failures that would have occurred. In order to discover as many failures as possible in a single build execution, you can use the --continue option.
❯ gradle test --continue
When executed with --continue, Gradle will execute every task to be executed where all of the dependencies for that task completed without failure, instead of stopping as soon as the first failure is encountered. Each of the encountered failures will be reported at the end of the build.
If a task fails, any subsequent tasks that were depending on it will not be executed. For example, tests will not run if there is a compilation failure in the code under test; because the test task will depend on the compilation task (either directly or indirectly).

Task name abbreviation

When you specify tasks on the command-line, you don’t have to provide the full name of the task. You only need to provide enough of the task name to uniquely identify the task. For example, it’s likely gradle che is enough for Gradle to identify the check task.
You can also abbreviate each word in a camel case task name. For example, you can execute task compileTest by running gradle compTest or even gradle cT.
Example: Abbreviated camel case task name
Output of gradle cT
> gradle cT
:compile
compiling source
:compileTest
compiling unit tests

BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed
Convert string to date java. Convert date to string java. Convert ascii to string java. Convert float to string java. Convert string to arraylist java. StringBuffer in java. append(String str) StringBuffer method in java. insert(int offset, String str) StringBuffer method in java. replace(int startIndex, int endIndex, String str) StringBuffer. delete(int startIndex, int endIndex) StringBuffer method in java. reverse() StringBuffer method in java. capacity() StringBuffer method in java. ensureCapacity(int minCapacity) StringBuffer method. StringTokenizer in java. StringBuilder in java. append(String str) StringBuilder method in java. insert(int offset, String str) StringBuilder method in java. replace(int startIndex, int endIndex, String str) StringBuilder method. delete(int startIndex, int endIndex) StringBuilder method in java.
reverse() StringBuilder method in java. capacity() StringBuilder method in java. ensureCapacity(int minCapacity) StringBuilder method in java. StringTokenizer in java. Some important terms for Exception Handling. Exception handling in java. try and catch blocks in java with example. Multiple catch blocks in java with example. Nested try block in java with example. Finally in java with example. throw in java with example. throws in java with example. Exception propagation in java with example. Exception handling with method overriding in java. Custom exception in java with example. Commonly used exception methods of Throwable class in java. Multithreading in java. Thread life cycle in java. Way of creating thread in java. Commonly used methods of Thread class. Thread scheduling in java with example. Thread priority in java with example. Naming a thread in java with example. Joining a thread in java with example. Daemon thread in java with example. Can we start a thread twice? Can we call run method directly? Difference between Thread.yield() and Thread.sleep() methods. Deadlock in java with example. Starvation in java with example. Inter-thread communication in java with example. Synchronization in java with example. Synchronized method in java with example. Static synchronization in java with example. Synchronized block in java with example. Collection framework in java. Collection interfaces in java. Collection interface in java with example. Set interface in java with example. SortedSet interface in java with example. List interface in java with example. Map interface in java with example. Daemon thread in java in java with example. SortedMap interface in java with example. Queue interface in java with example. Deque interface in java with example. Enumeration interface in java with example. Collection classes in java with example. HashSet in java with example. LinkedHashSet in java with example. TreeSet in java with example. ArrayList in java with example. LinkedList in java with example. HashMap in java with example. LinkedHashMap in java with example. TreeMap in java with example. PriorityQueue in java with example. ArrayDeque in java with example. Abstract classes in collection framework in java with example. Sorting in java with example. Comparable interface in java with example. Comparator interface in java with example. Properties class in java with example. Hashtable in java with example. ListIterator interface in java with example. Java annotations. Java annotations overview. Built-in Java Annotations. @Deprecated Java Annotation. Override Java Annotation. SuppressWarnings java annotation. Java custom annotation. JSP overview. JSP lifecycle phases. JSP Hello World Example. JSP Scriptlet tag with example. JSP Declaration tag with example. JSP Expression tag with example. JSP comment tag with example. JSP directives with example. import attribute of JSP page directive with example.
You can also use these abbreviations with the -x command-line option.

No comments:

Post a Comment