community-support
  • e

    Eivind Naess

    11/30/2022, 7:11 PM
    I am sure I am going about this wrong, but is there a way I can sort-n-sift through dependencies and pick artifacts from various projects without regards for what type they are? Consider the following code:
    // Bucket to hold all dependencies
    configurations.create("implementation") {                                                                                                                                                                       
        canBeConsumed = false                                                                                                                                                                                       
        canBeResolved = false                                                                                                                                                                                       
    }                                                                                                                                                                                                               
    
    def f = configurations.create("java-configurations") {                                                                                                                                                                 
        canBeConsumed = false                                                                                                                                                                                       
        canBeResolved = true
        extendsFrom = [ configurations.implementation ]                                                                                                                                                             
    }                                                                                                                                                                                                               
    
    def ff = f.incoming.artifactView {                                                                                                                                                                              
        attributes {
            attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))                                                                                                                       
            attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
            attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
            attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JavaVersion.current().majorVersion.toInteger())                                                                                                
        }                                                                                                                                                                                                           
    }                                                                                                                                                                                                               
    
    dependencies {
        implementation project(":java-project-1")
        implementation project(":native-project-1")                                                                                                                                                                 
    }                                                                                                                                                                                                               
    
    // Dummy to test the result of the dependencies / artifactView results
    project.afterEvaluate {
        println ff.files.size() 
        println ff.files.each { fi ->                                                                                                                                                                               
            println "$fi"                                                                                                                                                                                           
        }                                                                                                                                                                                                           
    }
    The idea being to for example organize the output in a slightly different output directory than build, e.g. stage to publish a .tar.gz of all build artifacts in a particular directory structure so they don't co-reside with other artifacts like .class or .o files. Or even separate out all the test results into a specific output structure. Here, the "f" configuration, or another configuration for only native targets; cause the dependency resolution to fail in either case. Configuration "f" fails when it hits projects that doesn't have java exported variants, and a "native-link" configuration fails when it sees a Java project without any native configurations in it. In a way, I wish it could ignore dependent projects that doesn't match the configuration rather than "fail" outright. Also, the "java-configuration" doesn't specify the attributes it matches, the incoming artifactView configuration does. I was kind of hoping that not attaching attributes to a configuration, but rather use them in the artifact resolution step; it would allow me to ignore dependencies I didn't care about. I am sure this is sort of an anti-pattern to Gradle and how it was designed. I am leaning towards building a plugin that when applied to Java projects would assemble an archive that could be exported as a separate configuration with separate attributes and have them match. Similarly, but with a behavior adjusted for native projects. In the consumer project I would use "implementation" as the contextual "give me projects that list these attributes that I care about (not java, not native), but maybe "stage"?. That way, I can add dependencies that all share a common attribute that can be resolved. Just trying to wrap my head around the notion of "implementation" and the fact it feels like it means something special (almost like it is reserved) dependent on the context of the project.
  • r

    rrva

    11/30/2022, 11:14 PM
    or maybe
  • e

    Eric Kolotyluk

    11/30/2022, 11:58 PM
    eric.kolotyluk@Y2RCV7009N utils % ./gradlew clean test 
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/eric.kolotyluk/git/autonomous-iam/utils/build.gradle'
    
    * What went wrong:
    Could not compile build file '/Users/eric.kolotyluk/git/autonomous-iam/utils/build.gradle'.
    > startup failed:
      General error during conversion: Unsupported class file major version 63
      
      java.lang.IllegalArgumentException: Unsupported class file major version 63
            at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:199)
            at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:180)
            at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)
            at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:287)
    . . .
    So everything was working fine until I added to my
    build.gradle
    file
    environment 'PROCESS_LIB_INSTRUMENTATION','true'
        environment 'PROCESS_LIB_BUNDLE_LOG_LEVEL','info'
    as in
    test {
    //    useJUnit()
        useJUnitPlatform()
        maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
        environment 'PROCESS_LIB_INSTRUMENTATION','true'
        environment 'PROCESS_LIB_BUNDLE_LOG_LEVEL','info'
    }
    I see no correspondence between the change to my
    build.gradle
    and the diagnostics provided... 🤔
  • m

    melix

    12/01/2022, 10:04 AM
    The Micronaut project consists of a lot of repositories and would benefit from composite builds a lot. However, today, this doesn't quite work because of the way project identity works. For example this morning I wrote this ugly code for a coworker:
    includeBuild("../micronaut-core") {
        def modules = file("../micronaut-core/settings.gradle").readLines().findAll {
           it.startsWith('include "') && !it.startsWith('include ":test')
        }.collect { it.substring(9) - '"' }
        
        
        dependencySubstitution {
            modules.each { mod ->
                substitute module("io.micronaut:micronaut-${mod}") using project(":$mod")
            }
        }
    }
    You can see that the problem is that we have convention plugins which rename the artifact id based on the project name, so a project named
    foo
    will end up with an artifact id
    micronaut-foo
    . Is there a smarter way to avoid having to add such configuration?
  • e

    Eleanor Joslin

    12/01/2022, 11:39 AM
    Hello everyone. I'm working on a Gradle plugin that depends on classes in the
    com.github.johnrengelman.shadow
    plugin. I'm trying to upgrade it, but finding the last few releases of the plugin are missing from the Gradle Plugin Portal. I'm using Gradle 7.4.1:
    repositories {
      maven {
        url = uri("<https://plugins.gradle.org/m2/>")
      }
    }
    
    dependencies {
      api("com.github.jengelman.gradle.plugins:shadow:7.1.2")
    }
    and getting this output:
    > Task :compileKotlin FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':compileKotlin'.
    > Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
       > Could not resolve all files for configuration ':compileClasspath'.
          > Could not find com.github.jengelman.gradle.plugins:shadow:7.1.2.
            Searched in the following locations:
              - file:/Users/ejj/.m2/repository/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom
              - <https://plugins.gradle.org/m2/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom>
            Required by:
                project :
    I haven't committed a typo; 7.1.2 is listed as the latest version on https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow but versions above 6.1.0 are missing from https://plugins.gradle.org/m2/com/github/jengelman/gradle/plugins/shadow/. If I change my dependency version to 6.1.0, it finds the module OK. What would cause it to be missing? Is there something wrong with the portal? Can I find the latest release somewhere else?
  • j

    Jakub Chrzanowski

    12/01/2022, 1:07 PM
    Hi, folks! I’ve bumped the Kotlin Gradle plugin version from
    1.7.10
    to
    1.7.22
    and got the following exception:
    A problem occurred configuring root project 'gradle-intellij-plugin'.
    > Could not resolve all files for configuration ':classpath'.
       > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.22.
         Required by:
             project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.22 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22
          > Multiple incompatible variants of org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.22 were selected:
               - Variant org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.22 variant gradle70RuntimeElements has attributes {org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.plugin.api-version=7.0, org.gradle.status=release, org.gradle.usage=java-runtime}
               - Variant org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.22 variant gradle71RuntimeElements has attributes {org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.plugin.api-version=7.1, org.gradle.status=release, org.gradle.usage=java-runtime}
    
    * 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.
    Any idea what’s going one here?
  • e

    Eric Kolotyluk

    12/01/2022, 11:38 PM
    eric.kolotyluk@Y2RCV7009N helidon-nima % ../gradlew clean run
    
    > Task :helidon-nima:compileJava FAILED
    warning: using incubating module(s): jdk.incubator.concurrent
    /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/helidon-nima/src/main/java/nima/BlockingService.java:69: error: newVirtualThreadPerTaskExecutor() is a preview API and is disabled by default.
            try (var exec = Executors.newVirtualThreadPerTaskExecutor()) {
                                     ^
      (use --enable-preview to enable preview APIs)
    Note: /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/helidon-nima/src/main/java/nima/NimaMain.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    1 warning
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':helidon-nima:compileJava'.
    > Compilation failed; see the compiler error output for details.
    I cannot figure out how to tell Gradle to use the javac option
    --enable-preview
    In the parent project, I don't need to; it just works. In the subproject, I tried
    tasks {
        compileJava {
            options.allCompilerArgs += "--enable-preview"
        }
    }
    but that produces
    eric.kolotyluk@Y2RCV7009N helidon-nima % ../gradlew clean run
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':helidon-nima:run'.
    > Could not resolve all dependencies for configuration ':helidon-nima:runtimeClasspath'.
       > Could not create task ':helidon-nima:compileJava'.
          > java.lang.UnsupportedOperationException (no error message)
    It seems like Gradle is inconsistent between root project and subprojects.
  • Sebastian Schuberth

    Sebastian Schuberth

    12/02/2022, 12:02 PM
    Is it possible to create a precompiled init script written in Kotlin DSL, and then apply that (binary) plugin (locally) to a Gradle project whose Gradle version (as defined by the wrapper) does not support Kotlin DSL yet, but only Groovy DSL?
  • Jacob Rakidzich

    Jacob Rakidzich

    12/02/2022, 5:16 PM
    Hey, I'm looking into source dependencies. I see docs that say it's only for c++ but I also see some people using kotlin as a source dependency but I can't get it to work. Can we make a Kotlin source dependency? If so, how? Is anyone able point me in the right direction?
  • e

    Eric Kolotyluk

    12/02/2022, 11:36 PM
    In older Gradle projects I have used
    allprojects {
       . . .
    }
    and
    subprojects {
        . . .
    }
    But it's not clear those are supported in newer versions such as Gradle 7.6 and 8.0 Am I imagining things? Is this practice still usual, or are there new ways of doing it?
  • Lars Kaulen

    Lars Kaulen

    12/05/2022, 9:54 AM
    I'm writing a custom convention-settings-plugin based on this one: https://github.com/cloudflightio/autoconfigure-gradle-plugin/blob/main/src/main/ko[…]cloudflight/gradle/autoconfigure/AutoConfigureSettingsPlugin.kt I have two questions regarding this:1. the reckoned version is applied to all subprojects using
    settings.gradle.allprojects { project -> project.version = developmentVersion }
    , is this good practice in this context? And if not, what would be the correct way to apply the version for all projects? 2. The
    GrgitService
    is registered with
    spec.maxParallelUsages.set(1)
    . In the documentation it is mentioned, that "the build service must be registered with the using tasks via Task.usesService(Provider<? extends BuildService<?>>)". But in this case the build service isn't used within a task, but within the plugin directly, is there anything to do in this case for the
    spec.maxParallelUsages
    to take effect? Or is it even useful conceptually?
  • j

    Jakub Chrzanowski

    12/05/2022, 10:34 AM
    Hi, folks! One of projects that we provide to end-users, related to Gradle, is the IntelliJ Platform Plugin Template which is a GitHub template-like repository with all the Gradle setup prepared in advance. Recently I’ve received a pull request that I’m uncertain I want to merge. In the
    gradle.build.kts
    we’re accessing
    gradle.properties
    with a helper method:
    fun properties(key: String) = project.findProperty(key).toString()
    
    ...
    
    // Configure Gradle IntelliJ Plugin - read more: <https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html>
    intellij {
        pluginName.set(properties("pluginName"))
        version.set(properties("platformVersion"))
        type.set(properties("platformType"))
    
        // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
        plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
    }
    
    ...
    
    tasks {
        wrapper {
            gradleVersion = properties("gradleVersion")
        }
    
        ...
    }
    PR I mentioned removes that
    properties(String)
    method and accesses properties via project property delegate:
    val pluginGroup: String by project
    val pluginName: String by project
    val pluginRepositoryUrl: String by project
    val pluginVersion: String by project
    
    val pluginSinceBuild: String by project
    val pluginUntilBuild: String by project
    
    val platformType: String by project
    val platformVersion: String by project
    
    val platformPlugins: String by project
    
    val gradleVersion: String by project
    
    ...
    
    // Configure Gradle IntelliJ Plugin - read more: <https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html>
    intellij {
        pluginName.set(this@Build_gradle.pluginName)
        version.set(platformVersion)
        type.set(platformType)
    
        // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
        plugins.set(platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty))
    }
    
    ...
    
    tasks {
        wrapper {
            gradleVersion = this@Build_gradle.gradleVersion
        }
    
        ...
    }
    To me, this looks pretty messy when it comes to reading the code and I don’t see the the additional value that should come with this PR. What do you think?
  • m

    mani

    12/06/2022, 10:23 AM
    Hi Team anyone Please help me to solve how to add bom dependency in version catalog
  • m

    mani

    12/06/2022, 10:23 AM
    catalog {
        versionCatalog {
            //library("bom", "software.amazon.awssdk:bom:2.17.276")
            library("spring-retry", "org.springframework.retry:spring-retry:1.2.5.RELEASE")
            library("spring-beans", "org.springframework:spring-beans:5.2.8.RELEASE")
    
        }
    }
  • Vaios Tsitsonis

    Vaios Tsitsonis

    12/06/2022, 10:45 AM
    Hello! I am trying to update gradle from 7.5 to 7.6 and I get the following error:
    Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
    It seems that the problem is caused by the the
    kotlin-dsl
    plugin that was defined in the
    buildSrc
    . In the migration steps it is documented that it may be a breaking change but I am not sure what steps need to take (kotlin version was updated). What else do I need to do?
  • m

    mani

    12/06/2022, 1:34 PM
    I am getting below exception while trying to refer version catalog dependencies, anyone please help
  • m

    mani

    12/06/2022, 1:34 PM
    No matching variant of com.store.ope😮pe-versioncat:0.7.0-SNAPSHOT was found. The consumer was configured to find attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog' but:
    - Variant 'apiElements' capability com.store.ope😮pe-versioncat:0.7.0-SNAPSHOT: - Incompatible because this component declares attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.usage' with value 'java-api' and the consumer needed attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog'
  • Yaniv Krim

    Yaniv Krim

    12/06/2022, 3:28 PM
    Hi 🙂 What could causes resolveAndLockAll to hang and how would I go about debugging it?
  • Adrian

    Adrian

    12/06/2022, 5:30 PM
    Is there a way to get a
    DirectoryProperty
    from the
    Copy
    task’s
    destinationDir
    ?
  • Matan Sabag

    Matan Sabag

    12/07/2022, 9:51 AM
    Hi all, i’m trying to use [Kythe](https://github.com/kythe/kythe) and for that I need to configure my
    build.gradle
    as follows:
    tasks.withType(JavaCompile).configureEach {
        options.fork = true
        options.forkOptions.executable = '/opt/kythe/extractors/javac-wrapper.sh'  
    }
    I am running in this error:
    * What went wrong:
    Execution failed for task ‘:compileJava’.
    Error while evaluating property ‘javaVersion’ of task ‘:compileJava’
    > No value present
    I tried adding
    options.release.set(11)
    without any success. What do I need to add to avoid this error?
  • d

    Daren Klamer

    12/08/2022, 2:17 AM
    Hey all, does anyone know how to fix this testSuite error?
    Cannot create a TestSuite named 'JvmTestSuite' because this container does not support creating elements by name alone
    ?
  • d

    Daren Klamer

    12/08/2022, 2:18 AM
    actually i figured it out, was building with gradle 6 instead of 7
  • m

    mani

    12/08/2022, 9:12 AM
    publishTomavenLocal - version catalog not working (getting exception) when my build.gradle have apply plugin: 'rio-library'when i commented this line I can able to call dependencies from other projects, If I want to deploy remoteloty then what changes need on this. can anyone please help
  • Heath Borders

    Heath Borders

    12/08/2022, 5:29 PM
    We’re standing up a new gradle enterprise instance, and attempting to validate that build caching works, but after we run:
    ./gradlew clean
    ./gradlew --build-cache compileJava
    we get:
    > Task : compileJava
    Could not load entry c8e5e9b6464a59e66cb37b40bdd756f5 from remote build cache: Loading entry from '<https://gradle-enterprise-sandbox.twitch.a2z.com/cache/c8e5e9b6464a59e66cb37b40bdd756f5>' response
    status 403: Forbidden
    And the gradle build scan says:
    The build cache was globally disabled in the build. Please consider enabling build caching.
    I’ve attached our build.gradle and settings.gradle that we’re using to test. What are we missing?
  • s

    Sagar Pachauri

    12/09/2022, 1:52 PM
    Hi All, I am facing an issue in installing SAP Hybris setup
  • s

    Sagar Pachauri

    12/09/2022, 1:52 PM
    can anyone help me on this ?
  • s

    Sagar Pachauri

    12/09/2022, 1:57 PM
    While trying to setup Admin password using the command: install.bat -r cx -A local_property:initialpasword=nimda Error : What went wrong: Execution failed for task ':recipes:cx:createStoreFrontExt'.
    external process returned non-zero exit code, command: [cmd, /c, set "ANT_OPTS=-Xmx1024m -Dfile.encoding=UTF-8" & set "PLATFORM_HOME=C:\Users\sagarpachauri\Hybris\hybris-training\hybris\bin\platform" & set "ANT_HOME=C:\Users\sagarpachauri\OneDrive - Nagarro\Hybris\hybris-training\hybris\bin\platform\apache-ant" & set "PATH=C:\Users\sagarpachauri\Hybris\hybris-training\hybris\bin\platform\apache-ant\bin;%PATH%" & ant extgen -Dhybris.target=extgen -Dinput.template=yacceleratorstorefront -Dinput.name=yb2bacceleratorstorefront -Dinput.package=de.hybris.platform.yb2bacceleratorstorefront]
  • s

    Sagar Pachauri

    12/09/2022, 1:59 PM
    Build file 'C:\Users\sagarpachauri\Hybris\hybris-training\installer\recipes\cx\build.gradle' line: 577