https://gradle.com/ logo
Join Slack
Powered by
# plugin-development
  • c

    Christian Ambach

    11/08/2024, 3:13 PM
    Hi all, I am working on a bugfix in the Hibernate Gradle Plugin. Currently, it only works if the order of plugins in the
    build.gradle
    file is correct. The Java Plugin (or another plugin that pulls in the Java plugin) needs to be in the plugin list before the Hibernate plugin. During review of my PR on Github, @Steve Ebersole brought up the question if I was using the correct approach while fixing the bug. It would be nice if someone could have a quick look at the pull request and either comment here (or in the PR) if the chosen approach is the right one and if not, provide a hint how it should be done. Thank you in advance! https://github.com/hibernate/hibernate-orm/pull/8770
    v
    • 2
    • 2
  • t

    thadhouse

    11/12/2024, 12:20 AM
    Is something broken with the gradle plugin portal? I just published https://plugins.gradle.org/plugin/edu.wpi.first.WpilibTools version 2.0.0, but when I attempt to use it, I get an error that it can't be found. An empty gradle project with just the following.
    Copy code
    plugins {
      id "edu.wpi.first.WpilibTools" version "2.0.0"
    }
    Gives the following error
    Copy code
    > Configure project :
    Evaluating root project 'gradlerio' using build file 'C:\Users\thadh\Documents\GitHub\thadhouse\gradlerio\build.gradle'.
    Resource missing. [HTTP GET: <https://repo.maven.apache.org/maven2/edu/wpi/first/WpilibTools/edu.wpi.first.WpilibTools.gradle.plugin/2.0.0/edu.wpi.first.WpilibTools.gradle.plugin-2.0.0.pom>]
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'C:\Users\thadh\Documents\GitHub\thadhouse\gradlerio\build.gradle' line: 2
    
    * What went wrong:
    Plugin [id: 'edu.wpi.first.WpilibTools', version: '2.0.0'] was not found in any of the following sources:
    
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Included Builds (No included builds contain this plugin)
    - Plugin Repositories (could not resolve plugin artifact 'edu.wpi.first.WpilibTools:edu.wpi.first.WpilibTools.gradle.plugin:2.0.0')
      Searched in the following repositories:
        Gradle Central Plugin Repository
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at <https://help.gradle.org>.
    Attempting to use a version I published previously works.
    e
    • 2
    • 3
  • p

    pgreze

    11/13/2024, 7:15 AM
    Hello, not so sure about where to ask this question. Because it's related to Gradle plugin conventions, I'm gonna ask here. I have several plugins in
    buildSrc/src/main/kotlin/com/company/allprojects/*.gradle.kts
    where I split the logic applied by
    allprojects
    or
    subprojects
    blocks across multiple files. They all need to be applied at the root build.gradle.kts but it happened a newly added plugin apply was forgotten. To solve this problem, I wrote this
    buildSrc/src/main/kotlin/com/company/allprojects/apply-all.gradle.kts
    logic:
    Copy code
    package com.company.allprojects
    
    //
    // Programmatically ensure all plugins located in this folder are applied.
    //
    
    val PLUGIN_SUFFIX = "gradle.kts"
    
    rootDir.resolve("buildSrc/src/main/kotlin/com/company/allprojects")
        .listFiles()
        .asSequence()
        .filter { it.name != "apply-all.gradle.kts" }
        .filter { it.name.endsWith(".gradle.kts") }
        .sorted()
        .forEach { apply(plugin = "com.company.allprojects.${it.name.removeSuffix(".gradle.kts")}") }
    But I'm not sure it's the best solution, even if it's working... Regardless of the hardcoded path, which is OK because it's only made to be used in this specific project, could someone point me to a better alternative, or just confirm if it's good enough?
    m
    v
    • 3
    • 10
  • l

    Leon Linhart

    11/14/2024, 10:12 AM
    Is it expected that the
    VersionCatalogsExtension
    is not yet available when applying a project plugin via settings plugin using
    Gradle#beforeProject
    ? I have multiple repos for microservices with exactly the same layout. I was planning to dedupe my build configuration by creating a settings plugin that does three things: • Registering an external version catalog • Including the usual subprojects • Applying project plugins to each subprojects. The project plugins were supposed to apply dependencies from the catalog. However, when doing this as described above, I noticed that version catalogs are not accessible at this stage. Is there a better approach this?
    p
    v
    t
    • 4
    • 27
  • n

    Nicklas Ansman

    11/14/2024, 7:19 PM
    Is there any way to specify an input directory for a task that is allowed to not exist (I don't mean that you're allowed to not specify it, I mean specifying a directory that doesn't exist)
    v
    • 2
    • 9
  • a

    Adam

    11/18/2024, 1:18 PM
    I wanted to check here before I open an issue. Did upgrading to Gradle v8.11 break your ability to add included builds to your project? We publish our convention plugins to an internal artifactory, but keep the sources in the parent android project for quick debugging / iteration. I’ve just noticed that after upgrading to v8.11, adding the line
    includeBuild("build-logic")
    breaks my build with classpath errors like this:
    Copy code
    Error resolving plugin [id: 'com.org.group.plugin.name', version: '1.0.30']
    > The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
    t
    • 2
    • 8
  • k

    Kelvin Chung

    11/19/2024, 12:00 AM
    Hey folks. Is there any public API in
    ExtensiblePolymorphicDomainObjectContainer
    that can be used to introspect registered bindings/factories? I have a build that is failing due to
    Copy code
    Caused by: org.gradle.api.GradleException: Cannot register a factory for type MyType because a factory for this type is already registered.
    It looks like there are internal APIs to do this, but not any public ones, according to API documentation.
  • k

    kyle

    11/25/2024, 8:37 PM
    Hi folks, I'm trying to modify a binary plugin with a fairly simple goal: copy a resource from the plugin jar into the resources of the target project. I want to use the under-utilized TextResource type instead of doing classloader introspection. The code would look something like this:
    Copy code
    URL pluginJar = MyPlugin.class.getProtectionDomain().getCodeSource().getLocation();
    TextResource bundledTemplate = project.getResources().getText().fromArchiveEntry(pluginJar, "path/to/resource");
    
    var processResourcesTask = project.getTasks().named(JavaPlugin.PROCESS_RESOURCES_TASK_NAME, ProcessResources.class, processResources -> {
      processResources.from(bundledTemplate, copy -> {
        copy.into("target/project/path");
        ...
      });
    });
    The hard part is testing. Despite setting
    org.gradle.java.compile-classpath-packaging=true
    in the project-under-test's properties, the plugin jar's codeLocation is always the classes dir, not the jar, causing
    TRF#fromArchiveEntry
    to fail while running tests. Are there better ways to do this? I don't control the plugin, so while separating the resource to another JAR would be nice and clean I probably can't do that.
    v
    • 2
    • 3
  • y

    ysb33r

    11/26/2024, 12:27 PM
    I want to add a test suite to
    testing.suites
    (from the
    jvm-test-suite
    ) in an upgrade of the GradleTest plugin. The latter has its own test task of type
    GradleTest
    which extends
    Test
    . Does anyone have a quick example of adding a test suite which does not use the default Test task?
  • a

    Andres Almiray

    12/04/2024, 10:11 AM
    Hello everyone, there’s an errror loading the
    jandex-gradle-plugin
    that I can’t quite figure out how to fix.
    Copy code
    * What went wrong:
    An exception occurred applying plugin request [id: 'org.kordamp.gradle.jandex', version: '2.1.0']
    > Failed to apply plugin 'org.kordamp.gradle.jandex'.
       > class org.kordamp.gradle.plugin.jandex.Banner$Inject cannot be cast to class org.kordamp.gradle.plugin.jandex.Banner (org.kordamp.gradle.plugin.jandex.Banner$Inject is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @941c416; org.kordamp.gradle.plugin.jandex.Banner is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @298df917)
    The class in question (Banner) is written in Java while the rest of the plugin code is in Groovy. https://github.com/kordamp/jandex-gradle-plugin/blob/master/src/main/groovy/org/kordamp/gradle/plugin/jandex/Banner.java Latest Gradle, Jandex, and Quarkus were used in the test project
    Copy code
    $ gm --version
    Using gradle at '/tmp/jandex_1.1.0_bug_reproducer/gradlew' to run buildFile '/tmp/jandex_1.1.0_bug_reproducer/build.gradle':
    
    ------------------------------------------------------------
    Gradle 8.11.1
    ------------------------------------------------------------
    
    Build time:    2024-11-20 16:56:46 UTC
    Revision:      481cb05a490e0ef9f8620f7873b83bd8a72e7c39
    
    Kotlin:        2.0.20
    Groovy:        3.0.22
    Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
    Launcher JVM:  17.0.4 (Azul Systems, Inc. 17.0.4+8-LTS)
    Daemon JVM:    /Users/aalmiray/.sdkman/candidates/java/17.0.4-zulu/zulu-17.jdk/Contents/Home (no JDK specified, using current Java home)
    OS:            Mac OS X 14.3 x86_64
    The plugin JAR does not contain the
    Banner$Inject
    class which seems to be created on the fly by Gradle upon loading
    Copy code
    $ unzip -l build/libs/jandex-gradle-plugin-2.2.0-SNAPSHOT.jar |grep Banner
          291  12-04-2024 11:05   org/kordamp/gradle/plugin/jandex/Banner$Params.class
         5647  12-04-2024 11:05   org/kordamp/gradle/plugin/jandex/Banner.class
          798  12-04-2024 11:05   org/kordamp/gradle/plugin/jandex/Banner.properties
    m
    • 2
    • 4
  • m

    Martin

    12/06/2024, 9:47 AM
    I want to create a classloader that is isolated but can still access
    Logging.getLogger()
    , is this possible? Is there a "base" Gradle classloader that I can build on top of? I don't want to use workers because of https://github.com/gradle/gradle/issues/18313
    v
    • 2
    • 3
  • e

    efemoney

    12/08/2024, 11:09 AM
    I have a custom Gradle distribution, How can I bundle plugins inside of it? ie custom distribution will include plugin jar in some folder (where?), init scripts can apply these plugins automatically by ID and the plugin types eg extensions must be available to any target build using the distribution Is this possible? If no, whats the alternative 😞?
    👀 1
    e
    • 2
    • 6
  • m

    Martin

    12/09/2024, 10:47 AM
    API evolution question: getDependencyProject() was deprecated in 8.11 and removed in 9.0. This leaves a small window for everyone to update. I'm all for removing more aggressively so that's fine by me 👍 But I was under the impression the team was a lot more convervative before. Did anything change there?
    v
    a
    • 3
    • 9
  • m

    Martin

    12/09/2024, 2:02 PM
    Is anyone monitoring the memory used by their Gradle plugins in integration tests? Mainly heap/metaspace. I could
    jstat
    /`jcmd` my way to the "good" process at the "good" time but wondering if there's something easier?
    a
    • 2
    • 1
  • j

    jrod

    12/16/2024, 5:52 PM
    Hi there 👋 not sure if this is the appropriate channel, so please redirect me, if not. Someone filed this issue on cashapp/paparazzi, regarding this recent change in the Gradle repo removing TestReporter. I know we were playing with 🔥 by referencing internal classes, but that appeared to be the only way to be able to customize test reports. See here and here where we extended the test report to include failure snapshot diffs. We still had to copy a bunch of code 😢 but TestReporter proved to be a handy entry point. Now, I realize reverting the change is likely not an option for team Gradle (is it? 😄), but would you all be open to designing a way for test report customization of some sorts in the infrastructure?
    ➕ 1
    • 1
    • 1
  • j

    jonathan gafner

    12/19/2024, 8:04 AM
    Hi 👋🏻 Maybe someone knows if there are some existing GitHub actions to help a plugin development and release flow? If not maybe someone can point me to open source plugin that have implement a workflow for the public release process? So I will be able to look and see how things should be done. Thanks 🙏🏻
    t
    m
    m
    • 4
    • 7
  • f

    Francois Dabonot (Frankois)

    12/26/2024, 5:55 PM
    Hello, I’m making a Gradle plugin, and I’m looking for tips about debugging during the development / test, I’m starting from this template as there is no so much starting project. I’m using Intellij IDE
    j
    • 2
    • 7
  • b

    Big Chungus

    12/27/2024, 11:59 PM
    How does one change the email associated with their plugins.gradle.com account?
    v
    • 2
    • 2
  • f

    Francois Dabonot (Frankois)

    01/01/2025, 7:23 PM
    Hello, I’m looking about some news of code coverage (jacoco) when developing a plugin, about TestKit and functionalTest. There is no up-to-date thing about it.
    v
    y
    • 3
    • 9
  • t

    thadhouse

    01/01/2025, 9:08 PM
    Is there anything special needed to get the problems API to actually report problems to the command line? https://docs.gradle.org/current/userguide/reporting_problems.html#command_line_interface The docs make it seem like it should be reporting a good message. But I just get a non useful error message.
    Copy code
    * What went wrong:
    A problem occurred evaluating root project 'PathWeaver'.
    > Failed to calculate the value of extension 'wpilibVersioning' property 'version'.
       > java.lang.IllegalStateException (no error message)
    The problem is occuring while evaluating a property. I wonder if thats a special case that isn't supported.
    k
    y
    • 3
    • 5
  • e

    efemoney

    01/06/2025, 5:36 AM
    Anyone have success with applying a (settings) plugin from an init script (and getting proper accessors generated for kotlin dsl!)?
  • m

    Martin

    01/07/2025, 2:55 PM
    Given an
    InputDirectory
    , can I use
    PathSensitivity.NONE
    for the directory itself but
    PathSensitivity.RELATIVE
    for its contents?
    v
    • 2
    • 6
  • a

    Alexey Loubyansky

    01/08/2025, 3:04 PM
    Custom configuration resolver Is there any way, in a plugin, to define a custom configuration and delegate its resolution to a custom dependency resolver?
    m
    v
    • 3
    • 83
  • k

    Kelvin Chung

    01/13/2025, 7:21 PM
    Sometimes I wish that we had something like a
    ArchiveOperations.zip()
    in the same manner as we have
    FileSystemOperations.copy()
    . Are there any plans to add that to the API - a way to create a zip file in a non-task way (for example, if the zip file is not meant to be a task output) without going through ant?
    v
    m
    • 3
    • 10
  • f

    Francois Dabonot (Frankois)

    01/14/2025, 8:28 AM
    Hello, I’m facing a weird behaviour of my plugin, I’m using Gradle 8.12. This is working :
    Copy code
    SwiftDependency.Package.Remote.Version(
        // Repository URL
        url = URI("<https://github.com/firebase/firebase-ios-sdk.git>"),
        // Libraries from the package
        products = {
            // Export to Kotlin for use in shared Kotlin code
            add(ProductName("FirebaseCore"), exportToKotlin = true) // OK!!
        },
        // (Optional) Package name, can be required in some cases
        packageName = "firebase-ios-sdk",
        // Package version
        version = "11.6.0",
    ),
    This is not working :
    Copy code
    val firebaseDeps =
        listOf(
            ProductName("FirebaseCore"),
        )
     SwiftDependency.Package.Remote.Version(
       // Repository URL
        url = URI("<https://github.com/firebase/firebase-ios-sdk.git>"),
        // Libraries from the package
        products = {
            // Export to Kotlin for use in shared Kotlin code
            add(firebaseDeps[0], exportToKotlin = true) // NO OK!!
        },
        // (Optional) Package name, can be required in some cases
        packageName = "firebase-ios-sdk",
        // Package version
        version = "11.6.0",
    ),
    The error :
    Copy code
    > Cannot fingerprint input property 'packageDependencies': value '[Version(url=<https://github.com/firebase/firebase-ios-sdk.git>, packageName=firebase-ios-sdk, version=11.6.0, products=io.github.frankois944.spmForKmp.definition.product.dsl.ProductPackageConfig.() -> kotlin.Unit)]' cannot be serialized.
    I understand the error, but why I can’t put a reference inside the
    add
    method?
    v
    • 2
    • 8
  • a

    Andres Almiray

    01/15/2025, 6:36 AM
    Hello, is there a way to programmatically determine the JDK used by the build? Whether it’s the same JDK used to run Gradle and/or if Toolchains were in play for a given compile task?
    v
    • 2
    • 5
  • s

    Sergej Koščejev

    01/17/2025, 3:47 PM
    In my plugin I want to provide a task to build an Ant script (by running Ant via javaexec). I would like the user to be able to configure parameters such as heap size and Ant path variables but I'm not sure if my task should extend JavaExec and customize it in the constructor or extend DefaultTask and call
    javaexec
    in its action method. Are there any known best practices or do's and don'ts?
    v
    e
    y
    • 4
    • 26
  • s

    Shreyash Saitwal

    01/20/2025, 6:45 PM
    Hi. I want to access local dependencies (declared using, say,
    implementation(fileTree("libs"))
    ) from my plugin. Is there a way to do that?
    v
    • 2
    • 8
  • f

    Felix de Souza

    01/21/2025, 12:25 AM
    is it possible to get the classifier and extension via the
    ResolvableDependencies
    api? I can get it from the
    ResolvedConfiguration
    API, but that doesn’t have all the nice
    ArtifactView
    stuff + laziness
  • n

    no

    01/24/2025, 9:59 AM
    Hello! Is there a way to run a transform only on project classes and that project's project dependencies but not external libraries?
    v
    a
    • 3
    • 14
1...121314...36Latest