Gradle has a set of standard tasks provided by common plugins, but also allows defining custom tasks. A gradle task is an atomic unit of work that is scheduled before or other after tasks depending on task ordering constraints.
Questions tagged [gradle-task]
154 questions
1
vote
1 answer
How to Zip a folder using Android Gradle?
I am trying to zip an android source using gradle but my gradle task not doing anything. After completing the gradle sync, nothing happening, my source is not zipping.
I followed this but didn't work.
My Gradle :
apply plugin:…

Anshuman Pattnaik
- 883
- 3
- 16
- 37
1
vote
1 answer
Gradle - export property after copy task finishes
I have a build pipeline where I want to run a particular jar (with some args) after copying it into a separate folder from the dependency list.
Currently I'm doing the following:
task copyToLib(type: Copy, dependsOn: classes) {
into…

user3690467
- 3,049
- 6
- 27
- 54
1
vote
1 answer
The projectDir is invisible from the task class in Gradle script
It is an example of a build.gradle set on an empty freshly created Gradle/Groovy project on IntellJ. I use projectDir here in two places: in task definition and in task class definition. IntelliJ shows me the first use as incorrect - cannot resolve…

Gangnus
- 24,044
- 16
- 90
- 149
1
vote
1 answer
How to refresh gradle task's targets
I have a project, in which I automate build using gradle. I made a task's target in build.xml file:

banan3'14
- 3,810
- 3
- 24
- 47
1
vote
1 answer
Wrong order of task execution in gradle 3.3
I want to define methods inside my script file, and use them to define build tasks for each project individual (custom library).
ext.buildDockerImage = { imageName ->
def distDir = "${getProject().getBuildDir()}/docker"
copy {
from…

Beri
- 11,470
- 4
- 35
- 57
1
vote
1 answer
Gradle copy task, relative path
I have two gradle modules(A and B). Module B depends on module A.
Module A contains Copy task from relative path:
task copyStrings(type: Copy){
from '../path/'
into 'folder'
}
tasks.preBuild.dependsOn('copyStrings')
When I execute…

Andrii Abramov
- 10,019
- 9
- 74
- 96
1
vote
0 answers
Gradle Javadoc plugin custom task with Doclava invalid flag -link
I am adding my custom gradle task in my libraries build.gradle with Doclava implementation as:
android.libraryVariants.all { variant ->
task("generateNew${variant.name.capitalize()}Javadoc", type: Javadoc) {
title = ""
destinationDir =…

aman.nepid
- 2,864
- 8
- 40
- 48
1
vote
1 answer
Rename layout file during compilation with Gradle
My Android Studio project has two product flavors - A and B. Both have in their resource folder a layout named my_layout.xml.
I want also when I build the project for flavor A to have the layout named a_my_layout.xml and b_my_layout.xml when…

gop
- 2,150
- 5
- 26
- 54
1
vote
1 answer
Custom active-flavor-specific gradle task included in build process
Per an Android Gradle build environment:
I currently read my Version Code and Version Name from a local version.properties file via a "readVersions" gradle task. I am in the process of adding flavors to my app. These flavors would need different…

FishStix
- 4,994
- 9
- 38
- 53
0
votes
0 answers
Error with Gradle task assembleDebug failed with exit code 1
Gradle task assembleDebug failed with exit code 1
I tried to run the main.dart code but it gave me an error saying, JAVA_HOME has been set to an invalid directory: C:\Program Files\Java\jdk-19\bin

Megallen
- 1
0
votes
0 answers
Gradle Task creation option removed from Android Studio Electric Eel - | 2022.1.1 Patch 1
I have an Android Studio project in which I have plugins for Jacoco and Sonar and such for code quality.
I could run these tasks by going into the Gradle task list -> Reporting and there I could see those.
Some time ago, Android removed these task…

Dawood Ilyas
- 63
- 7
0
votes
1 answer
Continue where an interrupted task left off
I have an application for which the testing is quite extensive. Essentially, we must run the application a few hundred thousand time on different input. So I have built a custom Gradle task which manages forking processes and reaping finished…

DBear
- 312
- 2
- 9
0
votes
1 answer
How to modify error message after executing a command via a Gradle task
I'm implementing a Gradle Java plugin which registers below task.
TaskProvider taskProvider = project.getTasks().register("spectralTask", Exec.class);
taskProvider.configure(exec -> {
exec.executable("spectral");
…

Bee
- 12,251
- 11
- 46
- 73
0
votes
0 answers
How to run Apollo download schema in custom Gradle task?
I have this task
tasks{
register("my_build"){
dependsOn(build)
exec{
commandLine("apollo schema:download --endpoint=https://*************************************/graphql schema.json
")
…
0
votes
1 answer
How to: pass a closure (or Gradle Action) as an input to a custom Gradle task?
I want to pass a Gradle closure to a custom task.
@CacheableTask
abstract class FooTask : DefaultTask() {
@get:Input
abstract val input: RegularFileProperty
@get:Input
abstract val renamer: Property>
@TaskAction
…

phreed
- 1,759
- 1
- 15
- 30