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
5
votes
2 answers
Gradle tasks are disabled in eclipse
I'm trying to create a .jar file for my eclipse project. Through export option, I am able to create .jar, but I want to use Gradle build task to do so. Problem is that, all tasks are disabled for this particular project only, as showing in the…

User
- 4,023
- 4
- 37
- 63
5
votes
0 answers
Gradle missing dynamic task
I have a declared task:
tasks.getByName('connectedAndroidTest').finalizedBy 'archiveReports'
But when I am trying to build project it tells me that:
Caused by: org.gradle.api.UnknownTaskException: Task with name 'connectedAndroidTest' not found in…

Andrii Abramov
- 10,019
- 9
- 74
- 96
5
votes
2 answers
Gradle optional @Input
How can I provide an optional property for task?
class CustomTask extends DefaultTask {
@Input
Closure preconfig
// ...
}
This way obligates user to provide preconfig closure as parameter when defining task with CustomTask…

Andrii Abramov
- 10,019
- 9
- 74
- 96
4
votes
1 answer
How can I know which tasks are available in Gradle and when to use them?
While creating some tasks in the build.gradle of a project I found very difficult to know which type the task should be.
Is there any reference guide indicating what kind of tasks exist and when to use every one of them?
P.S.: On the link referenced…

lealceldeiro
- 14,342
- 6
- 49
- 80
4
votes
0 answers
Absolute path to Gradle buildSrc resources
On my project, I'm updating my Gradle version from 2.3 to 4.1 and I ran into an issue when getting absolute path on a resource inside a custom task.
In version 2.3, the getResource function returned the absolute path to the…

gilkal1979
- 61
- 3
3
votes
0 answers
Gradle Unexpected input: '{' When upgrade gradle from 4.2 to 7.0
I'm trying to upgrade an old project. Actually, I had to upgrade targetAPILevel to 33 from 30 which eventually requires JDK upgrade from 1.8 to 11.I could be wrong but JDK 11 requires Gradle version upgrade from 4.2 to 7. So I did upgrade Gradle to…

Faisal
- 705
- 3
- 16
3
votes
0 answers
Gradle custom task type defined in buildSrc not accessible in subprojects for multi-project structure
I have a gradle multi-project hierarchy:
root
-buildSrc
-src/main/groovy/com/CustomTask.groovy
-subproj1
-subproj1-build.gradle-settings.gradle I am able to invoke custom task - com.CustomTask only from root build.gradle file but I get - Unable to…

Xavier DSouza
- 2,861
- 7
- 29
- 40
3
votes
2 answers
Gradle task don't run in all subprojects
I have the following multi-module project structure.
Root project 'reports-be'
+--- Project ':auth'
+--- Project ':builder'
| +--- Project ':builder:base'
| \--- Project ':builder:reporting'
\--- Project ':common'
When I run build task for…

Vladimir
- 525
- 5
- 15
3
votes
1 answer
How to use custom task as artifact
I have a simple custom task in a project's (lets call it projectA) build script that creates a file. The task looks like this:
task createFile() {
def outputFile = rootProject.file("${buildDir}/tmp/outputFile.txt")
outputs.file(outputFile)
…

dpr
- 10,591
- 3
- 41
- 71
3
votes
1 answer
Gradle Copy task always UP-TO-DATE
I've seen this question posted numerous times, but I've not yet found an answer that matches my specific use case.
I'm created a bunch of config files from a template, after iterating over a config file containing environment properties.
The problem…

RCross
- 4,919
- 4
- 44
- 42
2
votes
2 answers
Cannot set environment variable or property in Gradle outside test
I have been trying to set a simple environment variable (or system property, whatever works really) through build.gradle file to access it from a java method (which is not part of integration tests) but after exhausting almost every answer on this…

scottstots
- 155
- 2
- 17
2
votes
0 answers
Using getProject() with Gradle Configuration Cache
Gradle documentation states that using the getProject() method in the @TaskAction method of a Task class should not be used if you want compatibility with Gradle Configuration Cache. The question I have is that, suppose you have something like…

Kelvin Chung
- 1,327
- 1
- 11
- 23
2
votes
1 answer
Does Gradle provide a way to add a task without including it in the build script?
I have a few custom Gradle tasks I've created perform analysis on the build, which I'll make use of when doing certain types changes (e.g. viewing changes in included dependencies as I upgrade library versions). These are tasks for my own benefit,…

M. Justin
- 14,487
- 7
- 91
- 130
2
votes
1 answer
what are equivalent of Ant , in gradle?
I am migrating ant based project to gradle project. I have to use a set of files or pattern in many tasks which makes me write duplicate code while it can be simply kept in resources and patternset tags in ant. Is there any simpler way like…

Vazid
- 713
- 1
- 6
- 19
2
votes
0 answers
How to execute method in class using Gradle task?
I want to execute Hello method in class using gradle task(at springboot). The sample is like below.
class MyClass
{
public void Hello()
{
System.out.println("Hello World");
}
}
Is there any way to execute Hello function in…

Wien 1683
- 65
- 6