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
23
votes
2 answers

Is it possible to use the Gradle build system for Android with Eclipse?

I've an app that needs to be build multiple times with different resources for different customers (branding, configuration, and pre-loaded data change between customers). In the wake of this year's Google I/O I've heard about the new Gradle-based…
Chris
  • 3,192
  • 4
  • 30
  • 43
23
votes
3 answers

How to import Action Bar Sherlock to gradle project?

I've imported Module to Android Studio using steps posted this question: Problems importing project into Android Studio regarding ActionBarSherlock The IDE is working well, but It doesn't affect the build. From Android Studio: Are Library Project…
kravemir
  • 10,636
  • 17
  • 64
  • 111
23
votes
2 answers

Gradle multiproject gives "Could not find property 'sourceSets' on project" error

I had quite good gradle configuration, that built everything just fine. But one of the projects of my multi-project build derived from the rest of them so much, that I would gladly move it to another git repo and configure submodules to handle…
Mateusz Kubuszok
  • 24,995
  • 4
  • 42
  • 64
23
votes
1 answer

How to overcome "package com.sun.xml.internal.xxx does not exist" when compiling with Gradle?

I want to compile java code that uses some Java's deprecated "sun" packages and Gradle compile task fails with this error error: package com.sun.xml.internal.ws.developer does not exist I am using Hotspot JDK and I can see this package there (so it…
user1746915
  • 331
  • 1
  • 3
  • 8
23
votes
6 answers

Adding classpath entries using Gradle's Application plugin

I'm using Gradle's Application plugin to generate the install for a standalone java application. I have a configuration file I need to put on the classpath but I can't seem to get it to generate the classpath correctly in the sh/bat files. This…
Josh
  • 2,842
  • 8
  • 45
  • 51
22
votes
1 answer

Gradle Multi-Module Project Setup

I've recently started using Gradle and replacing my existing Maven-based projects. I have had many issues in the past with handling multi-module builds with Maven. Gradle has been a breath of fresh air when handling multi-module buils, but it's not…
juan.villa
  • 231
  • 1
  • 2
  • 5
22
votes
4 answers

Is it ok to use forward slashes instead of File.separator in my (Gradle) build files?

I don't see any obvious problems, but I'm wondering if it's ok to use / rather than File.separator when I'm writing my build files. Using File.separator makes it very difficult to read some of the paths. Ex: dependsDir =…
Ryan J
  • 2,502
  • 5
  • 31
  • 41
22
votes
1 answer

Cmake 3.10.2 not found in SDK, PATH or by cmake.dir prop

Getting the following error when building my project in Android Studio: [CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property. My Gradle looks like the following: externalNativeBuild { cmake { cppFlags…
wazev
  • 321
  • 1
  • 2
  • 4
22
votes
4 answers

Flutter Cannot run Project.afterEvaluate(Closure) when the project is already evaluated

Workaround way: Looks like there is dependecy of onesignal plugin on flutter_tools. The solution is to place onesignal plugin after it in the sequence in the "android/app/build.gradle": apply from:…
Aksoyhlc
  • 285
  • 1
  • 3
  • 11
22
votes
9 answers

Android Jetpack Compose - java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)

I'm getting a java.lang.NoSuchMethodError exception when trying to run setContent{ Composable() }. Full code: class ComposeFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState:…
Kes Walker
  • 1,154
  • 2
  • 10
  • 24
22
votes
3 answers

What causes a junit warning org.junit.platform.launcher.core.EngineDiscoveryOrchestrator lambda$logTestDescriptorExclusionReasons$7

I have a gradle-based java testing framework. After updating junit to 5.7.2 this warning started appearing for every test: Jul 21, 2021 10:23:45 AM org.junit.platform.launcher.core.EngineDiscoveryOrchestrator…
bohdan
  • 425
  • 1
  • 3
  • 8
22
votes
2 answers

Gradle7 Version Catalog: How to use it with buildSrc?

I am very excited about the incubating Gradle's version catalogs and have been experimenting with it. I’ve found that the information in my gradle/libs.versions.toml is accessible in the build.gradle.kts scripts for my app and utility-lib…
A Bit of Help
  • 1,368
  • 19
  • 36
22
votes
9 answers

Could not get unknown property 'release' for SoftwareComponentInternal - Maven publish plugin project gradle

I have an Android project with multiple modules and I want to publish them to self-hosted maven repo. I earlier had the publishing code present in individual modules and things worked just fine. I am now trying to move the publishing code into the…
Swapnil
  • 1,870
  • 2
  • 23
  • 48
22
votes
3 answers

Flutter Secure Storage not working after build in release mode

Everything works fine in debug mode and release on emulator, but reading values from FlutterSecureStorage fails on a physical device. Other functionalities in application work properly, when I comment using FlutterSecureStorage. After installing…
krlxen
  • 341
  • 2
  • 6
22
votes
2 answers

Kapt annotation processing - how to show full stacktrace

I am working on a android project using Kotlin, Databinding and Room. Sometimes the build fails with a error message, containing no information about what exactly went wrong, except that it has something to do with the annotation processor (which…
tarbos
  • 241
  • 1
  • 2
  • 6