Questions tagged [gradle]

Gradle is a project build automation tool that uses a Groovy DSL. Gradle build scripts support Maven and Ivy repositories as well as plain file system for dependency management.

Gradle is a build automation tool focused on flexibility and performance. Gradle build scripts are written using a or DSL. Gradle allows the use of , , or user-defined repositories for dependency management.

Why Gradle?

  • Polyglot Builds: build in 60 different programming languages
  • Tool Integration: like , , , etc.
  • Robust Dependency Management
  • Powerful Yet Concise Logic: declarative and imperative
  • High Performance Builds
  • Build Reporting

Gradle allows you to describe the automation of a project build both declaratively and imperatively as you have the full power of the programming language to describe Gradle tasks.

There are many plugins for Gradle. Both native ones like the "War" plugin and third-party ones. These can be found at plugins.gradle.org

Latest Version: 7.6 (Nov 25, 2022)

The default name for the build script is build.gradle

Expressing a project dependency

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'junit:junit:4.12'
}

Defining a task

Using a closure in defining a task count action:

task count {
    doFirst {
        4.times { print "$it " }
    }
}

Output of running gradle -q count:

> gradle -q count
0 1 2 3

Links:

Related tags:

Tips:

51043 questions
362
votes
9 answers

How do I use tools:overrideLibrary in a build.gradle file?

I'm using the leanback libraries, which require Android 17 or later. However my app supports a minSDK of 16, so I get a build error from gradle saying Error:Execution failed for task ':Tasks:processPhoneDebugManifest'. > Manifest merger failed :…
emmby
  • 99,783
  • 65
  • 191
  • 249
360
votes
31 answers

Error: Unfortunately you can't have non-Gradle Java modules and > Android-Gradle modules in one project

I have an IntelliJ 14.1.2 Project consisting of two modules - one is an Android Gradle based module and the other is a Spring Java-based module with Maven. gps-trackman.v1 is my root project and I've not configured any outputs or facets for this…
kamokaze
  • 7,142
  • 5
  • 33
  • 43
347
votes
24 answers

Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'

I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning : I tried to look for "compile " in the whole project but no match was found. So what could be the cause?
Rob
  • 4,123
  • 3
  • 33
  • 53
346
votes
16 answers

Where does Gradle store downloaded jars on the local file system

How does Gradle store downloaded jar files on the local file system? Maven stores them in the .m2 directory under USER_HOME, but where does Gradle store them? I checked the .gradle folder there, but saw only compiled scripts.
manojpardeshi111
  • 3,465
  • 2
  • 14
  • 8
343
votes
25 answers

Error:(1, 0) Plugin with id 'com.android.application' not found

This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message: Error:(1, 0) Plugin with id 'com.android.application' not…
Bob Kusik
  • 3,439
  • 2
  • 12
  • 3
338
votes
7 answers

Intellij Idea: Importing Gradle project - getting JAVA_HOME not defined yet

Intellij Idea 14.1.4 Mac OS X Yosemite 10.10.3 and later. From the IDE: Import Project -> (Chosen directory to import) -> Import project from external model, Gradle -> Gradle Home: /usr/local/Cellar/gradle/2.4/libexec Gradle JVM: Use JAVA_HOME (not…
bentobox
  • 3,948
  • 2
  • 16
  • 10
337
votes
2 answers

Difference between using gradlew and gradle

What is the difference between using gradlew and gradle or are they the same?
megalucio
  • 5,051
  • 2
  • 22
  • 26
333
votes
19 answers

Gradle: How to Display Test Results in the Console in Real Time?

I would like to see test results ( system.out/err, log messages from components being tested ) as they run in the same console I run: gradle test And not wait until tests are done to look at the test reports ( that are only generated when tests are…
tolitius
  • 22,149
  • 6
  • 70
  • 81
329
votes
1 answer

Multiple maven repositories in one gradle file

So my problem is how to add multiple maven repositories to one gradle file. This DOESN’T work: repositories { mavenCentral() maven { url "http://maven.springframework.org/release" url "http://maven.restlet.org" } }
AZ_
  • 21,688
  • 25
  • 143
  • 191
329
votes
20 answers

Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"

Using Android Gradle plugin 0.7.0 with the following build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.7.0' } } apply plugin:…
David Lawson
  • 7,802
  • 4
  • 31
  • 37
327
votes
16 answers

Android Studio: Where is the Compiler Error Output Window?

When I 'Run' my project in Android Studio, in the 'Messages' window, I get: Gradle: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':play01:compileDebug'. > Compilation failed; see the compiler error output…
ChaseTheSun
  • 3,810
  • 3
  • 18
  • 16
324
votes
9 answers

Why use Gradle instead of Ant or Maven?

What does another build tool targeted at Java really get me? If you use Gradle over another tool, why?
IttayD
  • 28,271
  • 28
  • 124
  • 178
311
votes
9 answers

Could not find method compile() for arguments Gradle

Looked around for this solution for much too long now, and I'm not sure if I missed it or just misstyped something, but my Gradle script will not compile. I am migrating to Gradle, and am very new with it. I am very used to using Maven for…
Ichbinjoe
  • 3,259
  • 2
  • 12
  • 7
306
votes
9 answers

Purpose of buildscript block in Gradle

I am new to Gradle and I am reading the documentation but I don't understand some parts of it. One of these parts is connected with buildscript block. What is its purpose? If your build script needs to use external libraries, you can add them to…
Xelian
  • 16,680
  • 25
  • 99
  • 152
303
votes
15 answers

Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'

I want to add jitpack.io as a repository in my gradle file. This is my gradle root file: buildscript { repositories { google() mavenCentral() } dependencies { classpath "com.android.tools.build:gradle:7.0.2" …
André Nogueira
  • 3,363
  • 3
  • 10
  • 16