-
Notifications
You must be signed in to change notification settings - Fork 57
Built In Tasks
In this plugin, each build command you can execute is mapped to a Gradle command. Each of these commands can be freely adjusted in the project properties.
In each of the edit boxes, you can use the following variables:
- ${project}: This will be replaced by the fully qualified name of the project on which you execute a task (except on the root project where it is an empty string). This is advantageous when you want to execute task of project and not the tasks of the subproject (for example: you write ${project}:clean as a task).
- ${platform-dir}: The path to the JDK specified in the project properties for the "Target platform".
- ${test-file-path}: The fully qualified name of the class on which you execute the task where "." characters are replaced by "/" characters. This is to support the "test.single" property in Gradle when executing a single test file. This variable is only meaningful for commands associated with a single file. This is when running, debugging or testing a single file (or method).
- ${selected-class}: The fully qualified name of the class on which you execute the task. This variable is only meaningful for commands associated with a single file. This is when running, debugging or testing a single file (or method).
- ${source-set-name}: The name of the source set containing the file against which a particular task is being run. This variable is only meaningful for commands associated with a single file. This is when running, debugging or testing a single file (or method).
-
${source-set-name-capital}: Same as ${source-set-name} but the first character is capitalized according to
Locale.ROOT
. - ${test-task-name}: The name of the source set believed to be associated with the file against which a particular task is being run. Currently, it is believed to be something similar to the name of the source set (preferably the same). The heuristic to determine the associated test task is not defined except when it is exactly the same as the name of the source set. This variable is only meaningful for commands associated with a single file. This is when running, debugging or testing a single file (or method).
-
${test-task-name-capital}: Same as ${test-task-name} but the first character is capitalized according to
Locale.ROOT
. - ${test-method}: The fully qualified name of the test method to be tested. This is available for "Run/Debug Focused Test Method".
- ${env.XXX}: The value of the given XXX environment variable. If the variable does not exist, the variable will be treated as a custom task variable. (since version 1.3.6)
Note: You may also use custom variables (since version 1.2.4).
The same inheritance rule applies to these commands as to any property of the project. Note that, I may change the factory default for these commands (of course, I will try to be reasonable). You can see the factory defaults greyed out until you change them. Note that commands are always executed as if you were executing the tasks from the directory of the selected project.
Notice that you can specify if a task is "non-blocking task". The reason to make distinctions about blocking and non-blocking tasks is purely for performance reasons. The rule about them is that if a non-blocking task is currently being executed (you can consider loading a project as a non-blocking task), other tasks will be queued and wait for this task to complete (even blocking tasks). If a currently running task is a blocking task, then subsequent task executions will simply execute concurrently with this task. To not execute tasks concurrently is important to avoid needlessly spawning new Gradle daemon processes (these processes carry out all the work for Gradle and are anything but lightweight processes) because these processes will remain for 3 hours (by default) with you if you don't kill them manually.
- Apply Code Changes: This task is executed when you click "Debug/Apply Code Changes" while debugging. After this task is executed, the classes of the currently active source file are reloaded in the running JVM.
- Build: Whenever you click build anywhere, this is the task to be executed.
- Clean: Whenever you click clean anywhere, this is the task to be executed.
- Clean and Build: Whenever you click clean and build anywhere, this is the task to be executed.
- Debug: Whenever you click debug anywhere, this is the task to be executed. Notice that the default value for this is to simply execute the "debug" task. You don't necessarily have to have a "debug" task defined in the build script because if you don't define it the plugin will add one dynamically. The dynamically added debug task will rely on the "mainClass" property, so you either have to set it in the build script "ext.mainClass=..." or define it through the arguments of the task ("-PmainClass=...").
- Debug Single: Whenever you click "Debug File" on a source file, this is the task to be executed. The notes described for the "Debug" task also apply here, but by default this task defines the "mainClass" property through the arguments. Note that if you overwrite this value in the build script, then "Debug File" will not work properly.
- Debug Test Single: Whenever you click "Debug Test File" on a source file, this is the task to be executed. The notes described for the "Debug" task also apply here but by default this task defines the "mainClass" property through the arguments (and also "-Dtest.debug"). Note that if you overwrite the "mainClass" property in the build script, then "Debug File" will not work properly.
- Debug Test Single Method: Whenever you click "Debug Focused Test Method" in a test file, this is the task to be executed. This feature needs Gradle 1.10 or higher because it relies on the "--tests" task option by default.
- Generate Javadoc: Whenever you click generate javadoc anywhere, this is the task to be executed. Note that the "java" plugin of Gradle won't automatically add a "javadoc" task, so you have to add it manually.
- Run: Whenever you click run anywhere, this is the task to be executed. Notice that the default value for this is to simply execute the "run" task. You don't necessarily have to have a "run" task defined in the build script because if you don't define it the plugin will add one dynamically. The dynamically added run task will rely on the "mainClass" property, so you either have to set it in the build script "ext.mainClass=..." or define it through the arguments of the task ("-PmainClass=...").
- Run Single: Whenever you click "Run File" on a source file, this is the task to be executed. The notes described for the "Run" task also apply here, but by default this task defines the "mainClass" property through the arguments. Note that if you overwrite this value in the build script, then "Run File" will not work properly.
- Test: Whenever you click test anywhere, this is the task to be executed. Notice that the default task executes "cleanTest" before testing. Without this Gradle would not rerun tests, it would simply report that the "test" task is "UP-TO-DATE".
- Test Single: Whenever you click "Test File" on a source file, this is the task to be executed.
- Test Single Method: Whenever you click "Run Focused Test Method" in a test file, this is the task to be executed. This feature needs Gradle 1.10 or higher because it relies on the "--tests" task option by default.