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

    Sebastian Schuberth

    05/19/2025, 11:09 AM
    Gradle docs say that publishing features should just work, but for me it doesn't, Sonatype Central Portal is giving me bogus "Dependency version information is missing" errors. So how can I actually disable publishing of custom features? (As I only need to be able to build them locally.)
    v
    • 2
    • 3
  • t

    Tapchicoma

    05/19/2025, 2:28 PM
    What would be the best approach to add all resolved dependencies from resolvable configuration into consumable configuration artifacts without triggering the resolvable configuration resolve unless consumable configuration was requested by some other project?
    ✔️ 1
    • 1
    • 3
  • b

    Bhavana Dornadula

    05/19/2025, 5:58 PM
    Hello, I am trying to JAR for my selenium gradle project and not able to update sources and getting below error.
    Copy code
    Unable to download com.salesforce.csg.testautomation.services:CSG-UnifiedTestAutomation-Services:7.0.0-local-SNAPSHOT:sources from MavenLocal. Ensure that all the artifact's components are available in this repository. Alternatively, adjust the order of repositories in build.gradle to prioritize downloading from the repository with the full set of components.
    v
    • 2
    • 1
  • r

    Robert Elliot

    05/21/2025, 2:00 PM
    We recently needed to take a gradle application project and publish it as a library. In our dependencies we were not always specifying versions, on the basis that the project was a fairly thin library around a library that defined the versions of some core projects (jetty, jackson). When we published it as a library we were not able to consume it because a number of the dependencies had null versions in the generated pom. Two questions: 1. Can I stop it doing that? 2. If not, what would be a good way to add a CI check that the generated pom is always consumable? Thanks!
    s
    • 2
    • 3
  • a

    Adam Roberts

    05/21/2025, 5:35 PM
    Anyone free to answer some stupid gradle questions
    party gradlephant 1
    c
    • 2
    • 2
  • a

    Adam Roberts

    05/21/2025, 7:06 PM
    I suck at gradle.. I am making a new android project and am starting a new. I am trying to add a gitlab repo to it, but I am not sure where I add it. I believe I know what the syntax should be, but there is confusion about the overall structure of gradle and adding repos that get added into the actual project.
    t
    e
    v
    • 4
    • 15
  • a

    Adam Roberts

    05/22/2025, 12:27 AM
    Are there better gradle courses than others? Preferably android focused? I'll happily jump into a 6 hour one if it's actually more useful, but it seems most are ~2-3.
  • e

    Estevan Fick

    05/22/2025, 2:09 PM
    I'm trying to add a source set to the "com.android.compose.screenshot" plugin. When I ran
    ./gradlew :module:sourceSets
    , the screenshotTest is shown on the list, but when I try to use it on the gradle script, I get "SourceSet with name 'screenshotTest' not found. Is this the correct way to add a different directory?
    v
    p
    • 3
    • 3
  • s

    Sebastian Schuberth

    05/23/2025, 8:27 AM
    Just to clarify, as I do not find the docs here to be super clear: If the Gradle wrapper configures a Gradle version that's globally available in
    PATH
    on the build machine, it will not get bootstrapped, right? Or does the wrapper only look among versions that have been bootstrapped by the wrapper before to
    ~/.gradle/wrapper/
    ?
    v
    • 2
    • 5
  • l

    Lee Turner

    05/23/2025, 11:14 AM
    For one of the libraries we maintain, we currently publish to a private repo using:
    Copy code
    publishing {
        publications {
            mavenJava(MavenPublication) { publication ->
                artifactId = 'lib-name'
                from components.java
                versionMapping {
                    usage('java-api') {
                        fromResolutionOf('runtimeClasspath')
                    }
                    usage('java-runtime') {
                        fromResolutionResult()
                    }
                }
            }
        }
        repositories {
            maven {
                ....
            }
        }
    }
    This works fine. Now we are obfuscating the code using proguard and we updated this to use the jar generated by the proguard task:
    Copy code
    publishing {
        publications {
            mavenJava(MavenPublication) { publication ->
                artifactId = 'lib-name'
                
                artifact(tasks.proguard.outputs.files[0]) {
                    builtBy(tasks.proguard)
                }
                versionMapping {
                    usage('java-api') {
                        fromResolutionOf('runtimeClasspath')
                    }
                    usage('java-runtime') {
                        fromResolutionResult()
                    }
                }
            }
        }
        repositories {
            maven {
    
        }
    }
    This does work in the sense that it publishes the jar generated by proguard but importantly it doesn't generate the same
    .pom
    file with all the associated dependencies as the one generated from the
    components.java
    artifact (and the sources jar but this is less important at the moment). Is there a way to use the jar from the proguard task but still have all the other parts of the publication from the components.java artifact ? I tried using both artifacts at the same time but that generated an error -
    Invalid publication 'mavenJava': multiple artifacts with the identical extension and classifier ('jar', 'null').
    . Adding a classifier to the proguard artifact works but then both jars are published and the proguard jar has the classifier appended to the filename. I also tried adding the
    pom {}
    element to the publication and removing the
    components.java
    artifact but that generated the pom but without all the dependencies that are present when generated from the
    components.java
    artifact. I am currently looking into just copying jars around but was wondering if there was a better way using the artifacts?
    v
    • 2
    • 2
  • a

    Andrzej Zabost

    05/23/2025, 1:15 PM
    Hey. I stumbled upon this answer https://stackoverflow.com/a/78936660/6761823: > Modern Gradle Behavior: > • Gradle now automatically includes a clean task that targets the
    buildDir
    directory in each project (including the top-level project). but it doesn't seem to be the case when I'm testing it in my project running Gradle 8.10.2. If I delete the custom
    clean
    task registered in the top-level
    build.gradle.kts
    file:
    Copy code
    tasks.register("clean", Delete::class) {
        delete(rootProject.layout.buildDirectory)
    }
    then run
    ./gradlew clean --dry-run
    , I can't see the top-level
    clean
    task on the list. If I restore the custom
    clean
    task in
    build.gradle.kts
    and re-run that command, the task is listed as expected. So it doesn't seem to be true that "modern Gradle automatically includes this task for top-level project". Can someone clarify if I'm expected to manually register a
    clean
    task in root
    build.gradle.kts
    or is this practice deprecated in favor of something else?
    c
    e
    v
    • 4
    • 7
  • m

    Matei David

    05/23/2025, 6:25 PM
    Hi. As part of authoring a Gradle plugin, I want to test its compatibility with the Gradle configuration cache, if possible using TestKit. I'm using
    GradleRunner.create().withTestKitDir(myTestHomeDir).withPluginClasspath().withProjectDir(myProjectDir).withDebug(false)
    . (Initially I had tried
    withDebug(true)
    to get coverage, but cc-enabled tests fail due to the presence of the Jacoco agent, so I gave up on coverage for cc tests.) Still, with the settings above, my cc tests pass on Windows and fail on Linux with a message that: "Class com.sun.jna.NativeLibrary: external process started /sbin/ldconfig -p... Starting an external process /sbin/ldconfig -p during configuration time is unsupported" I tried to identify the culprit that might execute ldconfig, and I suspect it is caused by the recently added Nebula Info. Still, I am puzzled why Gradle complains about the ldconfig call only on Linux and not on Windows. I'm not too familiar with Neblua, but I suspect this OS-specific branching might occur elsewhere. Does anyone have any suggestions how to fix my cc-enabled tests on Linux without ditching Nebula Info? Is there any guideline specifically about Gradle cc and Jna/ldconfig on Linux in particular? EDIT: I found the Linux call here: https://github.com/nebula-plugins/gradle-info-plugin/blob/main/src/main/groovy/nebula/plugin/info/ci/POSIXUtil.groovy#L23 It seems ridiculous this is being done only to get the hostname... This is resolved, I might raise it with Nebula Info, not a Gradle issue. I'll leave this here for reference.
    👌 1
  • a

    Arjan van Wieringen (avwie)

    05/25/2025, 11:06 AM
    A very simple question I think. I have a project consisting of the following folders: • libraries ◦ libA ◦ libB • plugins ◦ pluginA ◦ pluginB • applications ◦ appA ◦ appB Plugins should be able to have dependencies on libraries Applications should be able to have dependencies on libraries and enable plugins from the plugins Am I correct that composite builds at the level of libraries/plugins/applications is the right way forward? If I wouldn't have the plugins I could've gone the simpler route of just including the subprojects. But since plugins need to be available during the configuration phase (correct?) they needed to be included in the build and this automatically implies that its dependencies as well need to be available in the build.
    v
    • 2
    • 17
  • n

    no

    05/26/2025, 11:51 AM
    Hey there, 👋 I'm looking at the sample of sharing artifacts between projects with Gradle. Is there a way of setting this up so that the consuming project doesn't have to know the names of the dependent projects? Specifically this line:
    Copy code
    dependencies {
        add("instrumentedRuntime", project(":producer"))
    }
    `project(":producer") requires me to know the name of the producing project. It seems to me there is a way to do this without knowing the names of the producing project like the aggregate test reports plugin does.
    👀 1
    m
    v
    • 3
    • 16
  • a

    Adam

    05/26/2025, 6:01 PM
    I want to publish all Gradle modules to a single directory, without the Maven repository directory layout. I've updated the Gradle Module Metadata so the relative file paths point to the correct location. I expected Gradle would be able to detect the modules based on the Gradle Module Metadata files, but it seems like Gradle is hardcoded to detect the module version from the directory, which fails because I'm not publishing it to a Maven directory https://github.com/gradle/gradle/blob/5bb3182cf38a901dbffbacc0cb9c8efec9f87e9a/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/M2ResourcePattern.java#L80 Is there a way of defining a
    repository {}
    that will only use Gradle module metadata to resolve artifacts, and not assume a Maven repository layout?
    v
    • 2
    • 5
  • a

    Adam

    05/27/2025, 10:18 AM
    Is there a mistake in the Gradle Module Metadata spec? It says the attribute values can only be strings or booleans, but the
    org.gradle.jvm.version
    attribute value can be an integer. https://github.com/gradle/gradle/blob/v8.14.1/platforms/documentation/docs/src/docs/design/gradle-module-metadata-latest-specification.md?plain=1#L79-L80 https://github.com/gradle/gradle/blob/v8.14.1/platforms/documentation/docs/src/docs/design/gradle-module-metadata-latest-specification.md?plain=1#L112
    til 1
    v
    • 2
    • 1
  • a

    Akhilesh Singh

    05/27/2025, 2:32 PM
    I am getting this error continously and unable to resolve the same post multiple debugging steps:-
    Copy code
    What went wrong:
    Execution failed for task ':app:setup'.
    > Command failed: bash -c source /Users/akhileshsingh/AndroidStudioProjects/android-truecaller/android-revelio/.pyenv/bin/activate && pip3 install -r scripts/perfetto/requirements.txt
      Process 'command 'bash'' finished with non-zero exit value 1
      error: subprocess-exited-with-error
        
        × Getting requirements to build wheel did not run successfully.
        │ exit code: 1
        ╰─> [21 lines of output]
            Traceback (most recent call last):
              File "/Users/akhileshsingh/AndroidStudioProjects/android-truecaller/android-revelio/.pyenv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
                main()
                ~~~~^^
              File "/Users/akhileshsingh/AndroidStudioProjects/android-truecaller/android-revelio/.pyenv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
                json_out["return_val"] = hook(**hook_input["kwargs"])
                                         ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
              File "/Users/akhileshsingh/AndroidStudioProjects/android-truecaller/android-revelio/.pyenv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
                return hook(config_settings)
              File "/private/var/folders/yh/mgnb466d79l9s3h02r8xl_200000gp/T/pip-build-env-v6qxs0vu/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
                return self._get_build_requires(config_settings, requirements=[])
                       ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "/private/var/folders/yh/mgnb466d79l9s3h02r8xl_200000gp/T/pip-build-env-v6qxs0vu/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
                self.run_setup()
                ~~~~~~~~~~~~~~^^
              File "/private/var/folders/yh/mgnb466d79l9s3h02r8xl_200000gp/T/pip-build-env-v6qxs0vu/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
                exec(code, locals())
                ~~~~^^^^^^^^^^^^^^^^
              File "<string>", line 30, in <module>
              File "<string>", line 27, in get_version
            KeyError: '__version__'
            [end of output]
        
        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: subprocess-exited-with-error
      
      × Getting requirements to build wheel did not run successfully.
      │ exit code: 1
      ╰─> See above for output.
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    
    * 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>.
    v
    • 2
    • 1
  • p

    Philip W

    05/28/2025, 7:19 AM
    How can you use WorkerAction with the TestListener? I don't want to use a main function and pass all the parameters untyped
    v
    • 2
    • 13
  • e

    Eli Graber

    05/28/2025, 9:14 AM
    If I'm writing a plugin that is meant to be applied to every project, and most projects will configure the plugin identically, is it better to: A. Have a root plugin that defines a service configured by an extension that sets the defaults for all other projects to use B. Have the plugin look for a configuration file in the root project directory C. Something else
    🅰️ 1
    t
    v
    • 3
    • 5
  • n

    Nadav Gampel

    05/28/2025, 11:58 AM
    hey! im trying to publish locally an artifact/library and consume from another project. the artifact, with the correct version is indeed created in the .m2 folder. but, its not added to gradle cache, instead it takes some version from upstream the code is using the right class in compilation, but in runtime(running with intellij) the classpath is gradle cache, and its not there
    v
    v
    • 3
    • 14
  • r

    Rob Pridham

    05/28/2025, 3:19 PM
    Hi! I have an Android project where
    testDebugUnitTest
    is not running unit tests in most of our application modules, i.e.
    com.android.application
    ones. It happily runs them in all the library modules, and curiously, one sample app module. More specific tasks like
    testMyProductVariantDebugUnitTest
    do run them. What can I look at (logs etc) to understand why this is happening?
    e
    • 2
    • 12
  • н

    Никита Гучаков

    05/28/2025, 7:19 PM
    Hi, is there any option to avoid repository url/configuration duplication? We have 2 nexus repos urls for custom snapshots/releases versions and currently it's at 3 places: buildSrc, settings.kts pluginsManagement and dependencyResolutionManagement
    v
    • 2
    • 9
  • a

    Adam

    05/29/2025, 8:34 PM
    What would it take to make convert a Gradle Module Metadata file to an equivalent POM file, so the module can be consumed by Maven? Just looking at the JVM ecosystem. I've found a way to publish Gradle libraries to GitHub, without using GitHub Packages (which is annoying because it requires authentication, and requires users define multiple repos for each library). I want to make it easier to prototype libraries, which would be much easier than setting up Maven Central. Basically: attach the files to GitHub Release assets. It's quite easy to tweak Gradle to process the files but not for Maven, because the files are in a 'flat' directory, and Maven requires files are in the typical
    org/package/version/
    directories. To support Maven I think a Maven plugin could make it work, but I'm just curious whether a
    pom.xml
    would be necessary, since the GMM contains the same data.
    e
    v
    • 3
    • 20
  • s

    Something

    05/30/2025, 8:39 AM
    does anyone understand this?
    c
    n
    +2
    • 5
    • 4
  • j

    James Daugherty

    05/30/2025, 11:10 PM
    Well here's something I've not experienced before; I'm trying to "test" a source distribution zip. As part of that, I have a wrapper task in my gradle file that generates the missing wrapper files. Running
    gradle wrapper
    from my extracted source location, creates the wrapper. Here's the confusing part: If I have a shell script to do this step for me, the project attempts to build (and actually ignores the settings.gradle file indicating separate gralde projects so it fails to build). It doesn't generate the wrapper. Has anyone seen this before ?
  • m

    Martin

    05/31/2025, 11:54 AM
    Is there a Gradle task that shows me the exported compile classpath from a project? I don't want the
    compileClasspath
    of the project, I want what other projects will see when depending on it. Seems like
    apiElements
    is closer to what I want but it doesn't show any dependencies in
    ./gradlew dependencies
    v
    • 2
    • 16
  • v

    Vishwanth Prakash

    05/31/2025, 12:18 PM
    Good Afternoon sir. I'm Vishwanth. I'm lagging for 3 days with same issue in react native expo build. it continuously showing error like this.
    Copy code
    WARNING: The following problems were found when resolving the SDK location:
    101
    Where: ANDROID_SDK_ROOT environment variable. Problem: Directory does not exist
    Could you help me with this case?
    v
    • 2
    • 4
  • a

    Arjan van Wieringen (avwie)

    06/01/2025, 8:19 AM
    When using composite builds my individual root project do not discover the tasks of the subprojects anymore. So I do not mean that I can not access tasks from includedBuilds, because that is by design. But I mean that I have a composite build (libs) with subprojects in there (asset-mapper). And the libs project does not allow me to execute the tasks. See thread for what I mean.
    a
    v
    • 3
    • 13
  • t

    Thomas Chan

    06/02/2025, 4:01 AM
    I might be going insane but what precisely does "build", the noun, mean in Gradle?
    v
    a
    • 3
    • 34
  • d

    Divya Nair

    06/02/2025, 4:48 PM
    Hello, I have been trying to build my gradle project and I have been seeing this error for the past few days. My project used to build properly but now just a few days ago I started seeing this error. What can it possibly mean and what can I do to fix it?
    v
    • 2
    • 7