https://gradle.com/ logo
Join Slack
Powered by
# community-support
  • a

    Andrzej Zabost

    09/18/2025, 11:54 AM
    Hello. I'm trying to configure some excludes for code coverage. I tried this:
    Copy code
    plugins {
        id("jacoco")
        // ... everything else
    }
    
    tasks.withType<Test> {
        configure<JacocoTaskExtension> {
            excludes = listOf(
                "com.example.*",
            )
        }
    }
    but it doesn't seem to do anything. I tried different formats, like
    com.example.**
    ,
    com/example/*
    and
    com/example/**
    , but none of them worked. How do I correctly do this? Btw I'm running coverage from IDE by just executing a Gradle task with the coverage option. I know I can edit the "run configuration" and add the excludes in the IDE's UI, but I'd rather have a global configuration in Gradle.
    v
    • 2
    • 18
  • j

    Jatin Garg

    09/18/2025, 12:38 PM
    Hlo can any one help me to resolve my unity build error
  • j

    Jatin Garg

    09/18/2025, 12:40 PM
    image.png
    🧵 1
    v
    c
    • 3
    • 9
  • t

    tony

    09/18/2025, 10:03 PM
    My
    test
    task is not running all my tests and I cannot figure out why. I've run it with
    -i
    and
    -d
    and don't see anything in the logging. I've also used
    --rerun
    and
    --no-configuration-cache
    just in case there was something there. There is one test that gets run this way, but it ends up being SKIPPED for unclear reasons. If I use
    --tests Foo
    , then
    Foo
    test does run. I've never seen this before and I'm mystified. I'm using junit5 and have the following dependencies, among others
    Copy code
    # libs.versions.toml
    junitEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiter" }
    junitLauncher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatformLauncher" }
    
    // build.gradle.kts
    testRuntimeOnly(libs.junitEngine)
    testRuntimeOnly(libs.junitLauncher)
    ✅ 1
    • 1
    • 1
  • s

    SW

    09/19/2025, 6:19 AM
    Hello, getting this error when try to run the code.
    * What went wrong:
    Plugin [id: 'com.github.johnrengelman.shadow', version: '7.0.0'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Plugin Repositories (could not resolve plugin artifact 'com.github.johnrengelman.shadowcom.github.johnrengelman.shadow.gradle.plugin7.0.0') Searched in the following repositories: Gradle Central Plugin Repository * Try:
    Run with --stacktrace option to get the stack trace.
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Get more help at https://help.gradle.org CONFIGURE FAILED in 19s
    v
    • 2
    • 1
  • n

    Niels Doucet

    09/19/2025, 10:39 AM
    Is there any reliable way to resolve gradle properties in an init script? We used to rely on
    DefaultGradlePropertiesController#loadGradlePropertiesFrom
    , but that moved to an internal package with gradle 9. I'd really like to avoid relying on internal classes.
    v
    • 2
    • 6
  • r

    Robert Elliot

    09/19/2025, 3:39 PM
    I'm ashamed to say that I've never really got to grips with included builds. I asked ChatGPT for a way to be able to include / uninclude a build globally without risking committing something accidentally, and it came up with this:
    settings.gradle.kts
    Copy code
    if (file("settings-include.gradle.kts").exists()) {
      apply(from = "settings-include.gradle.kts", optional = true)
    }
    .gitignore
    Copy code
    settings-include.gradle.kts
    settings-include.gradle.kts
    Copy code
    includeBuild("../other-project")
    Then you can just comment that line in
    settings-include.gradle.kts
    in and out. Is this how everyone else is doing it?
    m
    v
    +2
    • 5
    • 14
  • a

    Adam

    09/19/2025, 7:18 PM
    when Kotlin Multiplatform projects are published to Maven there's a variant for each target. Each has a separate GAV coordinate and directory, and is linked together via the Gradle Module Metadata. The variants are discovered via a relative URL in the metadata. I want to emulate the same behaviour for a simple project, for an integration test. Something like
    foo-lib
    publishes text files to GAV
    org.demo:foo-lib-text
    and repo path
    org/demo/foo-lib-text/
    , and json files to
    org.demo:foo-lib-json
    with path
    org/demo/foo-lib-json/
    . The main variant is published to
    org/demo/foo-lib/
    . Is this possible? I tried adding feature variants but they use the same directory, but with a different directory.
    • 1
    • 3
  • s

    Sergej Koščejev

    09/22/2025, 11:48 AM
    If I want to compute a build number once and share it among several projects, what is the best way to do it? Computing it would involve calls to Git because I would like to include the commit hash, and/or accessing some env variables. What's the best place to put the computed build number to comply with the best practices re project isolation and whatnot? I could do it in a precompiled plugin that each project applies but it seems kind of overkill for each project to compute the version over and over.
    m
    n
    +3
    • 6
    • 11
  • t

    Thomas Keller

    09/22/2025, 2:23 PM
    Hi all! I try to migrate a hand-crafted version catalogue (i.e. scripted in a
    SettingsPlugin
    ) to one using a central
    gradle/libs.versions.toml
    file to support GHs Renovate bot in a multi-component build. Previously I had this specific settings plugin applied to all of my sub component's settings like this:
    Copy code
    pluginManagement {
        includeBuild("../build-settings")
    }
    
    plugins {
        id("my.custom.settings.plugin")
    }
    and it all worked fine. Now that move to that
    libs.versions.toml
    I cannot get this working any longer, since each subcomponent has it's own reference to a
    gradle
    subdir, i.e.
    ROOT/gradle/libs.versions.toml
    exists, but
    ROOT/subcomponent/gradle/libs.versions.toml
    obviously does not and if I try to manually "correct" that like this via
    Copy code
    if (!settings.project(":").name.contains("monorepo")) {
      settings.dependencyResolutionManagement {
         versionCatalogs {
            create("libs") {
              from(
                settings.layout.settingsDirectory.file("gradle/libs.versions.toml")
              )
            }
         }
      }
    }
    I get
    ROOT/subcomponent/gradle/
    referenced and even if I fix that, Gradle will still tell me
    Copy code
    java.lang.RuntimeException: org.gradle.internal.typeconversion.UnsupportedNotationException: Cannot convert the provided notation to an object of type Dependency: /local/path/to/monorepo/gradle/libs.versions.toml.
    The following types/formats are supported:
      - String or CharSequence values, for example 'org.gradle:gradle-core:1.0'.
      - Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0'].
      - FileCollections, for example files('some.jar', 'someOther.jar').
      - Projects, for example project(':some:project:path').
      - ClassPathNotation, for example gradleApi().
    So what am I doing wrong / how can I effectively share a TOML version catalogue in a multi-component scenario?
    t
    • 2
    • 3
  • y

    ysb33r

    09/22/2025, 6:33 PM
    Is there an attribute one can set on an outgoing variant to indicate a library should only be added to runtime scope if Gradle version is within a certain range?
    m
    p
    v
    • 4
    • 13
  • n

    Nik Ammerlaan

    09/22/2025, 10:34 PM
    Hey folks, I’m enabling Gradle’s configuration cache in CI and running into a Docker auth issue with Testcontainers. The first run after turning it on is fine, then about an hour later a fresh run starts failing to pull from our private registry with 401. If I switch the configuration cache off, the same workflow passes. I’m not reading credentials during configuration, so I’m puzzled about what state could be getting reused. Could the configuration cache cause tests to see stale Docker auth across runs? Is it more practical to mark tests as not compatible with the configuration cache because the registry token is short-lived? If anyone has dealt with configuration cache oddities like this, I’d appreciate pointers.
    v
    • 2
    • 3
  • m

    Markus Maier

    09/23/2025, 8:24 AM
    Hi, I need to configure a
    Copy
    task with data from a file produced by another task. Currently that's done by cross-configuring the second task from the first. I'm trying to find a better way, but so far have come up empty. Do you have any pointers for me, or am I stuck with using cross-configuration?
    v
    • 2
    • 21
  • j

    Jatin Garg

    09/23/2025, 1:59 PM
    Hi i am facing an issue ..while making a build it takes alot of time to again rebuild even if i just commented a line of code .
    v
    • 2
    • 1
  • c

    Colton Idle

    09/23/2025, 4:33 PM
    Got a popup today in android studio... didn't grab a screenshot but it said something like "New macro available for GRADLE_LOCAL_JAVA_HOME" What does that mean? is it that theres a new ENV variable for declaring which java home, gradle should use?
    v
    • 2
    • 2
  • a

    Adam

    09/23/2025, 8:53 PM
    I want to use
    net.rubygrapefruit:native-platform
    in a pet project but it has a lot of variants for specific OSes that are downloaded unnecessarily. It seems to be published without Gradle module metadata. Is there an existing ComponentMetadataRule so I can only download a suitable variant for the current OS & arch?
    v
    • 2
    • 4
  • m

    Mike Wacker

    09/24/2025, 10:57 PM
    Is this a good way to take advantage of layer caching with Docker + Gradle? 1. Download Gradle. 2. Build buildSrc. 3. Build everything.
    Copy code
    # syntax=docker/dockerfile:1
    FROM eclipse-temurin:21-jdk AS build
    WORKDIR /src
    COPY gradle/ gradle/
    COPY gradle.properties gradlew ./
    RUN ./gradlew --no-daemon --version
    COPY buildSrc/ buildSrc/
    RUN touch settings.gradle.kts
    RUN ./gradlew --no-daemon build
    COPY . .
    RUN ./gradlew --no-daemon installDist
    
    FROM eclipse-temurin:21-jre
    WORKDIR /app
    COPY --from=build /src/app/build/install/app/ ./
    COPY --from=build /src/docker/config/ config/
    CMD ["bin/app", "server", "config/config.yml"]
    Aside: it still seems like the
    buildSrc
    tasks take a significant, non-zero amount of time in the
    RUN ./gradlew --no-daemon installDist
    layer, but overall, this layer does seem to be faster if you build
    buildSrc
    in an earlier layer.
    t
    t
    • 3
    • 7
  • s

    Stylianos Gakis

    09/25/2025, 10:25 AM
    If I want to apply a bom to all of my projects ("com.squareup.okhttp3:okhttp-bom") is there a way to do it in one place so that I don't have to write
    implementation(platform(libs.okhttp.bom))
    in all places where I add any okhttp dependency? Conceptually, something like
    Copy code
    subprojects {
        dependencies {
            implementation(platform(libs.okhttp...
    but I can't seem to find the proper way to do this.
    m
    v
    t
    • 4
    • 12
  • f

    Fanish

    09/26/2025, 8:51 AM
    I am trying to add a jasper related task like below,
    Copy code
    tasks.register('compileJasperReports') {
        dependsOn classes
    
        doLast {
            def jasperOut = jasperOutDir.get().asFile
            jasperOut.mkdirs()
    
            ant.taskdef(
                    name: 'jasper',
                    classname: 'net.sf.jasperreports.ant.JRAntCompileTask',
                    classpath: jasperCompileClasspath.asPath
            )
    
            ant.jasper(
                    destdir: jasperOut,
                    srcdir: jasperSrcDir,
                    includes: jasperIncludes
            ) {
                classpath {
                    pathelement(path: mainOutputClassesDirs.asPath)
                    pathelement(path: mainOutputResourcesDir)
                    pathelement(path: compileClasspath.asPath)
                    pathelement(path: jasperCompileClasspath.asPath)
                }
            }
        }
    }
    but the build is failing with
    Copy code
    14:08:04 FAILURE: Build failed with an exception.
    14:08:04 
    14:08:04 * What went wrong:
    14:08:04 Java heap space
    I have added this in gradle.properties
    Copy code
    org.gradle.jvmargs=-Xmx12g -XX:MaxMetaspaceSize=2g -XX:+HeapDumpOnOutOfMemoryError
    What is cousing this issue?
    t
    v
    • 3
    • 13
  • n

    Nobara_Vinny

    09/26/2025, 8:57 AM
    hey so I ran ./gradlew build and got an error
  • n

    Nobara_Vinny

    09/26/2025, 8:58 AM
    'gradlew' is not recognized as an internal or external command, operable program or batch file.
    🧵 1
  • n

    Nobara_Vinny

    09/26/2025, 9:03 AM
    Try:
    Run with --stacktrace option to get the stack trace.
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Get more help at https://help.gradle.org BUILD FAILED in 5s
    🧵 1
    v
    • 2
    • 1
  • c

    Caleb Cushing

    09/26/2025, 12:10 PM
    is there a way to invoke a task programatically after configuration? meaning I never call
    ./gradlew mytask
    even just running
    ./gradlew
    would execute it
    m
    v
    • 3
    • 12
  • c

    Caleb Cushing

    09/26/2025, 12:30 PM
    if I'm depending on a 3rd party file like
    Copy code
    .git/config
    that I never need to read in the task (it's just for change detection to decide with the task needs to be run
    Copy code
    @Input
      val gitConfig = project.layout.projectDirectory.dir(".git").file("config")
    is right? I don't ever need
    filename
    so this feels unintitive in a way. Also since the task technically mutates it, should it have both input and output on the same property? basically I want to run
    git config core.hooksPath .config/git/hooks
    but only if it hasn't been run
    v
    • 2
    • 30
  • j

    John

    09/30/2025, 2:08 PM
    has anyone figured out how to use includeBuild with shadow? in my case, my main build is including another build which provides a gradle plugin to be applied within the main build. but the plugin project uses gradleup shadow. the error looks like
    Copy code
    > Could not resolve all artifacts for configuration 'classpath'.
       > Failed to transform xxx-main.jar (project :plugin) to match attributes {artifactType=jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.internal.instrumented=instrumented-only, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
          > Execution failed for ProjectDependencyInstrumentingArtifactTransform: /home/xxx-main.jar.
             > java.io.FileNotFoundException: File system element for parameter 'source' does not exist: '/home/xxx-main.jar'
    The plugin produces the shadow jar without the
    main
    classifier. so my thought was to do a custom dependency substitution like this
    Copy code
    variant(module("myplugin")) {
                attributes{
                    attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.SHADOWED))
                }
            }
    however, it seems the
    objects
    reference doesn't exist in settings.gradle. is there anyway to set an attribute in an included build dependency substitution?
    j
    e
    v
    • 4
    • 5
  • f

    Fanish

    10/01/2025, 8:53 AM
    Copy code
    I am using a war task in my gradle project, The idea is to get the web.xml file in war artifact created and in that copied file there is one parameter <param-value>${springActiveProfile}</param-value>which should have the value given in def springActiveProfile = 'sync,prodPropertySetup'.
    But my below added task is not working as it is not editing the web.xml
    Copy code
    def springActiveProfile = 'sync,prodPropertySetup'
    war {
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
        archiveBaseName = "Sync"
    
        // Normal webapp content
        from("src/main/webapp")
    
        // Override just web.xml with expansion
        from("src/main/webapp/WEB-INF") {
            include "web.xml"
            into "WEB-INF"
            expand(springActiveProfile: springActiveProfile)
        }
    }
    s
    v
    • 3
    • 4
  • s

    Slackbot

    10/01/2025, 9:28 AM
    This message was deleted.
    v
    • 2
    • 1
  • s

    Sofia Louisy

    10/01/2025, 10:09 AM
    Hi! I'm new to gradle and have started a new gradle project in eclipse. It gives me a lib folder, and a gradle folder, but not an app-folder. I cannot find anywhere in the new-project-wizard that I want a java application, and I havn't found an easy way to create my java application there
    d
    v
    • 3
    • 3
  • k

    Kanstantsin Shautsou

    10/01/2025, 11:28 AM
    How to deal with such warnings? visible is not used in any project related code
    m
    v
    • 3
    • 17
  • j

    Joseph Ottinger

    10/01/2025, 5:58 PM
    hi, all. I have an unfortunately complex build with groovy and gradle 8, using a series of plugins, etc., that I need to convert to be ABLE to be an airgapped build (i.e., have an offline construction such that it doesn't touch a network that it would have no access to anyway). There are offline dependency plugins, but they're badly out of date, and they resolve plugin dependencies poorly. I have a few options in mind, but before I chase them too far, I wanted to see if there's conventional wisdom to apply here.
    e
    • 2
    • 2
1...9899100101102Latest