Questions tagged [gradle-task]

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.

154 questions
118
votes
10 answers

How to pass arguments from command line to Gradle

I'm trying to pass an argument from command line to a Java class. I followed this post: http://gradle.1045684.n5.nabble.com/Gradle-application-plugin-question-td5539555.html but the code does not work for me (perhaps it is not meant for JavaExec?).…
Lidia
  • 2,005
  • 5
  • 25
  • 32
83
votes
1 answer

Difference between test and check tasks in Gradle

My build.gradle is as follows: group 'groupName' version 'version' apply plugin: 'java' apply plugin: 'idea' sourceCompatibility = 1.8 repositories { . . . } dependencies { . . . testCompile group: 'junit', name: 'junit', version:…
andrewgazelka
  • 1,746
  • 1
  • 16
  • 26
76
votes
7 answers

Execute task before Android Gradle build?

is it possible for Gradle to execute a task before calling gradle build Something like precompile. Someone please help. Is something like this possible and how?
HellOfACode
  • 1,675
  • 3
  • 18
  • 38
72
votes
7 answers

How do I extend gradle's clean task to delete a file?

So far I've added the following to my build.gradle apply plugin: 'base' clean << { delete '${rootDir}/api-library/auto-generated-classes/' println '${rootDir}/api-library/auto-generated-classes/' } However, not only is my file not deleted,…
oibe
  • 1,047
  • 1
  • 7
  • 10
31
votes
1 answer

Gradle execute command lines in custom task

In my gradle file I defined the following task: task text_example << { //?!? commandLine '' println 'Fam Flinstone' } I want to put inside this task some commands line. How can I do that ? I'm using a library to automatically publish in…
Corneliu
  • 421
  • 1
  • 6
  • 12
18
votes
3 answers

How to run a command line command with Kotlin DSL in Gradle 6.1.1?

I am trying to run the code block below, after reading multiple posts on the topic and the Gradle manual. I run the below and get the following error: execCommand == null! Any ideas on what I am doing wrong with the below code block? open class…
Dan Largo
  • 1,075
  • 3
  • 11
  • 25
16
votes
2 answers

Gradle - selective module compilation (reuse jar otherwise)

I am using a lot of modules in my project (local and online ones, >20 most of the time) and I can say that normally non of them must be checked nor recompiled. I could include them all as .jar files which would speed up build time but I would prefer…
prom85
  • 16,896
  • 17
  • 122
  • 242
12
votes
3 answers

Stop showing Welcome to Gradle message from output

I am running gradle commands from command line and I want to show only output. There is an option -q, -quiet which says it will log errors only. After running command I get this crap with output too. How can I stop this ?? Welcome to Gradle…
mallaudin
  • 4,744
  • 3
  • 36
  • 68
9
votes
1 answer

Gradle and Shadow plugin - copy additional files (.jar files) to final jar after shadowJar task

Problem description: I'm using Gradle Shade plugin, it all works fine and it copies resource files to the final jar. However, as the docs say, it can not include other .jar files as resources because it can not distinguish them from dependencies. It…
Dmitry Avtonomov
  • 8,747
  • 4
  • 32
  • 45
8
votes
4 answers

Gradle task to take a build of specific build flavors (more than one)

In my app, I have more than 30 build variants. Every time when I release the app, I need to publish it to different platforms, therefore I build 5 different build variants. Currently, I am doing this: switch to build variant A wait for the Gradle…
amira
  • 416
  • 1
  • 7
  • 24
8
votes
1 answer

Gradle fat jar does not contain libraries

I have created a simple Gradle Java project. The build.gradle file looks like this: plugins { id 'java' } repositories { mavenCentral() } dependencies { implementation group: 'org.apache.commons', name: 'commons-lang3', version:…
Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109
8
votes
0 answers

How to unit test gradle task?

I want to test logic of my build.gradle script. Excerpt of the script would be: (...other tasks and methods...) def readCustomerFile(File file) { def schema = def report = schema.validate(JsonLoader.fromFile(file)) if…
Monika
  • 116
  • 1
  • 4
7
votes
3 answers

Run clean task before every build automatically in Gradle

I want to run a project "clean" before the assembleRelease task in Gradle. How can I trigger the clean task basically before everything?
5
votes
2 answers

Gradle lazy Exec-Task configuration

I'm running into a problem when configuring an Exec-Task using an Extension-Property. Problem The configuration of my Exec-Task relies on a String-Property that is defined in an extension. Unfortunately, the property is not set yet, when configuring…
xani
  • 784
  • 1
  • 7
  • 21
5
votes
1 answer

How to create a Gradle Task to run only a specific Tests in Spring

I have a Spring Project where I wrote some Unit and Integration Tests. Now I want to create custom tasks for running all unit tests, all integration tests and one task for running both. But how can I do this?
softwareUser
  • 398
  • 2
  • 6
  • 21
1
2 3
10 11